nfs: new subdir Documentation/filesystems/nfs
[safe/jmp/linux-2.6] / lib / kobject_uevent.c
index 9f8d599..920a3ca 100644 (file)
@@ -118,6 +118,13 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
        kset = top_kobj->kset;
        uevent_ops = kset->uevent_ops;
 
+       /* skip the event, if uevent_suppress is set*/
+       if (kobj->uevent_suppress) {
+               pr_debug("kobject: '%s' (%p): %s: uevent_suppress "
+                                "caused the event to drop!\n",
+                                kobject_name(kobj), kobj, __func__);
+               return 0;
+       }
        /* skip the event, if the filter returns zero. */
        if (uevent_ops && uevent_ops->filter)
                if (!uevent_ops->filter(kset, kobj)) {
@@ -165,7 +172,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
        /* keys passed in from the caller */
        if (envp_ext) {
                for (i = 0; envp_ext[i]; i++) {
-                       retval = add_uevent_var(env, envp_ext[i]);
+                       retval = add_uevent_var(env, "%s", envp_ext[i]);
                        if (retval)
                                goto exit;
                }
@@ -225,8 +232,13 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
                        }
 
                        NETLINK_CB(skb).dst_group = 1;
-                       netlink_broadcast(uevent_sock, skb, 0, 1, GFP_KERNEL);
-               }
+                       retval = netlink_broadcast(uevent_sock, skb, 0, 1,
+                                                  GFP_KERNEL);
+                       /* ENOBUFS should be handled in userspace */
+                       if (retval == -ENOBUFS)
+                               retval = 0;
+               } else
+                       retval = -ENOMEM;
        }
 #endif
 
@@ -285,8 +297,7 @@ int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...)
        int len;
 
        if (env->envp_idx >= ARRAY_SIZE(env->envp)) {
-               printk(KERN_ERR "add_uevent_var: too many keys\n");
-               WARN_ON(1);
+               WARN(1, KERN_ERR "add_uevent_var: too many keys\n");
                return -ENOMEM;
        }
 
@@ -297,8 +308,7 @@ int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...)
        va_end(args);
 
        if (len >= (sizeof(env->buf) - env->buflen)) {
-               printk(KERN_ERR "add_uevent_var: buffer size too small\n");
-               WARN_ON(1);
+               WARN(1, KERN_ERR "add_uevent_var: buffer size too small\n");
                return -ENOMEM;
        }
 
@@ -318,7 +328,7 @@ static int __init kobject_uevent_init(void)
                       "kobject_uevent: unable to create netlink socket!\n");
                return -ENODEV;
        }
-
+       netlink_set_nonroot(NETLINK_KOBJECT_UEVENT, NL_NONROOT_RECV);
        return 0;
 }