[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v5 5/5] raw-posix: Introduce hdev_is_sg()
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH v5 5/5] raw-posix: Introduce hdev_is_sg() |
Date: |
Tue, 23 Jun 2015 15:03:30 +0100 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Tue, Jun 23, 2015 at 01:45:00PM +0300, Dimitris Aragiorgis wrote:
> +static bool hdev_is_sg(BlockDriverState *bs)
> +{
> +
> +#if defined(__linux__)
> +
> + struct stat st;
> + struct sg_scsi_id scsiid;
> + int sg_version;
> +
> + if (stat(bs->filename, &st) >= 0 && S_ISCHR(st.st_mode) &&
> + !bdrv_ioctl(bs, SG_GET_VERSION_NUM, &sg_version) &&
> + !bdrv_ioctl(bs, SG_GET_SCSI_ID, &scsiid)) {
> + DPRINTF("SG device found: type=%d, version=%d\n",
> + scsiid.scsi_type, sg_version);
> + return true;
> + }
If you respin this series, please use fstat() instead of stat() since we
already have the file descriptor open. That ensures the stat is really
for the same file as the one we already have open (it avoids the race
condition).
I don't see a practical danger in using stat() for the time being:
Reviewed-by: Stefan Hajnoczi <address@hidden>
pgpDMo942gHh7.pgp
Description: PGP signature
- [Qemu-devel] [PATCH v5 0/5] Some fixes related to scsi-generic, Dimitris Aragiorgis, 2015/06/23
- [Qemu-devel] [PATCH v5 2/5] Fix migration in case of scsi-generic, Dimitris Aragiorgis, 2015/06/23
- [Qemu-devel] [PATCH v5 3/5] raw-posix: DPRINTF instead of DEBUG_BLOCK_PRINT, Dimitris Aragiorgis, 2015/06/23
- [Qemu-devel] [PATCH v5 4/5] raw-posix: Use DPRINTF for DEBUG_FLOPPY, Dimitris Aragiorgis, 2015/06/23
- [Qemu-devel] [PATCH v5 1/5] block: Use bdrv_is_sg() everywhere, Dimitris Aragiorgis, 2015/06/23
- [Qemu-devel] [PATCH v5 5/5] raw-posix: Introduce hdev_is_sg(), Dimitris Aragiorgis, 2015/06/23
- Re: [Qemu-devel] [PATCH v5 5/5] raw-posix: Introduce hdev_is_sg(),
Stefan Hajnoczi <=
- Re: [Qemu-devel] [PATCH v5 0/5] Some fixes related to scsi-generic, Stefan Hajnoczi, 2015/06/23