diff options
| author | Steven Whitehouse <swhiteho@redhat.com> | 2006-09-28 08:29:59 -0400 |
|---|---|---|
| committer | Steven Whitehouse <swhiteho@redhat.com> | 2006-09-28 08:29:59 -0400 |
| commit | 185a257f2f73bcd89050ad02da5bedbc28fc43fa (patch) | |
| tree | 5e32586114534ed3f2165614cba3d578f5d87307 /fs/sysfs | |
| parent | 3f1a9aaeffd8d1cbc5ab9776c45cbd66af1c9699 (diff) | |
| parent | a77c64c1a641950626181b4857abb701d8f38ccc (diff) | |
Merge branch 'master' into gfs2
Diffstat (limited to 'fs/sysfs')
| -rw-r--r-- | fs/sysfs/bin.c | 13 | ||||
| -rw-r--r-- | fs/sysfs/dir.c | 2 | ||||
| -rw-r--r-- | fs/sysfs/inode.c | 12 | ||||
| -rw-r--r-- | fs/sysfs/symlink.c | 14 | ||||
| -rw-r--r-- | fs/sysfs/sysfs.h | 2 |
5 files changed, 30 insertions, 13 deletions
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 | ||
| 182 | int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr) | 182 | int 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 | ||
| 197 | int sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr) | 196 | void 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 | ||
| 203 | EXPORT_SYMBOL_GPL(sysfs_create_bin_file); | 206 | EXPORT_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..e79e38d52c00 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 | ||
| 17 | extern struct super_block * sysfs_sb; | 18 | extern struct super_block * sysfs_sb; |
| @@ -124,7 +125,6 @@ struct inode * sysfs_new_inode(mode_t mode, struct sysfs_dirent * sd) | |||
| 124 | { | 125 | { |
| 125 | struct inode * inode = new_inode(sysfs_sb); | 126 | struct inode * inode = new_inode(sysfs_sb); |
| 126 | if (inode) { | 127 | if (inode) { |
| 127 | inode->i_blksize = PAGE_CACHE_SIZE; | ||
| 128 | inode->i_blocks = 0; | 128 | inode->i_blocks = 0; |
| 129 | inode->i_mapping->a_ops = &sysfs_aops; | 129 | inode->i_mapping->a_ops = &sysfs_aops; |
| 130 | inode->i_mapping->backing_dev_info = &sysfs_backing_dev_info; | 130 | inode->i_mapping->backing_dev_info = &sysfs_backing_dev_info; |
| @@ -234,17 +234,18 @@ void sysfs_drop_dentry(struct sysfs_dirent * sd, struct dentry * parent) | |||
| 234 | } | 234 | } |
| 235 | } | 235 | } |
| 236 | 236 | ||
| 237 | void sysfs_hash_and_remove(struct dentry * dir, const char * name) | 237 | int sysfs_hash_and_remove(struct dentry * dir, const char * name) |
| 238 | { | 238 | { |
| 239 | struct sysfs_dirent * sd; | 239 | struct sysfs_dirent * sd; |
| 240 | struct sysfs_dirent * parent_sd; | 240 | struct sysfs_dirent * parent_sd; |
| 241 | int found = 0; | ||
| 241 | 242 | ||
| 242 | if (!dir) | 243 | if (!dir) |
| 243 | return; | 244 | return -ENOENT; |
| 244 | 245 | ||
| 245 | if (dir->d_inode == NULL) | 246 | if (dir->d_inode == NULL) |
| 246 | /* no inode means this hasn't been made visible yet */ | 247 | /* no inode means this hasn't been made visible yet */ |
| 247 | return; | 248 | return -ENOENT; |
| 248 | 249 | ||
| 249 | parent_sd = dir->d_fsdata; | 250 | parent_sd = dir->d_fsdata; |
| 250 | mutex_lock(&dir->d_inode->i_mutex); | 251 | mutex_lock(&dir->d_inode->i_mutex); |
| @@ -255,8 +256,11 @@ void sysfs_hash_and_remove(struct dentry * dir, const char * name) | |||
| 255 | list_del_init(&sd->s_sibling); | 256 | list_del_init(&sd->s_sibling); |
| 256 | sysfs_drop_dentry(sd, dir); | 257 | sysfs_drop_dentry(sd, dir); |
| 257 | sysfs_put(sd); | 258 | sysfs_put(sd); |
| 259 | found = 1; | ||
| 258 | break; | 260 | break; |
| 259 | } | 261 | } |
| 260 | } | 262 | } |
| 261 | mutex_unlock(&dir->d_inode->i_mutex); | 263 | mutex_unlock(&dir->d_inode->i_mutex); |
| 264 | |||
| 265 | return found ? 0 : -ENOENT; | ||
| 262 | } | 266 | } |
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 | */ |
| 83 | int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char * name) | 84 | int 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 | ||
| 12 | extern int sysfs_add_file(struct dentry *, const struct attribute *, int); | 12 | extern int sysfs_add_file(struct dentry *, const struct attribute *, int); |
| 13 | extern void sysfs_hash_and_remove(struct dentry * dir, const char * name); | 13 | extern int sysfs_hash_and_remove(struct dentry * dir, const char * name); |
| 14 | extern struct sysfs_dirent *sysfs_find(struct sysfs_dirent *dir, const char * name); | 14 | extern struct sysfs_dirent *sysfs_find(struct sysfs_dirent *dir, const char * name); |
| 15 | 15 | ||
| 16 | extern int sysfs_create_subdir(struct kobject *, const char *, struct dentry **); | 16 | extern int sysfs_create_subdir(struct kobject *, const char *, struct dentry **); |
