As promised long ago, here is a patch to make sysfs optional. Note that this will result in an un-bootable system if you're booting from a hard drive. However, for *really* embedded systems, it will save a significant amount of memory during runtime. And, it saves 4k from the built kernel image for me. Pat ===== fs/Kconfig 1.39 vs edited ===== --- fs/Kconfig | 24 ++++++++++++++ fs/Makefile | 2 - fs/namespace.c | 8 ++++ include/linux/sysfs.h | 83 +++++++++++++++++++++++++++++++++++++++++++++----- 4 files changed, 108 insertions(+), 9 deletions(-) diff -puN fs/Kconfig~CONFIG_SYSFS fs/Kconfig --- 25/fs/Kconfig~CONFIG_SYSFS 2004-02-09 18:45:59.000000000 -0800 +++ 25-akpm/fs/Kconfig 2004-02-09 18:45:59.000000000 -0800 @@ -780,6 +780,30 @@ config PROC_KCORE bool default y if !ARM +config SYSFS + bool "sysfs file system support" if EMBEDDED + default y + help + The sysfs filesystem is a virtual filesystem that the kernel uses to export + internal kernel objects, their attributes, and their relationships to one + another. + + Users can use sysfs to ascertain useful information about the running kernel, + such as the devices the kernel has discovered on each bus and which driver + each is bound to. sysfs can also be used to tune devices and other kernel + subsystems. + + Some system agents rely on the information in sysfs to operate. /sbin/hotplug + uses device and object attributes in sysfs to assist in delegating policy + decisions, like persistantly naming devices. + + sysfs is currently needed by the block subsystem to mount the root partition. + Therefore, you MUST say Y if you're booting from a hard drive. If you use any + type of hotpluggable device, you'll also need sysfs for /sbin/hotplug support. + + However, designers of embedded systems may want to say N here to conserve + space. + config DEVFS_FS bool "/dev file system support (OBSOLETE)" depends on EXPERIMENTAL diff -puN fs/Makefile~CONFIG_SYSFS fs/Makefile --- 25/fs/Makefile~CONFIG_SYSFS 2004-02-09 18:45:59.000000000 -0800 +++ 25-akpm/fs/Makefile 2004-02-09 18:45:59.000000000 -0800 @@ -39,7 +39,7 @@ obj-$(CONFIG_QUOTACTL) += quota.o obj-$(CONFIG_PROC_FS) += proc/ obj-y += partitions/ -obj-y += sysfs/ +obj-$(CONFIG_SYSFS) += sysfs/ obj-y += devpts/ obj-$(CONFIG_PROFILING) += dcookies.o diff -puN fs/namespace.c~CONFIG_SYSFS fs/namespace.c --- 25/fs/namespace.c~CONFIG_SYSFS 2004-02-09 18:45:59.000000000 -0800 +++ 25-akpm/fs/namespace.c 2004-02-09 18:45:59.000000000 -0800 @@ -24,7 +24,15 @@ #include extern int __init init_rootfs(void); + +#ifdef CONFIG_SYSFS extern int __init sysfs_init(void); +#else +static inline int sysfs_init(void) +{ + return 0; +} +#endif /* spinlock for vfsmount related operations, inplace of dcache_lock */ spinlock_t vfsmount_lock __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED; diff -puN include/linux/sysfs.h~CONFIG_SYSFS include/linux/sysfs.h --- 25/include/linux/sysfs.h~CONFIG_SYSFS 2004-02-09 18:45:59.000000000 -0800 +++ 25-akpm/include/linux/sysfs.h 2004-02-09 18:45:59.000000000 -0800 @@ -18,6 +18,12 @@ struct attribute { mode_t mode; }; +struct attribute_group { + char * name; + struct attribute ** attrs; +}; + + struct bin_attribute { struct attribute attr; size_t size; @@ -25,14 +31,13 @@ struct bin_attribute { ssize_t (*write)(struct kobject *, char *, loff_t, size_t); }; -int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr); -int sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr); - struct sysfs_ops { ssize_t (*show)(struct kobject *, struct attribute *,char *); ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t); }; +#ifdef CONFIG_SYSFS + extern int sysfs_create_dir(struct kobject *); @@ -57,13 +62,75 @@ sysfs_create_link(struct kobject * kobj, extern void sysfs_remove_link(struct kobject *, char * name); - -struct attribute_group { - char * name; - struct attribute ** attrs; -}; +int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr); +int sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr); int sysfs_create_group(struct kobject *, const struct attribute_group *); void sysfs_remove_group(struct kobject *, const struct attribute_group *); +#else /* CONFIG_SYSFS */ + +static inline int sysfs_create_dir(struct kobject * k) +{ + return 0; +} + +static inline void sysfs_remove_dir(struct kobject * k) +{ + ; +} + +static inline void sysfs_rename_dir(struct kobject * k, const char *new_name) +{ + ; +} + +static inline int sysfs_create_file(struct kobject * k, const struct attribute * a) +{ + return 0; +} + +static inline int sysfs_update_file(struct kobject * k, const struct attribute * a) +{ + return 0; +} + +static inline void sysfs_remove_file(struct kobject * k, const struct attribute * a) +{ + ; +} + +static inline int sysfs_create_link(struct kobject * k, struct kobject * t, char * n) +{ + return 0; +} + +static inline void sysfs_remove_link(struct kobject * k, char * name) +{ + ; +} + + +static inline int sysfs_create_bin_file(struct kobject * k, struct bin_attribute * a) +{ + return 0; +} + +static inline int sysfs_remove_bin_file(struct kobject * k, struct bin_attribute * a) +{ + return 0; +} + +static inline int sysfs_create_group(struct kobject * k, const struct attribute_group *g) +{ + return 0; +} + +static inline void sysfs_remove_group(struct kobject * k, const struct attribute_group * g) +{ + ; +} + +#endif /* CONFIG_SYSFS */ + #endif /* _SYSFS_H_ */ _