fs/sysfs/bin.c | 6 ++++++ fs/sysfs/dir.c | 16 +++++++++++++++- fs/sysfs/file.c | 9 +++++++++ fs/sysfs/group.c | 6 ++++++ fs/sysfs/inode.c | 18 ++++++++++++++++-- fs/sysfs/symlink.c | 3 +++ fs/sysfs/sysfs.h | 2 ++ include/linux/sysfs.h | 2 ++ lib/kobject.c | 7 +++++-- 9 files changed, 64 insertions(+), 5 deletions(-) diff -puN fs/sysfs/inode.c~nosysfs fs/sysfs/inode.c --- 25/fs/sysfs/inode.c~nosysfs 2003-10-21 18:00:24.000000000 -0700 +++ 25-akpm/fs/sysfs/inode.c 2003-10-21 18:00:24.000000000 -0700 @@ -11,7 +11,8 @@ #include #include #include -extern struct super_block * sysfs_sb; +#include +#include "sysfs.h" static struct address_space_operations sysfs_aops = { .readpage = simple_readpage, @@ -24,6 +25,8 @@ static struct backing_dev_info sysfs_bac .memory_backed = 1, /* Does not contribute to dirty memory */ }; +int nosysfs; + struct inode * sysfs_new_inode(mode_t mode) { struct inode * inode = new_inode(sysfs_sb); @@ -44,6 +47,10 @@ int sysfs_create(struct dentry * dentry, { int error = 0; struct inode * inode = NULL; + + if (nosysfs) + return 0; + if (dentry) { if (!dentry->d_inode) { if ((inode = sysfs_new_inode(mode))) @@ -87,6 +94,8 @@ void sysfs_hash_and_remove(struct dentry { struct dentry * victim; + if (nosysfs) + return; down(&dir->d_inode->i_sem); victim = sysfs_get_dentry(dir,name); if (!IS_ERR(victim)) { @@ -107,4 +116,9 @@ void sysfs_hash_and_remove(struct dentry up(&dir->d_inode->i_sem); } - +static int __init nosysfs_setup(char *str) +{ + nosysfs = 1; + return 1; +} +__setup("nosysfs", nosysfs_setup); diff -puN fs/sysfs/dir.c~nosysfs fs/sysfs/dir.c --- 25/fs/sysfs/dir.c~nosysfs 2003-10-21 18:00:24.000000000 -0700 +++ 25-akpm/fs/sysfs/dir.c 2003-10-21 18:00:24.000000000 -0700 @@ -46,6 +46,8 @@ static int create_dir(struct kobject * k int sysfs_create_subdir(struct kobject * k, const char * n, struct dentry ** d) { + if (nosysfs) + return 0; return create_dir(k,k->dentry,n,d); } @@ -61,6 +63,9 @@ int sysfs_create_dir(struct kobject * ko struct dentry * parent; int error = 0; + if (nosysfs) + return 0; + if (!kobj) return -EINVAL; @@ -102,6 +107,8 @@ static void remove_dir(struct dentry * d void sysfs_remove_subdir(struct dentry * d) { + if (nosysfs) + return; remove_dir(d); } @@ -118,8 +125,12 @@ void sysfs_remove_subdir(struct dentry * void sysfs_remove_dir(struct kobject * kobj) { struct list_head * node; - struct dentry * dentry = dget(kobj->dentry); + struct dentry *dentry; + + if (nosysfs) + return; + dentry = dget(kobj->dentry); if (!dentry) return; @@ -164,6 +175,9 @@ void sysfs_rename_dir(struct kobject * k { struct dentry * new_dentry, * parent; + if (nosysfs) + return; + if (!strcmp(kobject_name(kobj), new_name)) return; diff -puN include/linux/sysfs.h~nosysfs include/linux/sysfs.h --- 25/include/linux/sysfs.h~nosysfs 2003-10-21 18:00:24.000000000 -0700 +++ 25-akpm/include/linux/sysfs.h 2003-10-21 18:02:23.000000000 -0700 @@ -66,4 +66,6 @@ struct attribute_group { int sysfs_create_group(struct kobject *, const struct attribute_group *); void sysfs_remove_group(struct kobject *, const struct attribute_group *); +extern int nosysfs; + #endif /* _SYSFS_H_ */ diff -puN fs/sysfs/sysfs.h~nosysfs fs/sysfs/sysfs.h --- 25/fs/sysfs/sysfs.h~nosysfs 2003-10-21 18:00:24.000000000 -0700 +++ 25-akpm/fs/sysfs/sysfs.h 2003-10-21 18:02:17.000000000 -0700 @@ -1,4 +1,6 @@ +struct super_block; +extern struct super_block *sysfs_sb; extern struct vfsmount * sysfs_mount; extern struct inode * sysfs_new_inode(mode_t mode); diff -puN fs/sysfs/file.c~nosysfs fs/sysfs/file.c --- 25/fs/sysfs/file.c~nosysfs 2003-10-21 18:00:24.000000000 -0700 +++ 25-akpm/fs/sysfs/file.c 2003-10-21 18:00:24.000000000 -0700 @@ -350,6 +350,9 @@ int sysfs_add_file(struct dentry * dir, struct dentry * dentry; int error; + if (nosysfs) + return 0; + down(&dir->d_inode->i_sem); dentry = sysfs_get_dentry(dir,attr->name); if (!IS_ERR(dentry)) { @@ -374,6 +377,9 @@ int sysfs_add_file(struct dentry * dir, int sysfs_create_file(struct kobject * kobj, const struct attribute * attr) { + if (nosysfs) + return 0; + if (kobj && attr) return sysfs_add_file(kobj->dentry,attr); return -EINVAL; @@ -394,6 +400,9 @@ int sysfs_update_file(struct kobject * k struct dentry * victim; int res = -ENOENT; + if (nosysfs) + return 0; + down(&dir->d_inode->i_sem); victim = sysfs_get_dentry(dir, attr->name); if (!IS_ERR(victim)) { diff -puN fs/sysfs/symlink.c~nosysfs fs/sysfs/symlink.c --- 25/fs/sysfs/symlink.c~nosysfs 2003-10-21 18:00:24.000000000 -0700 +++ 25-akpm/fs/sysfs/symlink.c 2003-10-21 18:00:24.000000000 -0700 @@ -79,6 +79,9 @@ int sysfs_create_link(struct kobject * k char * path; char * s; + if (nosysfs) + return 0; + depth = object_depth(kobj); size = object_path_length(target) + depth * 3 - 1; if (size > PATH_MAX) diff -puN fs/sysfs/bin.c~nosysfs fs/sysfs/bin.c --- 25/fs/sysfs/bin.c~nosysfs 2003-10-21 18:00:24.000000000 -0700 +++ 25-akpm/fs/sysfs/bin.c 2003-10-21 18:00:24.000000000 -0700 @@ -152,6 +152,9 @@ int sysfs_create_bin_file(struct kobject struct dentry * parent; int error = 0; + if (nosysfs) + return 0; + if (!kobj || !attr) return -EINVAL; @@ -185,6 +188,9 @@ int sysfs_create_bin_file(struct kobject int sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr) { + if (nosysfs) + return 0; + sysfs_hash_and_remove(kobj->dentry,attr->attr.name); return 0; } diff -puN fs/sysfs/group.c~nosysfs fs/sysfs/group.c --- 25/fs/sysfs/group.c~nosysfs 2003-10-21 18:00:24.000000000 -0700 +++ 25-akpm/fs/sysfs/group.c 2003-10-21 18:00:24.000000000 -0700 @@ -45,6 +45,9 @@ int sysfs_create_group(struct kobject * struct dentry * dir; int error; + if (nosysfs) + return 0; + if (grp->name) { error = sysfs_create_subdir(kobj,grp->name,&dir); if (error) @@ -65,6 +68,9 @@ void sysfs_remove_group(struct kobject * { struct dentry * dir; + if (nosysfs) + return; + if (grp->name) dir = sysfs_get_dentry(kobj->dentry,grp->name); else diff -puN lib/kobject.c~nosysfs lib/kobject.c --- 25/lib/kobject.c~nosysfs 2003-10-21 18:00:34.000000000 -0700 +++ 25-akpm/lib/kobject.c 2003-10-21 18:02:42.000000000 -0700 @@ -16,6 +16,7 @@ #include #include #include +#include /** * populate_dir - populate directory with attributes. @@ -170,8 +171,10 @@ static void kset_hotplug(const char *act memset (kobj_path, 0x00, kobj_path_length); fill_kobj_path (kset, kobj, kobj_path, kobj_path_length); - envp [i++] = scratch; - scratch += sprintf (scratch, "DEVPATH=%s", kobj_path) + 1; + if (!nosysfs) { + envp [i++] = scratch; + scratch += sprintf (scratch, "DEVPATH=%s", kobj_path) + 1; + } if (kset->hotplug_ops->hotplug) { /* have the kset specific function add its stuff */ _