Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * kernel userspace event delivery |
| 3 | * |
| 4 | * Copyright (C) 2004 Red Hat, Inc. All rights reserved. |
| 5 | * Copyright (C) 2004 Novell, Inc. All rights reserved. |
| 6 | * Copyright (C) 2004 IBM, Inc. All rights reserved. |
| 7 | * |
| 8 | * Licensed under the GNU GPL v2. |
| 9 | * |
| 10 | * Authors: |
| 11 | * Robert Love <rml@novell.com> |
| 12 | * Kay Sievers <kay.sievers@vrfy.org> |
| 13 | * Arjan van de Ven <arjanv@redhat.com> |
| 14 | * Greg Kroah-Hartman <greg@kroah.com> |
| 15 | */ |
| 16 | |
| 17 | #include <linux/spinlock.h> |
| 18 | #include <linux/socket.h> |
| 19 | #include <linux/skbuff.h> |
| 20 | #include <linux/netlink.h> |
| 21 | #include <linux/string.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | #include <linux/kobject.h> |
| 23 | #include <net/sock.h> |
| 24 | |
Benjamin Herrenschmidt | d87499e | 2006-01-25 10:21:32 +1100 | [diff] [blame] | 25 | #define BUFFER_SIZE 2048 /* buffer for the variables */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #define NUM_ENVP 32 /* number of env pointers */ |
| 27 | |
Kay Sievers | 60a96a5 | 2007-07-08 22:29:26 +0200 | [diff] [blame] | 28 | /* the strings here must match the enum in include/linux/kobject.h */ |
| 29 | const char *kobject_actions[] = { |
| 30 | "add", |
| 31 | "remove", |
| 32 | "change", |
| 33 | "move", |
| 34 | "online", |
| 35 | "offline", |
| 36 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
Cornelia Huck | cd030c4 | 2007-07-20 13:58:13 +0200 | [diff] [blame] | 38 | #if defined(CONFIG_HOTPLUG) |
| 39 | u64 uevent_seqnum; |
| 40 | char uevent_helper[UEVENT_HELPER_PATH_LEN] = "/sbin/hotplug"; |
| 41 | static DEFINE_SPINLOCK(sequence_lock); |
| 42 | #if defined(CONFIG_NET) |
| 43 | static struct sock *uevent_sock; |
| 44 | #endif |
| 45 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | /** |
Cornelia Huck | 8a82472 | 2006-11-20 17:07:51 +0100 | [diff] [blame] | 47 | * kobject_uevent_env - send an uevent with environmental data |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | * |
Cornelia Huck | 8a82472 | 2006-11-20 17:07:51 +0100 | [diff] [blame] | 49 | * @action: action that is happening (usually KOBJ_MOVE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | * @kobj: struct kobject that the action is happening to |
Cornelia Huck | 8a82472 | 2006-11-20 17:07:51 +0100 | [diff] [blame] | 51 | * @envp_ext: pointer to environmental data |
Aneesh Kumar K.V | 542cfce | 2006-12-19 13:01:27 -0800 | [diff] [blame] | 52 | * |
| 53 | * Returns 0 if kobject_uevent() is completed with success or the |
| 54 | * corresponding error when it fails. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | */ |
Aneesh Kumar K.V | 542cfce | 2006-12-19 13:01:27 -0800 | [diff] [blame] | 56 | int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, |
Cornelia Huck | 8a82472 | 2006-11-20 17:07:51 +0100 | [diff] [blame] | 57 | char *envp_ext[]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | { |
Kay Sievers | 5f123fb | 2005-11-11 14:43:07 +0100 | [diff] [blame] | 59 | char **envp; |
| 60 | char *buffer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | char *scratch; |
Kay Sievers | 5f123fb | 2005-11-11 14:43:07 +0100 | [diff] [blame] | 62 | const char *action_string; |
| 63 | const char *devpath = NULL; |
| 64 | const char *subsystem; |
| 65 | struct kobject *top_kobj; |
| 66 | struct kset *kset; |
Kay Sievers | 312c004 | 2005-11-16 09:00:00 +0100 | [diff] [blame] | 67 | struct kset_uevent_ops *uevent_ops; |
Kay Sievers | 5f123fb | 2005-11-11 14:43:07 +0100 | [diff] [blame] | 68 | u64 seq; |
| 69 | char *seq_buff; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | int i = 0; |
Aneesh Kumar K.V | 542cfce | 2006-12-19 13:01:27 -0800 | [diff] [blame] | 71 | int retval = 0; |
Cornelia Huck | 8a82472 | 2006-11-20 17:07:51 +0100 | [diff] [blame] | 72 | int j; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | |
Kay Sievers | 5f123fb | 2005-11-11 14:43:07 +0100 | [diff] [blame] | 74 | pr_debug("%s\n", __FUNCTION__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | |
Kay Sievers | 60a96a5 | 2007-07-08 22:29:26 +0200 | [diff] [blame] | 76 | action_string = kobject_actions[action]; |
Aneesh Kumar K.V | 542cfce | 2006-12-19 13:01:27 -0800 | [diff] [blame] | 77 | if (!action_string) { |
| 78 | pr_debug("kobject attempted to send uevent without action_string!\n"); |
| 79 | return -EINVAL; |
| 80 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | |
Kay Sievers | 5f123fb | 2005-11-11 14:43:07 +0100 | [diff] [blame] | 82 | /* search the kset we belong to */ |
| 83 | top_kobj = kobj; |
John Anthony Kazos Jr | 14193fb | 2007-04-04 07:39:17 -0400 | [diff] [blame] | 84 | while (!top_kobj->kset && top_kobj->parent) { |
| 85 | top_kobj = top_kobj->parent; |
Kay Sievers | 5f123fb | 2005-11-11 14:43:07 +0100 | [diff] [blame] | 86 | } |
Aneesh Kumar K.V | 542cfce | 2006-12-19 13:01:27 -0800 | [diff] [blame] | 87 | if (!top_kobj->kset) { |
| 88 | pr_debug("kobject attempted to send uevent without kset!\n"); |
| 89 | return -EINVAL; |
| 90 | } |
Kay Sievers | 5f123fb | 2005-11-11 14:43:07 +0100 | [diff] [blame] | 91 | |
| 92 | kset = top_kobj->kset; |
Kay Sievers | 312c004 | 2005-11-16 09:00:00 +0100 | [diff] [blame] | 93 | uevent_ops = kset->uevent_ops; |
Kay Sievers | 5f123fb | 2005-11-11 14:43:07 +0100 | [diff] [blame] | 94 | |
| 95 | /* skip the event, if the filter returns zero. */ |
Kay Sievers | 312c004 | 2005-11-16 09:00:00 +0100 | [diff] [blame] | 96 | if (uevent_ops && uevent_ops->filter) |
Aneesh Kumar K.V | 542cfce | 2006-12-19 13:01:27 -0800 | [diff] [blame] | 97 | if (!uevent_ops->filter(kset, kobj)) { |
| 98 | pr_debug("kobject filter function caused the event to drop!\n"); |
| 99 | return 0; |
| 100 | } |
Kay Sievers | 5f123fb | 2005-11-11 14:43:07 +0100 | [diff] [blame] | 101 | |
Kay Sievers | 8640624 | 2007-03-14 03:25:56 +0100 | [diff] [blame] | 102 | /* originating subsystem */ |
| 103 | if (uevent_ops && uevent_ops->name) |
| 104 | subsystem = uevent_ops->name(kset, kobj); |
| 105 | else |
| 106 | subsystem = kobject_name(&kset->kobj); |
| 107 | if (!subsystem) { |
| 108 | pr_debug("unset subsytem caused the event to drop!\n"); |
| 109 | return 0; |
| 110 | } |
| 111 | |
Kay Sievers | 5f123fb | 2005-11-11 14:43:07 +0100 | [diff] [blame] | 112 | /* environment index */ |
| 113 | envp = kzalloc(NUM_ENVP * sizeof (char *), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | if (!envp) |
Aneesh Kumar K.V | 542cfce | 2006-12-19 13:01:27 -0800 | [diff] [blame] | 115 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | |
Kay Sievers | 5f123fb | 2005-11-11 14:43:07 +0100 | [diff] [blame] | 117 | /* environment values */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | buffer = kmalloc(BUFFER_SIZE, GFP_KERNEL); |
Aneesh Kumar K.V | 542cfce | 2006-12-19 13:01:27 -0800 | [diff] [blame] | 119 | if (!buffer) { |
| 120 | retval = -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | goto exit; |
Aneesh Kumar K.V | 542cfce | 2006-12-19 13:01:27 -0800 | [diff] [blame] | 122 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | |
Kay Sievers | 5f123fb | 2005-11-11 14:43:07 +0100 | [diff] [blame] | 124 | /* complete object path */ |
| 125 | devpath = kobject_get_path(kobj, GFP_KERNEL); |
Aneesh Kumar K.V | 542cfce | 2006-12-19 13:01:27 -0800 | [diff] [blame] | 126 | if (!devpath) { |
| 127 | retval = -ENOENT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | goto exit; |
Aneesh Kumar K.V | 542cfce | 2006-12-19 13:01:27 -0800 | [diff] [blame] | 129 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | |
Kay Sievers | 5f123fb | 2005-11-11 14:43:07 +0100 | [diff] [blame] | 131 | /* event environemnt for helper process only */ |
| 132 | envp[i++] = "HOME=/"; |
| 133 | envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | |
Kay Sievers | 5f123fb | 2005-11-11 14:43:07 +0100 | [diff] [blame] | 135 | /* default keys */ |
| 136 | scratch = buffer; |
| 137 | envp [i++] = scratch; |
| 138 | scratch += sprintf(scratch, "ACTION=%s", action_string) + 1; |
| 139 | envp [i++] = scratch; |
| 140 | scratch += sprintf (scratch, "DEVPATH=%s", devpath) + 1; |
| 141 | envp [i++] = scratch; |
| 142 | scratch += sprintf(scratch, "SUBSYSTEM=%s", subsystem) + 1; |
Cornelia Huck | 8a82472 | 2006-11-20 17:07:51 +0100 | [diff] [blame] | 143 | for (j = 0; envp_ext && envp_ext[j]; j++) |
| 144 | envp[i++] = envp_ext[j]; |
Kay Sievers | 5f123fb | 2005-11-11 14:43:07 +0100 | [diff] [blame] | 145 | /* just reserve the space, overwrite it after kset call has returned */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | envp[i++] = seq_buff = scratch; |
| 147 | scratch += strlen("SEQNUM=18446744073709551616") + 1; |
| 148 | |
Kay Sievers | 5f123fb | 2005-11-11 14:43:07 +0100 | [diff] [blame] | 149 | /* let the kset specific function add its stuff */ |
Kay Sievers | 312c004 | 2005-11-16 09:00:00 +0100 | [diff] [blame] | 150 | if (uevent_ops && uevent_ops->uevent) { |
| 151 | retval = uevent_ops->uevent(kset, kobj, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | &envp[i], NUM_ENVP - i, scratch, |
| 153 | BUFFER_SIZE - (scratch - buffer)); |
| 154 | if (retval) { |
Kay Sievers | 312c004 | 2005-11-16 09:00:00 +0100 | [diff] [blame] | 155 | pr_debug ("%s - uevent() returned %d\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | __FUNCTION__, retval); |
| 157 | goto exit; |
| 158 | } |
| 159 | } |
| 160 | |
Kay Sievers | 5f123fb | 2005-11-11 14:43:07 +0100 | [diff] [blame] | 161 | /* we will send an event, request a new sequence number */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | spin_lock(&sequence_lock); |
Kay Sievers | 312c004 | 2005-11-16 09:00:00 +0100 | [diff] [blame] | 163 | seq = ++uevent_seqnum; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | spin_unlock(&sequence_lock); |
| 165 | sprintf(seq_buff, "SEQNUM=%llu", (unsigned long long)seq); |
| 166 | |
Kay Sievers | 4d17ffd | 2006-04-25 15:37:26 +0200 | [diff] [blame] | 167 | #if defined(CONFIG_NET) |
Kay Sievers | 5f123fb | 2005-11-11 14:43:07 +0100 | [diff] [blame] | 168 | /* send netlink message */ |
| 169 | if (uevent_sock) { |
| 170 | struct sk_buff *skb; |
| 171 | size_t len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | |
Kay Sievers | 5f123fb | 2005-11-11 14:43:07 +0100 | [diff] [blame] | 173 | /* allocate message with the maximum possible size */ |
| 174 | len = strlen(action_string) + strlen(devpath) + 2; |
| 175 | skb = alloc_skb(len + BUFFER_SIZE, GFP_KERNEL); |
| 176 | if (skb) { |
| 177 | /* add header */ |
| 178 | scratch = skb_put(skb, len); |
| 179 | sprintf(scratch, "%s@%s", action_string, devpath); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | |
Kay Sievers | 5f123fb | 2005-11-11 14:43:07 +0100 | [diff] [blame] | 181 | /* copy keys to our continuous event payload buffer */ |
| 182 | for (i = 2; envp[i]; i++) { |
| 183 | len = strlen(envp[i]) + 1; |
| 184 | scratch = skb_put(skb, len); |
| 185 | strcpy(scratch, envp[i]); |
| 186 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | |
Kay Sievers | 5f123fb | 2005-11-11 14:43:07 +0100 | [diff] [blame] | 188 | NETLINK_CB(skb).dst_group = 1; |
| 189 | netlink_broadcast(uevent_sock, skb, 0, 1, GFP_KERNEL); |
| 190 | } |
| 191 | } |
Kay Sievers | 4d17ffd | 2006-04-25 15:37:26 +0200 | [diff] [blame] | 192 | #endif |
Kay Sievers | 5f123fb | 2005-11-11 14:43:07 +0100 | [diff] [blame] | 193 | |
| 194 | /* call uevent_helper, usually only enabled during early boot */ |
Kay Sievers | 312c004 | 2005-11-16 09:00:00 +0100 | [diff] [blame] | 195 | if (uevent_helper[0]) { |
Kay Sievers | 5f123fb | 2005-11-11 14:43:07 +0100 | [diff] [blame] | 196 | char *argv [3]; |
| 197 | |
Kay Sievers | 312c004 | 2005-11-16 09:00:00 +0100 | [diff] [blame] | 198 | argv [0] = uevent_helper; |
Kay Sievers | 5f123fb | 2005-11-11 14:43:07 +0100 | [diff] [blame] | 199 | argv [1] = (char *)subsystem; |
| 200 | argv [2] = NULL; |
Jeremy Fitzhardinge | 86313c4 | 2007-07-17 18:37:03 -0700 | [diff] [blame] | 201 | call_usermodehelper (argv[0], argv, envp, UMH_WAIT_EXEC); |
Kay Sievers | 5f123fb | 2005-11-11 14:43:07 +0100 | [diff] [blame] | 202 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | |
| 204 | exit: |
Kay Sievers | 5f123fb | 2005-11-11 14:43:07 +0100 | [diff] [blame] | 205 | kfree(devpath); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | kfree(buffer); |
| 207 | kfree(envp); |
Aneesh Kumar K.V | 542cfce | 2006-12-19 13:01:27 -0800 | [diff] [blame] | 208 | return retval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | } |
Cornelia Huck | 8a82472 | 2006-11-20 17:07:51 +0100 | [diff] [blame] | 210 | |
| 211 | EXPORT_SYMBOL_GPL(kobject_uevent_env); |
| 212 | |
| 213 | /** |
| 214 | * kobject_uevent - notify userspace by ending an uevent |
| 215 | * |
| 216 | * @action: action that is happening (usually KOBJ_ADD and KOBJ_REMOVE) |
| 217 | * @kobj: struct kobject that the action is happening to |
Aneesh Kumar K.V | 542cfce | 2006-12-19 13:01:27 -0800 | [diff] [blame] | 218 | * |
| 219 | * Returns 0 if kobject_uevent() is completed with success or the |
| 220 | * corresponding error when it fails. |
Cornelia Huck | 8a82472 | 2006-11-20 17:07:51 +0100 | [diff] [blame] | 221 | */ |
Aneesh Kumar K.V | 542cfce | 2006-12-19 13:01:27 -0800 | [diff] [blame] | 222 | int kobject_uevent(struct kobject *kobj, enum kobject_action action) |
Cornelia Huck | 8a82472 | 2006-11-20 17:07:51 +0100 | [diff] [blame] | 223 | { |
Aneesh Kumar K.V | 542cfce | 2006-12-19 13:01:27 -0800 | [diff] [blame] | 224 | return kobject_uevent_env(kobj, action, NULL); |
Cornelia Huck | 8a82472 | 2006-11-20 17:07:51 +0100 | [diff] [blame] | 225 | } |
| 226 | |
Kay Sievers | 312c004 | 2005-11-16 09:00:00 +0100 | [diff] [blame] | 227 | EXPORT_SYMBOL_GPL(kobject_uevent); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | |
| 229 | /** |
Kay Sievers | 312c004 | 2005-11-16 09:00:00 +0100 | [diff] [blame] | 230 | * add_uevent_var - helper for creating event variables |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | * @envp: Pointer to table of environment variables, as passed into |
Kay Sievers | 312c004 | 2005-11-16 09:00:00 +0100 | [diff] [blame] | 232 | * uevent() method. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | * @num_envp: Number of environment variable slots available, as |
Kay Sievers | 312c004 | 2005-11-16 09:00:00 +0100 | [diff] [blame] | 234 | * passed into uevent() method. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | * @cur_index: Pointer to current index into @envp. It should be |
Kay Sievers | 312c004 | 2005-11-16 09:00:00 +0100 | [diff] [blame] | 236 | * initialized to 0 before the first call to add_uevent_var(), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | * and will be incremented on success. |
| 238 | * @buffer: Pointer to buffer for environment variables, as passed |
Kay Sievers | 312c004 | 2005-11-16 09:00:00 +0100 | [diff] [blame] | 239 | * into uevent() method. |
| 240 | * @buffer_size: Length of @buffer, as passed into uevent() method. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | * @cur_len: Pointer to current length of space used in @buffer. |
| 242 | * Should be initialized to 0 before the first call to |
Kay Sievers | 312c004 | 2005-11-16 09:00:00 +0100 | [diff] [blame] | 243 | * add_uevent_var(), and will be incremented on success. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | * @format: Format for creating environment variable (of the form |
| 245 | * "XXX=%x") for snprintf(). |
| 246 | * |
| 247 | * Returns 0 if environment variable was added successfully or -ENOMEM |
| 248 | * if no space was available. |
| 249 | */ |
Kay Sievers | 312c004 | 2005-11-16 09:00:00 +0100 | [diff] [blame] | 250 | int add_uevent_var(char **envp, int num_envp, int *cur_index, |
| 251 | char *buffer, int buffer_size, int *cur_len, |
| 252 | const char *format, ...) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | { |
| 254 | va_list args; |
| 255 | |
| 256 | /* |
| 257 | * We check against num_envp - 1 to make sure there is at |
Kay Sievers | 312c004 | 2005-11-16 09:00:00 +0100 | [diff] [blame] | 258 | * least one slot left after we return, since kobject_uevent() |
| 259 | * needs to set the last slot to NULL. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | */ |
| 261 | if (*cur_index >= num_envp - 1) |
| 262 | return -ENOMEM; |
| 263 | |
| 264 | envp[*cur_index] = buffer + *cur_len; |
| 265 | |
| 266 | va_start(args, format); |
| 267 | *cur_len += vsnprintf(envp[*cur_index], |
| 268 | max(buffer_size - *cur_len, 0), |
| 269 | format, args) + 1; |
| 270 | va_end(args); |
| 271 | |
| 272 | if (*cur_len > buffer_size) |
| 273 | return -ENOMEM; |
| 274 | |
| 275 | (*cur_index)++; |
| 276 | return 0; |
| 277 | } |
Kay Sievers | 312c004 | 2005-11-16 09:00:00 +0100 | [diff] [blame] | 278 | EXPORT_SYMBOL_GPL(add_uevent_var); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | |
Kay Sievers | 4d17ffd | 2006-04-25 15:37:26 +0200 | [diff] [blame] | 280 | #if defined(CONFIG_NET) |
Kay Sievers | 5f123fb | 2005-11-11 14:43:07 +0100 | [diff] [blame] | 281 | static int __init kobject_uevent_init(void) |
| 282 | { |
Eric W. Biederman | b4b5102 | 2007-09-12 13:05:38 +0200 | [diff] [blame] | 283 | uevent_sock = netlink_kernel_create(&init_net, NETLINK_KOBJECT_UEVENT, |
| 284 | 1, NULL, NULL, THIS_MODULE); |
Kay Sievers | 5f123fb | 2005-11-11 14:43:07 +0100 | [diff] [blame] | 285 | if (!uevent_sock) { |
| 286 | printk(KERN_ERR |
| 287 | "kobject_uevent: unable to create netlink socket!\n"); |
| 288 | return -ENODEV; |
| 289 | } |
| 290 | |
| 291 | return 0; |
| 292 | } |
| 293 | |
| 294 | postcore_initcall(kobject_uevent_init); |
Kay Sievers | 4d17ffd | 2006-04-25 15:37:26 +0200 | [diff] [blame] | 295 | #endif |
Kay Sievers | 5f123fb | 2005-11-11 14:43:07 +0100 | [diff] [blame] | 296 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | #endif /* CONFIG_HOTPLUG */ |