]> err.no Git - linux-2.6/commitdiff
[S390] dasd: Add sysfs attribute status and generate uevents.
authorHorst Hummel <horst.hummel@de.ibm.com>
Fri, 27 Apr 2007 14:01:47 +0000 (16:01 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Fri, 27 Apr 2007 14:01:44 +0000 (16:01 +0200)
This patch adds a sysfs-attribute 'status' to make the DASD device-status
accessible from user-space. In addition, the DASD driver generates an
uevent(CHANGE) for the ccw-device on each device-status change.
This enables user-space applications (e.g. udev) to do related processing.

Signed-off-by: Horst Hummel <horst.hummel@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
drivers/s390/block/dasd.c
drivers/s390/block/dasd_devmap.c

index eb5dc62f0d9c25cdace3239f3a5aacdf613f72ee..e71929db8b0642b5fcd1fa347dfff3898f64df21 100644 (file)
@@ -398,6 +398,9 @@ dasd_change_state(struct dasd_device *device)
 
        if (device->state == device->target)
                wake_up(&dasd_init_waitq);
+
+       /* let user-space know that the device status changed */
+       kobject_uevent(&device->cdev->dev.kobj, KOBJ_CHANGE);
 }
 
 /*
index ed70852cc9154666a0bffeb95d813c2cbd762268..66958b8d7c45bef3fb452fc671d2e6e71cf7f62e 100644 (file)
@@ -828,6 +828,46 @@ dasd_discipline_show(struct device *dev, struct device_attribute *attr,
 
 static DEVICE_ATTR(discipline, 0444, dasd_discipline_show, NULL);
 
+static ssize_t
+dasd_device_status_show(struct device *dev, struct device_attribute *attr,
+                    char *buf)
+{
+       struct dasd_device *device;
+       ssize_t len;
+
+       device = dasd_device_from_cdev(to_ccwdev(dev));
+       if (!IS_ERR(device)) {
+               switch (device->state) {
+               case DASD_STATE_NEW:
+                       len = snprintf(buf, PAGE_SIZE, "new\n");
+                       break;
+               case DASD_STATE_KNOWN:
+                       len = snprintf(buf, PAGE_SIZE, "detected\n");
+                       break;
+               case DASD_STATE_BASIC:
+                       len = snprintf(buf, PAGE_SIZE, "basic\n");
+                       break;
+               case DASD_STATE_UNFMT:
+                       len = snprintf(buf, PAGE_SIZE, "unformatted\n");
+                       break;
+               case DASD_STATE_READY:
+                       len = snprintf(buf, PAGE_SIZE, "ready\n");
+                       break;
+               case DASD_STATE_ONLINE:
+                       len = snprintf(buf, PAGE_SIZE, "online\n");
+                       break;
+               default:
+                       len = snprintf(buf, PAGE_SIZE, "no stat\n");
+                       break;
+               }
+               dasd_put_device(device);
+       } else
+               len = snprintf(buf, PAGE_SIZE, "unknown\n");
+       return len;
+}
+
+static DEVICE_ATTR(status, 0444, dasd_device_status_show, NULL);
+
 static ssize_t
 dasd_alias_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
@@ -939,6 +979,7 @@ static DEVICE_ATTR(eer_enabled, 0644, dasd_eer_show, dasd_eer_store);
 static struct attribute * dasd_attrs[] = {
        &dev_attr_readonly.attr,
        &dev_attr_discipline.attr,
+       &dev_attr_status.attr,
        &dev_attr_alias.attr,
        &dev_attr_vendor.attr,
        &dev_attr_uid.attr,