qemu-devel
[Top][All Lists]
Advanced

[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>

Attachment: pgpDMo942gHh7.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]