rpms/parted/devel parted-1.6.25-sgio.patch,NONE,1.1

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Thu Dec 1 22:27:13 UTC 2005


Author: pjones

Update of /cvs/dist/rpms/parted/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv28814

Added Files:
	parted-1.6.25-sgio.patch 
Log Message:
- change from using sg to using SG_IO.  This needs some testing, so it's
  not in the spec just yet.


parted-1.6.25-sgio.patch:
 linux.c |   52 ++++++++++++++++++++++++----------------------------
 1 files changed, 24 insertions(+), 28 deletions(-)

--- NEW FILE parted-1.6.25-sgio.patch ---
--- parted-1.6.25/libparted/linux.c.sgio	2005-11-18 13:14:40.000000000 -0500
+++ parted-1.6.25/libparted/linux.c	2005-11-18 13:19:07.000000000 -0500
@@ -38,6 +38,7 @@
 #include <sys/types.h>
 #include <sys/utsname.h>	/* for uname() */
 #include <scsi/scsi.h>
+#include <scsi/sg.h>
 #include <libdevmapper.h>
 
 #include "blkpg.h"
@@ -680,8 +681,7 @@
 }
 
 /* This function sends a query to a SCSI device for vendor and product
- * information.  It uses the deprecated SCSI_IOCTL_SEND_COMMAND to
- * issue this query.
+ * information.  It uses the SG_IO ioctl to issue this query.
  */
 static int
 scsi_query_product_info (PedDevice* dev, char **vendor, char **product)
@@ -714,42 +714,38 @@
 		uint8_t _reserved3[40];
 	} __attribute__((packed)) scsi_inquiry_data_t;
 
-	struct scsi_arg
-	{
-		unsigned int inlen;
-		unsigned int outlen;
-
-		union arg_data
-		{
-			scsi_inquiry_data_t out;
-			scsi_inquiry_cmd_t  in;
-		} data;
-	} arg;
-
+        struct sg_io_hdr hdr;
+        scsi_inquiry_cmd_t in;
+        scsi_inquiry_data_t out;
 	LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev);
 	char	buf[32];
 
 	*vendor = NULL;
 	*product = NULL;
 
-	memset (&arg, 0x00, sizeof(struct scsi_arg));
-	arg.inlen  = 0;
-	arg.outlen = sizeof(scsi_inquiry_data_t);
-	arg.data.in.op  = INQUIRY;
-	arg.data.in.lun = dev->host << 5;
-	arg.data.in.alloc_length = sizeof(scsi_inquiry_data_t);
-	arg.data.in.page_code = 0;
-	arg.data.in.reserved = 0;
-	arg.data.in.control = 0;
-
-	if (ioctl (arch_specific->fd, SCSI_IOCTL_SEND_COMMAND, &arg) < 0)
+        memset (&in, 0, sizeof(in));
+        in.op  = INQUIRY;
+	in.lun = dev->host << 5;
+	in.alloc_length = sizeof(scsi_inquiry_data_t);
+	in.page_code = 0;
+	in.reserved = 0;
+	in.control = 0;
+
+        memset (&out, 0, sizeof(out));
+        memset (&hdr, 0, sizeof(hdr));
+        hdr.cmdp = ∈
+        hdr.cmd_len = sizeof(in);
+        hdr.dxfer_len = sizeof(out);
+        hdr.dxfer_direction = SG_DXFER_FROM_DEV;
+        
+	if (ioctl (arch_specific->fd, SG_IO, &hdr) < 0)
 		return 0;
 
-	memcpy (buf, arg.data.out.vendor_id, 8);
+	memcpy (buf, out.vendor_id, 8);
 	buf[8] = '\0';
 	*vendor = strip_name (buf);
 
-	memcpy (buf, arg.data.out.product_id, 16);
+	memcpy (buf, out.product_id, 16);
 	buf[16] = '\0';
 	*product = strip_name (buf);
 
@@ -758,7 +754,7 @@
 
 /* This function provides the vendor and product name for a SCSI device.
  * It supports both the modern /sys interface and direct queries
- * via the deprecated ioctl, SCSI_IOCTL_SEND_COMMAND.
+ * via the SG_IO ioctl.
  */
 static int
 scsi_get_product_info (PedDevice* dev, char **vendor, char **product)




More information about the fedora-cvs-commits mailing list