Skip to contentSkip to conversation

get-identity ioctl in libata?

PATCH Jeff Garzik 2 participants 2 messages Mar 8, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Bart,

Did you say that there was some problem with the patch to add HDIO_GET_IDENTITY support to libata (attached)?

I forget what the issues were, and this has been sitting in libata-dev-2.6 for a while.

Jeff

drivers/scsi/libata-scsi.c +22 -0
diff -Nru a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
@@ -72,6 +72,17 @@
 	struct ata_port *ap;
 	struct ata_device *dev;
 	int val = -EINVAL, rc = -EINVAL;
+	struct hd_driveid drv_id = {
+		.cyls		= 0,
+		.sectors	= 0,
+		.heads		= 0,
+		.fw_rev		= "",
+		.model		= "",
+		.cur_cyls	= 0,
+		.cur_heads	= 0,
+		.cur_sectors	= 0,
+	};
+	int geom[3];
 
 	ap = (struct ata_port *) &scsidev->host->hostdata[0];
 	if (!ap)
@@ -94,6 +105,17 @@
 		val = (unsigned long) arg;
 		if (val != 0)
 			return -EINVAL;
+		return 0;
+
+	case HDIO_GET_IDENTITY:
+		ata_std_bios_param(scsidev, NULL, dev->n_sectors, geom);
+		drv_id.cur_heads	= drv_id.heads		= geom[0];
+		drv_id.cur_sectors	= drv_id.sectors	= geom[1];
+		drv_id.cur_cyls		= drv_id.cyls		= geom[2];
+		strncpy((char *) &drv_id.model, scsidev->model, sizeof(drv_id.model));
+		strncpy((char *) &drv_id.fw_rev, scsidev->rev, sizeof(drv_id.fw_rev));
+		if(copy_to_user((char *) arg, (char *) &drv_id, sizeof(drv_id)))
+			return(-EFAULT);
 		return 0;
 
 	default:
#1 lore raw

Hi Jeff,

My concerns are following:
* it is not complete HDIO_GET_IDENTIFY implementation (applications may assume otherwise)
* you may need to add byte-swapping of the fields in the future (currently it is fine)
* same info is available via pass-thru inteface

Bartlomiej

Quoted 53 lines · Jeff Garzik

Bart,

Did you say that there was some problem with the patch to add HDIO_GET_IDENTITY support to libata (attached)?

I forget what the issues were, and this has been sitting in libata-dev-2.6 for a while.

Jeff

diff -Nru a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c

drivers/scsi/libata-scsi.c 2005-03-07 23:44:42 -05:00 +22 -0
@@ -72,6 +72,17 @@
        struct ata_port *ap;
        struct ata_device *dev;
        int val = -EINVAL, rc = -EINVAL;
+       struct hd_driveid drv_id = {
+               .cyls           = 0,
+               .sectors        = 0,
+               .heads          = 0,
+               .fw_rev         = "",
+               .model          = "",
+               .cur_cyls       = 0,
+               .cur_heads      = 0,
+               .cur_sectors    = 0,
+       };
+       int geom[3];
 
        ap = (struct ata_port *) &scsidev->host->hostdata[0];
        if (!ap)
@@ -94,6 +105,17 @@
                val = (unsigned long) arg;
                if (val != 0)
                        return -EINVAL;
+               return 0;
+
+       case HDIO_GET_IDENTITY:
+               ata_std_bios_param(scsidev, NULL, dev->n_sectors, geom);
+               drv_id.cur_heads        = drv_id.heads          = geom[0];
+               drv_id.cur_sectors      = drv_id.sectors        = geom[1];
+               drv_id.cur_cyls         = drv_id.cyls           = geom[2];
+               strncpy((char *) &drv_id.model, scsidev->model, sizeof(drv_id.model));
+               strncpy((char *) &drv_id.fw_rev, scsidev->rev, sizeof(drv_id.fw_rev));
+               if(copy_to_user((char *) arg, (char *) &drv_id, sizeof(drv_id)))
+                       return(-EFAULT);
                return 0;
 
        default: