aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-09-26 14:49:46 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-09-26 14:49:46 -0400
commitdd77a4ee0f3981693d4229aa1d57cea9e526ff47 (patch)
treecb486be20b950201103a03636cbb1e1d180f0098 /fs
parente8216dee838c09776680a6f1a2e54d81f3cdfa14 (diff)
parent7e9f4b2d3e21e87c26025810413ef1592834e63b (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6: (47 commits) Driver core: Don't call put methods while holding a spinlock Driver core: Remove unneeded routines from driver core Driver core: Fix potential deadlock in driver core PCI: enable driver multi-threaded probe Driver Core: add ability for drivers to do a threaded probe sysfs: add proper sysfs_init() prototype drivers/base: check errors drivers/base: Platform notify needs to occur before drivers attach to the device v4l-dev2: handle __must_check add CONFIG_ENABLE_MUST_CHECK add __must_check to device management code Driver core: fixed add_bind_files() definition Driver core: fix comments in drivers/base/power/resume.c sysfs_remove_bin_file: no return value, dump_stack on error kobject: must_check fixes Driver core: add ability for devices to create and remove bin files Class: add support for class interfaces for devices Driver core: create devices/virtual/ tree Driver core: add device_rename function Driver core: add ability for classes to handle devices properly ...
Diffstat (limited to 'fs')
-rw-r--r--fs/debugfs/file.c56
-rw-r--r--fs/debugfs/inode.c15
-rw-r--r--fs/namespace.c10
-rw-r--r--fs/sysfs/bin.c13
-rw-r--r--fs/sysfs/dir.c2
-rw-r--r--fs/sysfs/inode.c11
-rw-r--r--fs/sysfs/symlink.c14
-rw-r--r--fs/sysfs/sysfs.h2
8 files changed, 62 insertions, 61 deletions
diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index 39640fd03458..e4b430552c88 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -55,12 +55,11 @@ static u64 debugfs_u8_get(void *data)
55DEFINE_SIMPLE_ATTRIBUTE(fops_u8, debugfs_u8_get, debugfs_u8_set, "%llu\n"); 55DEFINE_SIMPLE_ATTRIBUTE(fops_u8, debugfs_u8_get, debugfs_u8_set, "%llu\n");
56 56
57/** 57/**
58 * debugfs_create_u8 - create a file in the debugfs filesystem that is used to read and write an unsigned 8 bit value. 58 * debugfs_create_u8 - create a debugfs file that is used to read and write an unsigned 8-bit value
59 *
60 * @name: a pointer to a string containing the name of the file to create. 59 * @name: a pointer to a string containing the name of the file to create.
61 * @mode: the permission that the file should have 60 * @mode: the permission that the file should have
62 * @parent: a pointer to the parent dentry for this file. This should be a 61 * @parent: a pointer to the parent dentry for this file. This should be a
63 * directory dentry if set. If this paramater is NULL, then the 62 * directory dentry if set. If this parameter is %NULL, then the
64 * file will be created in the root of the debugfs filesystem. 63 * file will be created in the root of the debugfs filesystem.
65 * @value: a pointer to the variable that the file should read to and write 64 * @value: a pointer to the variable that the file should read to and write
66 * from. 65 * from.
@@ -72,11 +71,11 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_u8, debugfs_u8_get, debugfs_u8_set, "%llu\n");
72 * This function will return a pointer to a dentry if it succeeds. This 71 * This function will return a pointer to a dentry if it succeeds. This
73 * pointer must be passed to the debugfs_remove() function when the file is 72 * pointer must be passed to the debugfs_remove() function when the file is
74 * to be removed (no automatic cleanup happens if your module is unloaded, 73 * to be removed (no automatic cleanup happens if your module is unloaded,
75 * you are responsible here.) If an error occurs, NULL will be returned. 74 * you are responsible here.) If an error occurs, %NULL will be returned.
76 * 75 *
77 * If debugfs is not enabled in the kernel, the value -ENODEV will be 76 * If debugfs is not enabled in the kernel, the value -%ENODEV will be
78 * returned. It is not wise to check for this value, but rather, check for 77 * returned. It is not wise to check for this value, but rather, check for
79 * NULL or !NULL instead as to eliminate the need for #ifdef in the calling 78 * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling
80 * code. 79 * code.
81 */ 80 */
82struct dentry *debugfs_create_u8(const char *name, mode_t mode, 81struct dentry *debugfs_create_u8(const char *name, mode_t mode,
@@ -97,12 +96,11 @@ static u64 debugfs_u16_get(void *data)
97DEFINE_SIMPLE_ATTRIBUTE(fops_u16, debugfs_u16_get, debugfs_u16_set, "%llu\n"); 96DEFINE_SIMPLE_ATTRIBUTE(fops_u16, debugfs_u16_get, debugfs_u16_set, "%llu\n");
98 97
99/** 98/**
100 * debugfs_create_u16 - create a file in the debugfs filesystem that is used to read and write an unsigned 16 bit value. 99 * debugfs_create_u16 - create a debugfs file that is used to read and write an unsigned 16-bit value
101 *
102 * @name: a pointer to a string containing the name of the file to create. 100 * @name: a pointer to a string containing the name of the file to create.
103 * @mode: the permission that the file should have 101 * @mode: the permission that the file should have
104 * @parent: a pointer to the parent dentry for this file. This should be a 102 * @parent: a pointer to the parent dentry for this file. This should be a
105 * directory dentry if set. If this paramater is NULL, then the 103 * directory dentry if set. If this parameter is %NULL, then the
106 * file will be created in the root of the debugfs filesystem. 104 * file will be created in the root of the debugfs filesystem.
107 * @value: a pointer to the variable that the file should read to and write 105 * @value: a pointer to the variable that the file should read to and write
108 * from. 106 * from.
@@ -114,11 +112,11 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_u16, debugfs_u16_get, debugfs_u16_set, "%llu\n");
114 * This function will return a pointer to a dentry if it succeeds. This 112 * This function will return a pointer to a dentry if it succeeds. This
115 * pointer must be passed to the debugfs_remove() function when the file is 113 * pointer must be passed to the debugfs_remove() function when the file is
116 * to be removed (no automatic cleanup happens if your module is unloaded, 114 * to be removed (no automatic cleanup happens if your module is unloaded,
117 * you are responsible here.) If an error occurs, NULL will be returned. 115 * you are responsible here.) If an error occurs, %NULL will be returned.
118 * 116 *
119 * If debugfs is not enabled in the kernel, the value -ENODEV will be 117 * If debugfs is not enabled in the kernel, the value -%ENODEV will be
120 * returned. It is not wise to check for this value, but rather, check for 118 * returned. It is not wise to check for this value, but rather, check for
121 * NULL or !NULL instead as to eliminate the need for #ifdef in the calling 119 * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling
122 * code. 120 * code.
123 */ 121 */
124struct dentry *debugfs_create_u16(const char *name, mode_t mode, 122struct dentry *debugfs_create_u16(const char *name, mode_t mode,
@@ -139,12 +137,11 @@ static u64 debugfs_u32_get(void *data)
139DEFINE_SIMPLE_ATTRIBUTE(fops_u32, debugfs_u32_get, debugfs_u32_set, "%llu\n"); 137DEFINE_SIMPLE_ATTRIBUTE(fops_u32, debugfs_u32_get, debugfs_u32_set, "%llu\n");
140 138
141/** 139/**
142 * debugfs_create_u32 - create a file in the debugfs filesystem that is used to read and write an unsigned 32 bit value. 140 * debugfs_create_u32 - create a debugfs file that is used to read and write an unsigned 32-bit value
143 *
144 * @name: a pointer to a string containing the name of the file to create. 141 * @name: a pointer to a string containing the name of the file to create.
145 * @mode: the permission that the file should have 142 * @mode: the permission that the file should have
146 * @parent: a pointer to the parent dentry for this file. This should be a 143 * @parent: a pointer to the parent dentry for this file. This should be a
147 * directory dentry if set. If this paramater is NULL, then the 144 * directory dentry if set. If this parameter is %NULL, then the
148 * file will be created in the root of the debugfs filesystem. 145 * file will be created in the root of the debugfs filesystem.
149 * @value: a pointer to the variable that the file should read to and write 146 * @value: a pointer to the variable that the file should read to and write
150 * from. 147 * from.
@@ -156,11 +153,11 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_u32, debugfs_u32_get, debugfs_u32_set, "%llu\n");
156 * This function will return a pointer to a dentry if it succeeds. This 153 * This function will return a pointer to a dentry if it succeeds. This
157 * pointer must be passed to the debugfs_remove() function when the file is 154 * pointer must be passed to the debugfs_remove() function when the file is
158 * to be removed (no automatic cleanup happens if your module is unloaded, 155 * to be removed (no automatic cleanup happens if your module is unloaded,
159 * you are responsible here.) If an error occurs, NULL will be returned. 156 * you are responsible here.) If an error occurs, %NULL will be returned.
160 * 157 *
161 * If debugfs is not enabled in the kernel, the value -ENODEV will be 158 * If debugfs is not enabled in the kernel, the value -%ENODEV will be
162 * returned. It is not wise to check for this value, but rather, check for 159 * returned. It is not wise to check for this value, but rather, check for
163 * NULL or !NULL instead as to eliminate the need for #ifdef in the calling 160 * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling
164 * code. 161 * code.
165 */ 162 */
166struct dentry *debugfs_create_u32(const char *name, mode_t mode, 163struct dentry *debugfs_create_u32(const char *name, mode_t mode,
@@ -219,12 +216,11 @@ static const struct file_operations fops_bool = {
219}; 216};
220 217
221/** 218/**
222 * debugfs_create_bool - create a file in the debugfs filesystem that is used to read and write a boolean value. 219 * debugfs_create_bool - create a debugfs file that is used to read and write a boolean value
223 *
224 * @name: a pointer to a string containing the name of the file to create. 220 * @name: a pointer to a string containing the name of the file to create.
225 * @mode: the permission that the file should have 221 * @mode: the permission that the file should have
226 * @parent: a pointer to the parent dentry for this file. This should be a 222 * @parent: a pointer to the parent dentry for this file. This should be a
227 * directory dentry if set. If this paramater is NULL, then the 223 * directory dentry if set. If this parameter is %NULL, then the
228 * file will be created in the root of the debugfs filesystem. 224 * file will be created in the root of the debugfs filesystem.
229 * @value: a pointer to the variable that the file should read to and write 225 * @value: a pointer to the variable that the file should read to and write
230 * from. 226 * from.
@@ -236,11 +232,11 @@ static const struct file_operations fops_bool = {
236 * This function will return a pointer to a dentry if it succeeds. This 232 * This function will return a pointer to a dentry if it succeeds. This
237 * pointer must be passed to the debugfs_remove() function when the file is 233 * pointer must be passed to the debugfs_remove() function when the file is
238 * to be removed (no automatic cleanup happens if your module is unloaded, 234 * to be removed (no automatic cleanup happens if your module is unloaded,
239 * you are responsible here.) If an error occurs, NULL will be returned. 235 * you are responsible here.) If an error occurs, %NULL will be returned.
240 * 236 *
241 * If debugfs is not enabled in the kernel, the value -ENODEV will be 237 * If debugfs is not enabled in the kernel, the value -%ENODEV will be
242 * returned. It is not wise to check for this value, but rather, check for 238 * returned. It is not wise to check for this value, but rather, check for
243 * NULL or !NULL instead as to eliminate the need for #ifdef in the calling 239 * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling
244 * code. 240 * code.
245 */ 241 */
246struct dentry *debugfs_create_bool(const char *name, mode_t mode, 242struct dentry *debugfs_create_bool(const char *name, mode_t mode,
@@ -264,13 +260,11 @@ static struct file_operations fops_blob = {
264}; 260};
265 261
266/** 262/**
267 * debugfs_create_blob - create a file in the debugfs filesystem that is 263 * debugfs_create_blob - create a debugfs file that is used to read and write a binary blob
268 * used to read and write a binary blob.
269 *
270 * @name: a pointer to a string containing the name of the file to create. 264 * @name: a pointer to a string containing the name of the file to create.
271 * @mode: the permission that the file should have 265 * @mode: the permission that the file should have
272 * @parent: a pointer to the parent dentry for this file. This should be a 266 * @parent: a pointer to the parent dentry for this file. This should be a
273 * directory dentry if set. If this paramater is NULL, then the 267 * directory dentry if set. If this parameter is %NULL, then the
274 * file will be created in the root of the debugfs filesystem. 268 * file will be created in the root of the debugfs filesystem.
275 * @blob: a pointer to a struct debugfs_blob_wrapper which contains a pointer 269 * @blob: a pointer to a struct debugfs_blob_wrapper which contains a pointer
276 * to the blob data and the size of the data. 270 * to the blob data and the size of the data.
@@ -282,11 +276,11 @@ static struct file_operations fops_blob = {
282 * This function will return a pointer to a dentry if it succeeds. This 276 * This function will return a pointer to a dentry if it succeeds. This
283 * pointer must be passed to the debugfs_remove() function when the file is 277 * pointer must be passed to the debugfs_remove() function when the file is
284 * to be removed (no automatic cleanup happens if your module is unloaded, 278 * to be removed (no automatic cleanup happens if your module is unloaded,
285 * you are responsible here.) If an error occurs, NULL will be returned. 279 * you are responsible here.) If an error occurs, %NULL will be returned.
286 * 280 *
287 * If debugfs is not enabled in the kernel, the value -ENODEV will be 281 * If debugfs is not enabled in the kernel, the value -%ENODEV will be
288 * returned. It is not wise to check for this value, but rather, check for 282 * returned. It is not wise to check for this value, but rather, check for
289 * NULL or !NULL instead as to eliminate the need for #ifdef in the calling 283 * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling
290 * code. 284 * code.
291 */ 285 */
292struct dentry *debugfs_create_blob(const char *name, mode_t mode, 286struct dentry *debugfs_create_blob(const char *name, mode_t mode,
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index e8ae3042b806..3ca268d2e5a2 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -162,7 +162,6 @@ static int debugfs_create_by_name(const char *name, mode_t mode,
162 162
163/** 163/**
164 * debugfs_create_file - create a file in the debugfs filesystem 164 * debugfs_create_file - create a file in the debugfs filesystem
165 *
166 * @name: a pointer to a string containing the name of the file to create. 165 * @name: a pointer to a string containing the name of the file to create.
167 * @mode: the permission that the file should have 166 * @mode: the permission that the file should have
168 * @parent: a pointer to the parent dentry for this file. This should be a 167 * @parent: a pointer to the parent dentry for this file. This should be a
@@ -182,11 +181,11 @@ static int debugfs_create_by_name(const char *name, mode_t mode,
182 * This function will return a pointer to a dentry if it succeeds. This 181 * This function will return a pointer to a dentry if it succeeds. This
183 * pointer must be passed to the debugfs_remove() function when the file is 182 * pointer must be passed to the debugfs_remove() function when the file is
184 * to be removed (no automatic cleanup happens if your module is unloaded, 183 * to be removed (no automatic cleanup happens if your module is unloaded,
185 * you are responsible here.) If an error occurs, NULL will be returned. 184 * you are responsible here.) If an error occurs, %NULL will be returned.
186 * 185 *
187 * If debugfs is not enabled in the kernel, the value -ENODEV will be 186 * If debugfs is not enabled in the kernel, the value -%ENODEV will be
188 * returned. It is not wise to check for this value, but rather, check for 187 * returned. It is not wise to check for this value, but rather, check for
189 * NULL or !NULL instead as to eliminate the need for #ifdef in the calling 188 * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling
190 * code. 189 * code.
191 */ 190 */
192struct dentry *debugfs_create_file(const char *name, mode_t mode, 191struct dentry *debugfs_create_file(const char *name, mode_t mode,
@@ -221,7 +220,6 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
221 220
222/** 221/**
223 * debugfs_create_dir - create a directory in the debugfs filesystem 222 * debugfs_create_dir - create a directory in the debugfs filesystem
224 *
225 * @name: a pointer to a string containing the name of the directory to 223 * @name: a pointer to a string containing the name of the directory to
226 * create. 224 * create.
227 * @parent: a pointer to the parent dentry for this file. This should be a 225 * @parent: a pointer to the parent dentry for this file. This should be a
@@ -233,11 +231,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
233 * This function will return a pointer to a dentry if it succeeds. This 231 * This function will return a pointer to a dentry if it succeeds. This
234 * pointer must be passed to the debugfs_remove() function when the file is 232 * pointer must be passed to the debugfs_remove() function when the file is
235 * to be removed (no automatic cleanup happens if your module is unloaded, 233 * to be removed (no automatic cleanup happens if your module is unloaded,
236 * you are responsible here.) If an error occurs, NULL will be returned. 234 * you are responsible here.) If an error occurs, %NULL will be returned.
237 * 235 *
238 * If debugfs is not enabled in the kernel, the value -ENODEV will be 236 * If debugfs is not enabled in the kernel, the value -%ENODEV will be
239 * returned. It is not wise to check for this value, but rather, check for 237 * returned. It is not wise to check for this value, but rather, check for
240 * NULL or !NULL instead as to eliminate the need for #ifdef in the calling 238 * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling
241 * code. 239 * code.
242 */ 240 */
243struct dentry *debugfs_create_dir(const char *name, struct dentry *parent) 241struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
@@ -250,7 +248,6 @@ EXPORT_SYMBOL_GPL(debugfs_create_dir);
250 248
251/** 249/**
252 * debugfs_remove - removes a file or directory from the debugfs filesystem 250 * debugfs_remove - removes a file or directory from the debugfs filesystem
253 *
254 * @dentry: a pointer to a the dentry of the file or directory to be 251 * @dentry: a pointer to a the dentry of the file or directory to be
255 * removed. 252 * removed.
256 * 253 *
diff --git a/fs/namespace.c b/fs/namespace.c
index fa7ed6a9fc2d..36d180858136 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -17,6 +17,7 @@
17#include <linux/acct.h> 17#include <linux/acct.h>
18#include <linux/capability.h> 18#include <linux/capability.h>
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/sysfs.h>
20#include <linux/seq_file.h> 21#include <linux/seq_file.h>
21#include <linux/namespace.h> 22#include <linux/namespace.h>
22#include <linux/namei.h> 23#include <linux/namei.h>
@@ -28,15 +29,6 @@
28 29
29extern int __init init_rootfs(void); 30extern int __init init_rootfs(void);
30 31
31#ifdef CONFIG_SYSFS
32extern int __init sysfs_init(void);
33#else
34static inline int sysfs_init(void)
35{
36 return 0;
37}
38#endif
39
40/* spinlock for vfsmount related operations, inplace of dcache_lock */ 32/* spinlock for vfsmount related operations, inplace of dcache_lock */
41__cacheline_aligned_in_smp DEFINE_SPINLOCK(vfsmount_lock); 33__cacheline_aligned_in_smp DEFINE_SPINLOCK(vfsmount_lock);
42 34
diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
index c16a93c353c0..98022e41cda1 100644
--- a/fs/sysfs/bin.c
+++ b/fs/sysfs/bin.c
@@ -10,6 +10,7 @@
10 10
11#include <linux/errno.h> 11#include <linux/errno.h>
12#include <linux/fs.h> 12#include <linux/fs.h>
13#include <linux/kernel.h>
13#include <linux/kobject.h> 14#include <linux/kobject.h>
14#include <linux/module.h> 15#include <linux/module.h>
15#include <linux/slab.h> 16#include <linux/slab.h>
@@ -176,7 +177,6 @@ const struct file_operations bin_fops = {
176 * sysfs_create_bin_file - create binary file for object. 177 * sysfs_create_bin_file - create binary file for object.
177 * @kobj: object. 178 * @kobj: object.
178 * @attr: attribute descriptor. 179 * @attr: attribute descriptor.
179 *
180 */ 180 */
181 181
182int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr) 182int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr)
@@ -191,13 +191,16 @@ int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr)
191 * sysfs_remove_bin_file - remove binary file for object. 191 * sysfs_remove_bin_file - remove binary file for object.
192 * @kobj: object. 192 * @kobj: object.
193 * @attr: attribute descriptor. 193 * @attr: attribute descriptor.
194 *
195 */ 194 */
196 195
197int sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr) 196void sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr)
198{ 197{
199 sysfs_hash_and_remove(kobj->dentry,attr->attr.name); 198 if (sysfs_hash_and_remove(kobj->dentry, attr->attr.name) < 0) {
200 return 0; 199 printk(KERN_ERR "%s: "
200 "bad dentry or inode or no such file: \"%s\"\n",
201 __FUNCTION__, attr->attr.name);
202 dump_stack();
203 }
201} 204}
202 205
203EXPORT_SYMBOL_GPL(sysfs_create_bin_file); 206EXPORT_SYMBOL_GPL(sysfs_create_bin_file);
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 61c42430cba3..5f3d725d1125 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -43,7 +43,7 @@ static struct sysfs_dirent * sysfs_new_dirent(struct sysfs_dirent * parent_sd,
43 43
44 memset(sd, 0, sizeof(*sd)); 44 memset(sd, 0, sizeof(*sd));
45 atomic_set(&sd->s_count, 1); 45 atomic_set(&sd->s_count, 1);
46 atomic_set(&sd->s_event, 0); 46 atomic_set(&sd->s_event, 1);
47 INIT_LIST_HEAD(&sd->s_children); 47 INIT_LIST_HEAD(&sd->s_children);
48 list_add(&sd->s_sibling, &parent_sd->s_children); 48 list_add(&sd->s_sibling, &parent_sd->s_children);
49 sd->s_element = element; 49 sd->s_element = element;
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index 9889e54e1f13..fd7cd5f843d2 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -12,6 +12,7 @@
12#include <linux/namei.h> 12#include <linux/namei.h>
13#include <linux/backing-dev.h> 13#include <linux/backing-dev.h>
14#include <linux/capability.h> 14#include <linux/capability.h>
15#include <linux/errno.h>
15#include "sysfs.h" 16#include "sysfs.h"
16 17
17extern struct super_block * sysfs_sb; 18extern struct super_block * sysfs_sb;
@@ -234,17 +235,18 @@ void sysfs_drop_dentry(struct sysfs_dirent * sd, struct dentry * parent)
234 } 235 }
235} 236}
236 237
237void sysfs_hash_and_remove(struct dentry * dir, const char * name) 238int sysfs_hash_and_remove(struct dentry * dir, const char * name)
238{ 239{
239 struct sysfs_dirent * sd; 240 struct sysfs_dirent * sd;
240 struct sysfs_dirent * parent_sd; 241 struct sysfs_dirent * parent_sd;
242 int found = 0;
241 243
242 if (!dir) 244 if (!dir)
243 return; 245 return -ENOENT;
244 246
245 if (dir->d_inode == NULL) 247 if (dir->d_inode == NULL)
246 /* no inode means this hasn't been made visible yet */ 248 /* no inode means this hasn't been made visible yet */
247 return; 249 return -ENOENT;
248 250
249 parent_sd = dir->d_fsdata; 251 parent_sd = dir->d_fsdata;
250 mutex_lock(&dir->d_inode->i_mutex); 252 mutex_lock(&dir->d_inode->i_mutex);
@@ -255,8 +257,11 @@ void sysfs_hash_and_remove(struct dentry * dir, const char * name)
255 list_del_init(&sd->s_sibling); 257 list_del_init(&sd->s_sibling);
256 sysfs_drop_dentry(sd, dir); 258 sysfs_drop_dentry(sd, dir);
257 sysfs_put(sd); 259 sysfs_put(sd);
260 found = 1;
258 break; 261 break;
259 } 262 }
260 } 263 }
261 mutex_unlock(&dir->d_inode->i_mutex); 264 mutex_unlock(&dir->d_inode->i_mutex);
265
266 return found ? 0 : -ENOENT;
262} 267}
diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
index d2eac3ceed5f..f50e3cc2ded8 100644
--- a/fs/sysfs/symlink.c
+++ b/fs/sysfs/symlink.c
@@ -3,6 +3,7 @@
3 */ 3 */
4 4
5#include <linux/fs.h> 5#include <linux/fs.h>
6#include <linux/mount.h>
6#include <linux/module.h> 7#include <linux/module.h>
7#include <linux/kobject.h> 8#include <linux/kobject.h>
8#include <linux/namei.h> 9#include <linux/namei.h>
@@ -82,10 +83,19 @@ exit1:
82 */ 83 */
83int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char * name) 84int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char * name)
84{ 85{
85 struct dentry * dentry = kobj->dentry; 86 struct dentry *dentry = NULL;
86 int error = -EEXIST; 87 int error = -EEXIST;
87 88
88 BUG_ON(!kobj || !kobj->dentry || !name); 89 BUG_ON(!name);
90
91 if (!kobj) {
92 if (sysfs_mount && sysfs_mount->mnt_sb)
93 dentry = sysfs_mount->mnt_sb->s_root;
94 } else
95 dentry = kobj->dentry;
96
97 if (!dentry)
98 return -EFAULT;
89 99
90 mutex_lock(&dentry->d_inode->i_mutex); 100 mutex_lock(&dentry->d_inode->i_mutex);
91 if (!sysfs_dirent_exist(dentry->d_fsdata, name)) 101 if (!sysfs_dirent_exist(dentry->d_fsdata, name))
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index 3651ffb5ec09..6f3d6bd52887 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -10,7 +10,7 @@ extern int sysfs_make_dirent(struct sysfs_dirent *, struct dentry *, void *,
10 umode_t, int); 10 umode_t, int);
11 11
12extern int sysfs_add_file(struct dentry *, const struct attribute *, int); 12extern int sysfs_add_file(struct dentry *, const struct attribute *, int);
13extern void sysfs_hash_and_remove(struct dentry * dir, const char * name); 13extern int sysfs_hash_and_remove(struct dentry * dir, const char * name);
14extern struct sysfs_dirent *sysfs_find(struct sysfs_dirent *dir, const char * name); 14extern struct sysfs_dirent *sysfs_find(struct sysfs_dirent *dir, const char * name);
15 15
16extern int sysfs_create_subdir(struct kobject *, const char *, struct dentry **); 16extern int sysfs_create_subdir(struct kobject *, const char *, struct dentry **);