raw-posix: Introduce hdev_is_sg()
authorDimitris Aragiorgis <dimara@arrikto.com>
Tue, 23 Jun 2015 10:45:00 +0000 (13:45 +0300)
committerStefan Hajnoczi <stefanha@redhat.com>
Tue, 23 Jun 2015 14:08:52 +0000 (15:08 +0100)
commit3307ed7b3fac5ba99eb3b84904b0b7cdc3592a61
treefb98300d62b250a8976a07a9384a6ba27402d2e0
parenta93a3982a6645463fa822131d38b17284edd5633
raw-posix: Introduce hdev_is_sg()

Until now, an SG device was identified only by checking if its path
started with "/dev/sg". Then, hdev_open() would set the bs->sg flag
accordingly. The patch relies on the actual properties of the device
instead of the specified file path.

To this end, test for an SG device (e.g. /dev/sg0) by ensuring that
all of the following holds:

 - The specified file name corresponds to a character device
 - The device supports the SG_GET_VERSION_NUM ioctl
 - The device supports the SG_GET_SCSI_ID ioctl

Signed-off-by: Dimitris Aragiorgis <dimara@arrikto.com>
Message-id: 1435056300-14924-6-git-send-email-dimara@arrikto.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block/raw-posix.c