diff options
author | Mike Waychison <mikew@google.com> | 2005-09-07 02:17:10 +0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-09-08 03:57:26 +0400 |
commit | 19b4946ca9d1e35d4c641dcebe27378de34f3ddd (patch) | |
tree | add66dd24e7a30441bbe26a4cc35e1124434e5b9 /ipc/msg.c | |
parent | ae7817745eef3b4ed3c2e36cb403e0c50f17d4e4 (diff) | |
download | linux-19b4946ca9d1e35d4c641dcebe27378de34f3ddd.tar.xz |
[PATCH] ipc: convert /proc/sysvipc/* to generic seq_file interface
Change the /proc/sysvipc/shm|sem|msg files to use the generic seq_file
implementation for struct ipc_ids.
Signed-off-by: Mike Waychison <mikew@google.com>
Cc: Manfred Spraul <manfred@colorfullife.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'ipc/msg.c')
-rw-r--r-- | ipc/msg.c | 82 |
1 files changed, 27 insertions, 55 deletions
diff --git a/ipc/msg.c b/ipc/msg.c index 27e516f96cdc..d035bd2aba96 100644 --- a/ipc/msg.c +++ b/ipc/msg.c @@ -26,6 +26,7 @@ #include <linux/sched.h> #include <linux/syscalls.h> #include <linux/audit.h> +#include <linux/seq_file.h> #include <asm/current.h> #include <asm/uaccess.h> #include "util.h" @@ -74,16 +75,16 @@ static struct ipc_ids msg_ids; static void freeque (struct msg_queue *msq, int id); static int newque (key_t key, int msgflg); #ifdef CONFIG_PROC_FS -static int sysvipc_msg_read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data); +static int sysvipc_msg_proc_show(struct seq_file *s, void *it); #endif void __init msg_init (void) { ipc_init_ids(&msg_ids,msg_ctlmni); - -#ifdef CONFIG_PROC_FS - create_proc_read_entry("sysvipc/msg", 0, NULL, sysvipc_msg_read_proc, NULL); -#endif + ipc_init_proc_interface("sysvipc/msg", + " key msqid perms cbytes qnum lspid lrpid uid gid cuid cgid stime rtime ctime\n", + &msg_ids, + sysvipc_msg_proc_show); } static int newque (key_t key, int msgflg) @@ -113,6 +114,7 @@ static int newque (key_t key, int msgflg) return -ENOSPC; } + msq->q_id = msg_buildid(id,msq->q_perm.seq); msq->q_stime = msq->q_rtime = 0; msq->q_ctime = get_seconds(); msq->q_cbytes = msq->q_qnum = 0; @@ -123,7 +125,7 @@ static int newque (key_t key, int msgflg) INIT_LIST_HEAD(&msq->q_senders); msg_unlock(msq); - return msg_buildid(id,msq->q_perm.seq); + return msq->q_id; } static inline void ss_add(struct msg_queue* msq, struct msg_sender* mss) @@ -808,55 +810,25 @@ out_unlock: } #ifdef CONFIG_PROC_FS -static int sysvipc_msg_read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data) +static int sysvipc_msg_proc_show(struct seq_file *s, void *it) { - off_t pos = 0; - off_t begin = 0; - int i, len = 0; - - down(&msg_ids.sem); - len += sprintf(buffer, " key msqid perms cbytes qnum lspid lrpid uid gid cuid cgid stime rtime ctime\n"); - - for(i = 0; i <= msg_ids.max_id; i++) { - struct msg_queue * msq; - msq = msg_lock(i); - if(msq != NULL) { - len += sprintf(buffer + len, "%10d %10d %4o %10lu %10lu %5u %5u %5u %5u %5u %5u %10lu %10lu %10lu\n", - msq->q_perm.key, - msg_buildid(i,msq->q_perm.seq), - msq->q_perm.mode, - msq->q_cbytes, - msq->q_qnum, - msq->q_lspid, - msq->q_lrpid, - msq->q_perm.uid, - msq->q_perm.gid, - msq->q_perm.cuid, - msq->q_perm.cgid, - msq->q_stime, - msq->q_rtime, - msq->q_ctime); - msg_unlock(msq); - - pos += len; - if(pos < offset) { - len = 0; - begin = pos; - } - if(pos > offset + length) - goto done; - } - - } - *eof = 1; -done: - up(&msg_ids.sem); - *start = buffer + (offset - begin); - len -= (offset - begin); - if(len > length) - len = length; - if(len < 0) - len = 0; - return len; + struct msg_queue *msq = it; + + return seq_printf(s, + "%10d %10d %4o %10lu %10lu %5u %5u %5u %5u %5u %5u %10lu %10lu %10lu\n", + msq->q_perm.key, + msq->q_id, + msq->q_perm.mode, + msq->q_cbytes, + msq->q_qnum, + msq->q_lspid, + msq->q_lrpid, + msq->q_perm.uid, + msq->q_perm.gid, + msq->q_perm.cuid, + msq->q_perm.cgid, + msq->q_stime, + msq->q_rtime, + msq->q_ctime); } #endif |