/proc/sys replacement code (in progress)
Subsystems (2)
PATCH 1/1 /proc/sys replacement code (in progress)
After my last /proc patch (see "Replacement for current /proc of shit" thread), it has become clear that my new "single value" proc code is more appropriate in a new filesystem. I have also removed the (complex) dynamic directory support.
The patch against 2.5.1 is included below: it doesn't yet have the glue layer to support the old sysctl code, which I'll work on when I come back from Christmas holidays (early January).
For full details:
http://www.kernel.org/pub/linux/kernel/people/rusty/
Comments *ON THE CODE* eagerly sought,
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
fs/sys/test.c +54 -0
@@ -0,0 +1,54 @@ +/* Test stuff for new sys */ +#include <linux/sys_fs.h> +#include <linux/spinlock.h> +#include <asm/semaphore.h> + +static spinlock_t test_lock =SPIN_LOCK_UNLOCKED ; +static DECLARE_MUTEX (test_sem); + +unsigned int a, b, c; + +static int set_off (const char *dirname, +const char *filename, +const char *buffer, +unsigned int size, +void *arg) +{ +if (size <sizeof ("REMOVE" )-1 ) +return -1 ;/* FIXME: -EINVAL */ +if (strncmp ("REMOVE" , buffer,sizeof ("REMOVE" )-1 ) ==0 ) { +/* Remove everything */ +unsys ("test" ,"a" ); +unsys ("test" ,"b" ); +unsys ("test" ,"c" ); +unsys ("test" ,"off" ); + } +return 0 ; +} + +static int get_off (const char *dirname, +const char *filename, +char *buffer, +unsigned int size, +void *arg) +{ +return snprintf (buffer, size,"Write REMOVE here to remove me\n" ); +} + +static int __init init_test (void ) +{ +if (sys ("test" ,"a" , a, uint,S_IWUSR |S_IRUGO ) !=0 ) +printk ("Failed: a" ); +if (sys_spinlock ("test" ,"b" , b, uint, &test_lock,S_IWUSR |S_IRUGO ) + !=0 ) +printk ("Failed: b" ); +if (sys_sem ("test" ,"c" , c, uint, &test_sem,S_IWUSR |S_IRUGO ) !=0 ) +printk ("Failed: c" ); +if (sys_callfn ("test" ,"off" , get_off, set_off,NULL ,S_IWUSR |S_IRUGO ) + !=0 ) +printk ("Failed: off" ); + +return 0 ; +} + +module_init (init_test);
include/linux/sys_fs.h +127 -0
127 lines not on this page · raw message
fs/Config.in +2 -0
@@ -61,6 +61,8 @@ bool '/proc file system support' CONFIG_PROC_FS +bool '/proc/sys file system support (EXPERIMENTAL)' CONFIG_SYS_FS $CONFIG_EXPERIMENTAL + dep_bool '/dev file system support (EXPERIMENTAL)' CONFIG_DEVFS_FS $CONFIG_EXPERIMENTAL dep_bool ' Automatically mount at boot' CONFIG_DEVFS_MOUNT $CONFIG_DEVFS_FS dep_bool ' Debug devfs' CONFIG_DEVFS_DEBUG $CONFIG_DEVFS_FS
fs/Makefile +1 -0
@@ -23,6 +23,7 @@ endif subdir-$(CONFIG_PROC_FS) += proc +subdir-$(CONFIG_SYS_FS) += sys subdir-y += partitions # Do not add any filesystems before this line
fs/sys/Makefile +9 -0
@@ -0,0 +1,9 @@ +# Makefile for the Linux sys filesystem routines. + +O_TARGET := sys.o + +export-objs := helper.o sys_core.o + +obj-y := sys_core.o helper.o test.o + +include $(TOPDIR)/Rules.make
fs/sys/helper.c +233 -0
233 lines not on this page · raw message
fs/sys/sys_core.c +550 -0
550 lines not on this page · raw message
include/linux/sysctl.h +1 -0
@@ -1,3 +1,4 @@ +/* Obsolete: use sys_fs.h -- Rusty Russell. */ /* * sysctl.h: General linux system control interface *
include/linux/typecheck.h +29 -0
@@ -0,0 +1,29 @@ +#ifndef _LINUX_TYPECHECK_H +#define _LINUX_TYPECHECK_H +/* Simple macros to do compile-time type checking. IIRC, Jakub +Jelinek came up with this idea for the 2.4 module init code. */ +/* (C) 2001 Rusty Russell */ + +#define __CHECK_byte (name, p)/* Yeah, whatever */ +#define __CHECK_short (name, p) \ + extern inline short *__CHECK_##name(void) { return(p); } +#define __CHECK_ushort (name, p) \ + extern inline unsigned short *__CHECK_##name(void) { return(p); } +#define __CHECK_int (name, p) \ + extern inline int *__CHECK_##name(void) { return(p); } +#define __CHECK_uint (name, p) \ + extern inline unsigned int *__CHECK_##name(void) { return(p); } +#define __CHECK_long (name, p) \ + extern inline long *__CHECK_##name(void) { return(p); } +#define __CHECK_ulong (name, p) \ + extern inline unsigned long *__CHECK_##name(void) { return(p); } +#define __CHECK_charp (name, p) \ + extern inline char **__CHECK_##name(void) { return(p); } +#define __CHECK_bool (name, p) \ + extern inline int *__CHECK_##name(void) { return(p); } +#define __CHECK_invbool (name, p) \ + extern inline int *__CHECK_##name(void) { return(p); } +#define __CHECK_string (name, p) \ + extern inline char *__CHECK_##name(void) { return(p); } + +#endif /* _LINUX_TYPECHECK_H */