Commit d0d15d84 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] Add CONFIG_SYSFS

From: Patrick Mochel <mochel@digitalimplant.org>

Here is a patch to make sysfs optional.  Note that with CONFIG_SYSFS=n you
must specify the boot device's major:minor on the kernel boot command line
with

	root=03:01

For embedded systems, it will save a significant amount of memory during
runtime.  And, it saves 4k from the built kernel image for me.
parent e4730c3e
......@@ -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 used by the block subsystem to mount the root
partition. If sysfs is disabled you must specify the boot device on
the kernel boot command line via its major and minor numbers. For
example, "root=03:01" for /dev/hda1.
Designers of embedded systems may wish to say N here to conserve space.
config DEVFS_FS
bool "/dev file system support (OBSOLETE)"
depends on EXPERIMENTAL
......
......@@ -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
......
......@@ -24,7 +24,15 @@
#include <asm/uaccess.h>
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;
......
......@@ -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, struct kobject * target, char * name);
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_ */
......@@ -141,9 +141,11 @@ dev_t __init name_to_dev_t(char *name)
dev_t res = 0;
int part;
#ifdef CONFIG_SYSFS
sys_mkdir("/sys", 0700);
if (sys_mount("sysfs", "/sys", "sysfs", 0, NULL) < 0)
goto out;
#endif
if (strncmp(name, "/dev/", 5) != 0) {
unsigned maj, min;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment