diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1999-06-17 13:25:08 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 1999-06-17 13:25:08 +0000 |
commit | 59223edaa18759982db0a8aced0e77457d10c68e (patch) | |
tree | 89354903b01fa0a447bffeefe00df3044495db2e /ipc | |
parent | db7d4daea91e105e3859cf461d7e53b9b77454b2 (diff) |
Merge with Linux 2.3.6. Sorry, this isn't tested on silicon, I don't
have a MIPS box at hand.
Diffstat (limited to 'ipc')
-rw-r--r-- | ipc/msg.c | 67 | ||||
-rw-r--r-- | ipc/sem.c | 62 | ||||
-rw-r--r-- | ipc/shm.c | 64 |
3 files changed, 184 insertions, 9 deletions
@@ -8,6 +8,7 @@ * Fixed up the unchecked user space derefs * Copyright (C) 1998 Alan Cox & Andi Kleen * + * /proc/sysvipc/msg support (c) 1999 Dragos Acostachioaie <dragos@iname.com> */ #include <linux/malloc.h> @@ -15,6 +16,7 @@ #include <linux/interrupt.h> #include <linux/smp_lock.h> #include <linux/init.h> +#include <linux/proc_fs.h> #include <asm/uaccess.h> @@ -23,6 +25,9 @@ extern int ipcperms (struct ipc_perm *ipcp, short msgflg); static void freeque (int id); static int newque (key_t key, int msgflg); static int findkey (key_t key); +#ifdef CONFIG_PROC_FS +static int sysvipc_msg_read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data); +#endif static struct msqid_ds *msgque[MSGMNI]; static int msgbytes = 0; @@ -30,16 +35,23 @@ static int msghdrs = 0; static unsigned short msg_seq = 0; static int used_queues = 0; static int max_msqid = 0; -static struct wait_queue *msg_lock = NULL; +static DECLARE_WAIT_QUEUE_HEAD(msg_lock); void __init msg_init (void) { int id; - +#ifdef CONFIG_PROC_FS + struct proc_dir_entry *ent; +#endif + for (id = 0; id < MSGMNI; id++) msgque[id] = (struct msqid_ds *) IPC_UNUSED; msgbytes = msghdrs = msg_seq = max_msqid = used_queues = 0; - msg_lock = NULL; + init_waitqueue_head(&msg_lock); +#ifdef CONFIG_PROC_FS + ent = create_proc_entry("sysvipc/msg", 0, 0); + ent->read_proc = sysvipc_msg_read_proc; +#endif return; } @@ -284,7 +296,8 @@ found: ipcp->gid = ipcp->cgid = current->egid; msq->msg_perm.seq = msg_seq; msq->msg_first = msq->msg_last = NULL; - msq->rwait = msq->wwait = NULL; + init_waitqueue_head(&msq->wwait); + init_waitqueue_head(&msq->rwait); msq->msg_cbytes = msq->msg_qnum = 0; msq->msg_lspid = msq->msg_lrpid = 0; msq->msg_stime = msq->msg_rtime = 0; @@ -491,3 +504,49 @@ out: return err; } +#ifdef CONFIG_PROC_FS +static int sysvipc_msg_read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data) +{ + off_t pos = 0; + off_t begin = 0; + int i, len = 0; + + len += sprintf(buffer, " key msqid perms cbytes qnum lspid lrpid uid gid cuid cgid stime rtime ctime\n"); + + for(i = 0; i < MSGMNI; i++) + if(msgque[i] != IPC_UNUSED) { + len += sprintf(buffer + len, "%10d %10d %4o %5u %5u %5u %5u %5u %5u %5u %5u %10lu %10lu %10lu\n", + msgque[i]->msg_perm.key, + msgque[i]->msg_perm.seq * MSGMNI + i, + msgque[i]->msg_perm.mode, + msgque[i]->msg_cbytes, + msgque[i]->msg_qnum, + msgque[i]->msg_lspid, + msgque[i]->msg_lrpid, + msgque[i]->msg_perm.uid, + msgque[i]->msg_perm.gid, + msgque[i]->msg_perm.cuid, + msgque[i]->msg_perm.cgid, + msgque[i]->msg_stime, + msgque[i]->msg_rtime, + msgque[i]->msg_ctime); + + pos += len; + if(pos < offset) { + len = 0; + begin = pos; + } + if(pos > offset + length) + goto done; + } + *eof = 1; +done: + *start = buffer + (offset - begin); + len -= (offset - begin); + if(len > length) + len = length; + if(len < 0) + len = 0; + return len; +} +#endif @@ -48,11 +48,14 @@ * better but only get the semops right which only wait for zero or * increase. If there are decrement operations in the operations * array we do the same as before. + * + * /proc/sysvipc/sem support (c) 1999 Dragos Acostachioaie <dragos@iname.com> */ #include <linux/malloc.h> #include <linux/smp_lock.h> #include <linux/init.h> +#include <linux/proc_fs.h> #include <asm/uaccess.h> @@ -60,10 +63,13 @@ extern int ipcperms (struct ipc_perm *ipcp, short semflg); static int newary (key_t, int, int); static int findkey (key_t key); static void freeary (int id); +#ifdef CONFIG_PROC_FS +static int sysvipc_sem_read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data); +#endif static struct semid_ds *semary[SEMMNI]; static int used_sems = 0, used_semids = 0; -static struct wait_queue *sem_lock = NULL; +static DECLARE_WAIT_QUEUE_HEAD(sem_lock); static int max_semid = 0; static unsigned short sem_seq = 0; @@ -71,11 +77,18 @@ static unsigned short sem_seq = 0; void __init sem_init (void) { int i; +#ifdef CONFIG_PROC_FS + struct proc_dir_entry *ent; +#endif - sem_lock = NULL; + init_waitqueue_head(&sem_lock); used_sems = used_semids = max_semid = sem_seq = 0; for (i = 0; i < SEMMNI; i++) semary[i] = (struct semid_ds *) IPC_UNUSED; +#ifdef CONFIG_PROC_FS + ent = create_proc_entry("sysvipc/sem", 0, 0); + ent->read_proc = sysvipc_sem_read_proc; +#endif return; } @@ -690,7 +703,7 @@ asmlinkage int sys_semop (int semid, struct sembuf *tsops, unsigned nsops) for (;;) { queue.status = -EINTR; - queue.sleeper = NULL; + init_waitqueue_head(&queue.sleeper); interruptible_sleep_on(&queue.sleeper); /* @@ -785,3 +798,46 @@ found: } current->semundo = NULL; } + +#ifdef CONFIG_PROC_FS +static int sysvipc_sem_read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data) +{ + off_t pos = 0; + off_t begin = 0; + int i, len = 0; + + len += sprintf(buffer, " key semid perms nsems uid gid cuid cgid otime ctime\n"); + + for(i = 0; i < SEMMNI; i++) + if(semary[i] != IPC_UNUSED) { + len += sprintf(buffer + len, "%10d %10d %4o %5u %5u %5u %5u %5u %10lu %10lu\n", + semary[i]->sem_perm.key, + semary[i]->sem_perm.seq * SEMMNI + i, + semary[i]->sem_perm.mode, + semary[i]->sem_nsems, + semary[i]->sem_perm.uid, + semary[i]->sem_perm.gid, + semary[i]->sem_perm.cuid, + semary[i]->sem_perm.cgid, + semary[i]->sem_otime, + semary[i]->sem_ctime); + + pos += len; + if(pos < offset) { + len = 0; + begin = pos; + } + if(pos > offset + length) + goto done; + } + *eof = 1; +done: + *start = buffer + (offset - begin); + len -= (offset - begin); + if(len > length) + len = length; + if(len < 0) + len = 0; + return len; +} +#endif @@ -4,6 +4,8 @@ * Many improvements/fixes by Bruno Haible. * Replaced `struct shm_desc' by `struct vm_area_struct', July 1994. * Fixed the shm swap deallocation (shm_unuse()), August 1998 Andrea Arcangeli. + * + * /proc/sysvipc/shm support (c) 1999 Dragos Acostachioaie <dragos@iname.com> */ #include <linux/malloc.h> @@ -12,6 +14,7 @@ #include <linux/smp_lock.h> #include <linux/init.h> #include <linux/vmalloc.h> +#include <linux/proc_fs.h> #include <asm/uaccess.h> #include <asm/pgtable.h> @@ -26,12 +29,15 @@ static void shm_open (struct vm_area_struct *shmd); static void shm_close (struct vm_area_struct *shmd); static unsigned long shm_nopage(struct vm_area_struct *, unsigned long, int); static int shm_swapout(struct vm_area_struct *, struct page *); +#ifdef CONFIG_PROC_FS +static int sysvipc_shm_read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data); +#endif static int shm_tot = 0; /* total number of shared memory pages */ static int shm_rss = 0; /* number of shared memory pages that are in memory */ static int shm_swp = 0; /* number of shared memory pages that are in swap */ static int max_shmid = 0; /* every used id is <= max_shmid */ -static struct wait_queue *shm_lock = NULL; /* calling findkey() may need to wait */ +static DECLARE_WAIT_QUEUE_HEAD(shm_lock); /* calling findkey() may need to wait */ static struct shmid_kernel *shm_segs[SHMMNI]; static unsigned short shm_seq = 0; /* incremented, for recognizing stale ids */ @@ -44,11 +50,18 @@ static ulong used_segs = 0; void __init shm_init (void) { int id; +#ifdef CONFIG_PROC_FS + struct proc_dir_entry *ent; +#endif for (id = 0; id < SHMMNI; id++) shm_segs[id] = (struct shmid_kernel *) IPC_UNUSED; shm_tot = shm_rss = shm_seq = max_shmid = used_segs = 0; - shm_lock = NULL; + init_waitqueue_head(&shm_lock); +#ifdef CONFIG_PROC_FS + ent = create_proc_entry("sysvipc/shm", 0, 0); + ent->read_proc = sysvipc_shm_read_proc; +#endif return; } @@ -762,3 +775,50 @@ void shm_unuse(unsigned long entry, unsigned long page) return; } } + +#ifdef CONFIG_PROC_FS +static int sysvipc_shm_read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data) +{ + off_t pos = 0; + off_t begin = 0; + int i, len = 0; + + len += sprintf(buffer, " key shmid perms size cpid lpid nattch uid gid cuid cgid atime dtime ctime\n"); + + for(i = 0; i < SHMMNI; i++) + if(shm_segs[i] != IPC_UNUSED) { + len += sprintf(buffer + len, "%10d %10d %4o %10d %5u %5u %5d %5u %5u %5u %5u %10lu %10lu %10lu\n", + shm_segs[i]->u.shm_perm.key, + shm_segs[i]->u.shm_perm.seq * SHMMNI + i, + shm_segs[i]->u.shm_perm.mode, + shm_segs[i]->u.shm_segsz, + shm_segs[i]->u.shm_cpid, + shm_segs[i]->u.shm_lpid, + shm_segs[i]->u.shm_nattch, + shm_segs[i]->u.shm_perm.uid, + shm_segs[i]->u.shm_perm.gid, + shm_segs[i]->u.shm_perm.cuid, + shm_segs[i]->u.shm_perm.cgid, + shm_segs[i]->u.shm_atime, + shm_segs[i]->u.shm_dtime, + shm_segs[i]->u.shm_ctime); + + pos += len; + if(pos < offset) { + len = 0; + begin = pos; + } + if(pos > offset + length) + goto done; + } + *eof = 1; +done: + *start = buffer + (offset - begin); + len -= (offset - begin); + if(len > length) + len = length; + if(len < 0) + len = 0; + return len; +} +#endif |