Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 27922b4260f65d317aabda37e42bbbff > files > 292

kernel-2.6.18-238.el5.src.rpm

From: Tomas Henzl <thenzl@redhat.com>
Date: Sun, 29 Aug 2010 15:49:27 -0400
Subject: [block] cciss: add lunid attribute to log drives in /sys
Message-id: <1283097002-3341-29-git-send-email-thenzl@redhat.com>
Patchwork-id: 27875
O-Subject: [RHEL6 PATCH 28/63] cciss: Add lunid attribute to log drives in /sys
Bugzilla: 568830
RH-Acked-by: Neil Horman <nhorman@redhat.com>

Add lunid attribute to logical drives in sysfs

diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 8436470..de6ae68 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -578,11 +578,38 @@ static ssize_t dev_show_rev(struct device *dev,
 }
 DEVICE_ATTR(rev, S_IRUGO, dev_show_rev, NULL);
 
+static ssize_t cciss_show_lunid(struct device *dev,
+				struct device_attribute *attr, char *buf)
+{
+	drive_info_struct *drv = dev_get_drvdata(dev);
+	struct ctlr_info *h = to_hba(drv->dev->parent);
+	unsigned long flags;
+	unsigned char lunid[8];
+
+	spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags);
+	if (h->busy_configuring) {
+		spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags);
+		return -EBUSY;
+	}
+	if (!drv->heads) {
+		spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags);
+		return -ENOTTY;
+	}
+	memcpy(lunid, drv->LunID, sizeof(lunid));
+	spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags);
+	return snprintf(buf, 20, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n",
+			lunid[0], lunid[1], lunid[2], lunid[3],
+			lunid[4], lunid[5], lunid[6], lunid[7]);
+
+}
+DEVICE_ATTR(lunid, S_IRUGO, cciss_show_lunid, NULL);
+
 struct device_attribute *cciss_dev_attrs[] = {
 	&dev_attr_unique_id,
 	&dev_attr_vendor,
 	&dev_attr_model,
 	&dev_attr_rev,
+	&dev_attr_lunid,
 	NULL,
 };