diff -Naur ipc/shm.c ./../linux-2.5.74ff1/ipc/shm.c --- ipc/shm.c 2003-07-02 22:48:07.000000000 +0200 +++ ./../linux-2.5.74ff1/ipc/shm.c 2003-07-07 22:32:45.000000000 +0200 @@ -13,6 +13,7 @@ * Shared /dev/zero support, Kanoj Sarcar * Move the mm functionality over to mm/shmem.c, Christoph Rohland * + * /sys/ipc support (c) 2003 Fabian Frédérick */ #include @@ -27,7 +28,8 @@ #include #include #include - +#include +#include #include "util.h" #define shm_flags shm_perm.mode @@ -62,6 +64,9 @@ #ifdef CONFIG_PROC_FS create_proc_read_entry("sysvipc/shm", 0, 0, sysvipc_shm_read_proc, NULL); #endif + shm_ids.kobj.parent = &ipc_subsys.kset.kobj; + sprintf(shm_ids.kobj.name, "%s", "shm"); + kobject_register(&shm_ids.kobj); } static inline int shm_checkid(struct shmid_kernel *s, int id) @@ -234,6 +239,10 @@ return error; } +/* Create a shared memory segment with given size and flags + * Returns negative result in case of failure + */ + asmlinkage long sys_shmget (key_t key, size_t size, int shmflg) { struct shmid_kernel *shp; diff -Naur ipc/util.c ./../linux-2.5.74ff1/ipc/util.c --- ipc/util.c 2003-07-02 22:46:12.000000000 +0200 +++ ./../linux-2.5.74ff1/ipc/util.c 2003-07-07 22:32:10.000000000 +0200 @@ -24,6 +24,7 @@ #include #include #include +#include #if defined(CONFIG_SYSVIPC) @@ -35,9 +36,10 @@ * The various system5 IPC resources (semaphores, messages and shared * memory are initialised */ - void __init ipc_init (void) { + sprintf(ipc_subsys.kset.kobj.name, "%s", "ipc"); + subsystem_register(&ipc_subsys); sem_init(); msg_init(); shm_init(); @@ -196,6 +198,8 @@ rcu_read_lock(); spin_lock(&new->lock); ids->entries[id].p = new; + kobject_register(&ids->entries[id].kobj); + return id; } @@ -432,12 +436,12 @@ * So far only shm_get_stat() calls ipc_get() via shm_get(), so ipc_get() * is called with shm_ids.sem locked. Since grow_ary() is also called with * shm_ids.sem down(for Shared Memory), there is no need to add read - * barriers here to gurantee the writes in grow_ary() are seen in order + * barriers here to guarantee the writes in grow_ary() are seen in order * here (for Alpha). * - * However ipc_get() itself does not necessary require ipc_ids.sem down. So + * However ipc_get() itself does not necessarily require ipc_ids.sem down. So * if in the future ipc_get() is used by other places without ipc_ids.sem - * down, then ipc_get() needs read memery barriers as ipc_lock() does. + * down, then ipc_get() needs read memory barriers as ipc_lock() does. */ struct kern_ipc_perm* ipc_get(struct ipc_ids* ids, int id) { diff -Naur ipc/util.h ./../linux-2.5.74ff1/ipc/util.h --- ipc/util.h 2003-07-02 22:49:13.000000000 +0200 +++ ./../linux-2.5.74ff1/ipc/util.h 2003-07-07 22:32:11.000000000 +0200 @@ -7,6 +7,7 @@ #define USHRT_MAX 0xffff #define SEQ_MULTIPLIER (IPCMNI) +static struct subsystem ipc_subsys; void sem_init (void); void msg_init (void); void shm_init (void); @@ -19,9 +20,11 @@ unsigned short seq_max; struct semaphore sem; struct ipc_id* entries; + struct kobject kobj; }; struct ipc_id { + struct kobject kobj; struct kern_ipc_perm* p; };