fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / s390 / block / dasd_proc.c
index 70d6136..bfa010f 100644 (file)
@@ -9,13 +9,12 @@
  *
  * /proc interface for the dasd driver.
  *
- * $Revision: 1.27 $
  */
 
-#include <linux/config.h>
 #include <linux/ctype.h>
 #include <linux/seq_file.h>
 #include <linux/vmalloc.h>
+#include <linux/proc_fs.h>
 
 #include <asm/debug.h>
 #include <asm/uaccess.h>
@@ -30,7 +29,7 @@ static struct proc_dir_entry *dasd_devices_entry = NULL;
 static struct proc_dir_entry *dasd_statistics_entry = NULL;
 
 static inline char *
-dasd_get_user_string(const char *user_buf, size_t user_len)
+dasd_get_user_string(const char __user *user_buf, size_t user_len)
 {
        char *buffer;
 
@@ -77,7 +76,7 @@ dasd_devices_show(struct seq_file *m, void *v)
        else
                seq_printf(m, " is ????????");
        /* Print devices features. */
-       substr = test_bit(DASD_FLAG_RO, &device->flags) ? "(ro)" : " ";
+       substr = (device->features & DASD_FEATURE_READONLY) ? "(ro)" : " ";
        seq_printf(m, "%4s: ", substr);
        /* Print device status information. */
        switch ((device != NULL) ? device->state : -1) {
@@ -93,6 +92,9 @@ dasd_devices_show(struct seq_file *m, void *v)
        case DASD_STATE_BASIC:
                seq_printf(m, "basic");
                break;
+       case DASD_STATE_UNFMT:
+               seq_printf(m, "unformatted");
+               break;
        case DASD_STATE_READY:
        case DASD_STATE_ONLINE:
                seq_printf(m, "active ");
@@ -239,7 +241,7 @@ dasd_statistics_read(char *page, char **start, off_t off,
 }
 
 static int
-dasd_statistics_write(struct file *file, const char *user_buf,
+dasd_statistics_write(struct file *file, const char __user *user_buf,
                      unsigned long user_len, void *data)
 {
 #ifdef CONFIG_DASD_PROFILE
@@ -248,7 +250,9 @@ dasd_statistics_write(struct file *file, const char *user_buf,
        if (user_len > 65536)
                user_len = 65536;
        buffer = dasd_get_user_string(user_buf, user_len);
-       MESSAGE(KERN_INFO, "/proc/dasd/statictics: '%s'", buffer);
+       if (IS_ERR(buffer))
+               return PTR_ERR(buffer);
+       MESSAGE_LOG(KERN_INFO, "/proc/dasd/statictics: '%s'", buffer);
 
        /* check for valid verbs */
        for (str = buffer; isspace(*str); str++);
@@ -258,20 +262,20 @@ dasd_statistics_write(struct file *file, const char *user_buf,
                if (strcmp(str, "on") == 0) {
                        /* switch on statistics profiling */
                        dasd_profile_level = DASD_PROFILE_ON;
-                       MESSAGE(KERN_INFO, "%s", "Statictics switched on");
+                       MESSAGE(KERN_INFO, "%s", "Statistics switched on");
                } else if (strcmp(str, "off") == 0) {
                        /* switch off and reset statistics profiling */
                        memset(&dasd_global_profile,
                               0, sizeof (struct dasd_profile_info_t));
                        dasd_profile_level = DASD_PROFILE_OFF;
-                       MESSAGE(KERN_INFO, "%s", "Statictics switched off");
+                       MESSAGE(KERN_INFO, "%s", "Statistics switched off");
                } else
                        goto out_error;
        } else if (strncmp(str, "reset", 5) == 0) {
                /* reset the statistics */
                memset(&dasd_global_profile, 0,
                       sizeof (struct dasd_profile_info_t));
-               MESSAGE(KERN_INFO, "%s", "Statictics reset");
+               MESSAGE(KERN_INFO, "%s", "Statistics reset");
        } else
                goto out_error;
        kfree(buffer);
@@ -289,23 +293,40 @@ out_error:
 #endif                         /* CONFIG_DASD_PROFILE */
 }
 
+/*
+ * Create dasd proc-fs entries.
+ * In case creation failed, cleanup and return -ENOENT.
+ */
 int
 dasd_proc_init(void)
 {
        dasd_proc_root_entry = proc_mkdir("dasd", &proc_root);
+       if (!dasd_proc_root_entry)
+               goto out_nodasd;
        dasd_proc_root_entry->owner = THIS_MODULE;
        dasd_devices_entry = create_proc_entry("devices",
                                               S_IFREG | S_IRUGO | S_IWUSR,
                                               dasd_proc_root_entry);
+       if (!dasd_devices_entry)
+               goto out_nodevices;
        dasd_devices_entry->proc_fops = &dasd_devices_file_ops;
        dasd_devices_entry->owner = THIS_MODULE;
        dasd_statistics_entry = create_proc_entry("statistics",
                                                  S_IFREG | S_IRUGO | S_IWUSR,
                                                  dasd_proc_root_entry);
+       if (!dasd_statistics_entry)
+               goto out_nostatistics;
        dasd_statistics_entry->read_proc = dasd_statistics_read;
        dasd_statistics_entry->write_proc = dasd_statistics_write;
        dasd_statistics_entry->owner = THIS_MODULE;
        return 0;
+
+ out_nostatistics:
+       remove_proc_entry("devices", dasd_proc_root_entry);
+ out_nodevices:
+       remove_proc_entry("dasd", &proc_root);
+ out_nodasd:
+       return -ENOENT;
 }
 
 void