[WATCHDOG] Documentation/watchdog/src/watchdog-simple.c: improve this code
[pandora-kernel.git] / kernel / ksysfs.c
index 559deca..65daa53 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/kexec.h>
+#include <linux/sched.h>
 
 #define KERNEL_ATTR_RO(_name) \
 static struct subsys_attribute _name##_attr = __ATTR_RO(_name)
@@ -60,8 +61,39 @@ static ssize_t kexec_crash_loaded_show(struct kset *kset, char *page)
        return sprintf(page, "%d\n", !!kexec_crash_image);
 }
 KERNEL_ATTR_RO(kexec_crash_loaded);
+
+static ssize_t vmcoreinfo_show(struct kset *kset, char *page)
+{
+       return sprintf(page, "%lx %x\n",
+                      paddr_vmcoreinfo_note(),
+                      (unsigned int)vmcoreinfo_max_size);
+}
+KERNEL_ATTR_RO(vmcoreinfo);
+
 #endif /* CONFIG_KEXEC */
 
+/*
+ * Make /sys/kernel/notes give the raw contents of our kernel .notes section.
+ */
+extern const void __start_notes __attribute__((weak));
+extern const void __stop_notes __attribute__((weak));
+#define        notes_size (&__stop_notes - &__start_notes)
+
+static ssize_t notes_read(struct kobject *kobj, struct bin_attribute *bin_attr,
+                         char *buf, loff_t off, size_t count)
+{
+       memcpy(buf, &__start_notes + off, count);
+       return count;
+}
+
+static struct bin_attribute notes_attr = {
+       .attr = {
+               .name = "notes",
+               .mode = S_IRUGO,
+       },
+       .read = &notes_read,
+};
+
 decl_subsys(kernel, NULL, NULL);
 EXPORT_SYMBOL_GPL(kernel_subsys);
 
@@ -73,6 +105,7 @@ static struct attribute * kernel_attrs[] = {
 #ifdef CONFIG_KEXEC
        &kexec_loaded_attr.attr,
        &kexec_crash_loaded_attr.attr,
+       &vmcoreinfo_attr.attr,
 #endif
        NULL
 };
@@ -88,6 +121,19 @@ static int __init ksysfs_init(void)
                error = sysfs_create_group(&kernel_subsys.kobj,
                                           &kernel_attr_group);
 
+       if (!error && notes_size > 0) {
+               notes_attr.size = notes_size;
+               error = sysfs_create_bin_file(&kernel_subsys.kobj,
+                                             &notes_attr);
+       }
+
+       /*
+        * Create "/sys/kernel/uids" directory and corresponding root user's
+        * directory under it.
+        */
+       if (!error)
+               error = uids_kobject_init();
+
        return error;
 }