]> git.hungrycats.org Git - linux/commitdiff
[PATCH] cciss: add CCISS_GETLUNINFO ioctl
authorAndrew Morton <akpm@digeo.com>
Sun, 2 Mar 2003 12:38:23 +0000 (04:38 -0800)
committerDavid S. Miller <davem@nuts.ninka.net>
Sun, 2 Mar 2003 12:38:23 +0000 (04:38 -0800)
Patch from Stephen Cameron <steve.cameron@hp.com>

Add CCISS_GETLUNINFO ioctl.

This ioctl returns the LUNID, number of partitions, and current number of
opens on a logical volume.  Used by the array config utility or any app that
needs to send passthrough commands to a particular logical disk.

drivers/block/cciss.c
include/linux/cciss_ioctl.h

index 9891ae651ac8dc3a3a841ab1e21aeb09d3df5fd3..d191f96a58754895305744f230be72322688916c 100644 (file)
@@ -577,6 +577,24 @@ static int cciss_ioctl(struct inode *inode, struct file *filep,
        case CCISS_REVALIDVOLS:
                 return( revalidate_allvol(inode->i_rdev));
 
+       case CCISS_GETLUNINFO: {
+               LogvolInfo_struct luninfo;
+               struct gendisk *disk = hba[ctlr]->gendisk[dsk];
+               drive_info_struct *drv = &hba[ctlr]->drv[dsk];
+               int i;
+               
+               luninfo.LunID = drv->LunID;
+               luninfo.num_opens = drv->usage_count;
+               luninfo.num_parts = 0;
+               /* count partitions 1 to 15 with sizes > 0 */
+               for(i=1; i <MAX_PART; i++)
+                       if (disk->part[i].nr_sects != 0)
+                               luninfo.num_parts++;
+               if (copy_to_user((void *) arg, &luninfo,
+                               sizeof(LogvolInfo_struct)))
+                       return -EFAULT;
+               return(0);
+       }
        case CCISS_DEREGDISK:
                return( deregister_disk(ctlr,dsk));
 
index 2f7e00b5b58174ebb06bb171f6461bdb80bf3078..e706b9406ef7862f1964b55b01e8330aae2d88f8 100644 (file)
@@ -169,6 +169,11 @@ typedef struct _IOCTL_Command_struct {
   BYTE                    *buf;
 } IOCTL_Command_struct;
 
+typedef struct _LogvolInfo_struct{
+       __u32   LunID;
+       int     num_opens;  /* number of opens on the logical volume */
+       int     num_parts;  /* number of partitions configured on logvol */
+} LogvolInfo_struct;
 
 #define CCISS_GETPCIINFO _IOR(CCISS_IOC_MAGIC, 1, cciss_pci_info_struct)
 
@@ -190,5 +195,6 @@ typedef struct _IOCTL_Command_struct {
 #define CCISS_REGNEWDISK  _IOW(CCISS_IOC_MAGIC, 13, int)
 
 #define CCISS_REGNEWD     _IO(CCISS_IOC_MAGIC, 14)
+#define CCISS_GETLUNINFO   _IOR(CCISS_IOC_MAGIC, 17, LogvolInfo_struct)
 
 #endif