]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - lib/kobject_uevent.c
ext4: move headers out of include/linux
[linux-2.6-omap-h63xx.git] / lib / kobject_uevent.c
index 51dc4d287addf9846b6c4b13ddc8c38ca4692bf4..9fb6b86cf6b15970ede185e8233a975dd4049d8a 100644 (file)
  */
 
 #include <linux/spinlock.h>
+#include <linux/string.h>
+#include <linux/kobject.h>
+#include <linux/module.h>
+
 #include <linux/socket.h>
 #include <linux/skbuff.h>
 #include <linux/netlink.h>
-#include <linux/string.h>
-#include <linux/kobject.h>
 #include <net/sock.h>
 
 
@@ -55,7 +57,7 @@ int kobject_action_type(const char *buf, size_t count,
        enum kobject_action action;
        int ret = -EINVAL;
 
-       if (count && buf[count-1] == '\n')
+       if (count && (buf[count-1] == '\n' || buf[count-1] == '\0'))
                count--;
 
        if (!count)
@@ -180,6 +182,17 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
                }
        }
 
+       /*
+        * Mark "add" and "remove" events in the object to ensure proper
+        * events to userspace during automatic cleanup. If the object did
+        * send an "add" event, "remove" will automatically generated by
+        * the core, if not already done by the caller.
+        */
+       if (action == KOBJ_ADD)
+               kobj->state_add_uevent_sent = 1;
+       else if (action == KOBJ_REMOVE)
+               kobj->state_remove_uevent_sent = 1;
+
        /* we will send an event, so request a new sequence number */
        spin_lock(&sequence_lock);
        seq = ++uevent_seqnum;
@@ -227,11 +240,12 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
                retval = add_uevent_var(env, "HOME=/");
                if (retval)
                        goto exit;
-               retval = add_uevent_var(env, "PATH=/sbin:/bin:/usr/sbin:/usr/bin");
+               retval = add_uevent_var(env,
+                                       "PATH=/sbin:/bin:/usr/sbin:/usr/bin");
                if (retval)
                        goto exit;
 
-               call_usermodehelper (argv[0], argv, env->envp, UMH_WAIT_EXEC);
+               call_usermodehelper(argv[0], argv, env->envp, UMH_WAIT_EXEC);
        }
 
 exit:
@@ -239,7 +253,6 @@ exit:
        kfree(env);
        return retval;
 }
-
 EXPORT_SYMBOL_GPL(kobject_uevent_env);
 
 /**
@@ -255,7 +268,6 @@ int kobject_uevent(struct kobject *kobj, enum kobject_action action)
 {
        return kobject_uevent_env(kobj, action, NULL);
 }
-
 EXPORT_SYMBOL_GPL(kobject_uevent);
 
 /**