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 <stefa...@redhat.com>

Attachment: pgpBC7ie_e7bV.pgp
Description: PGP signature

Reply via email to