diff options
author | Mike Waychison <mikew@google.com> | 2005-09-06 18:17:10 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-09-07 19:57:26 -0400 |
commit | 19b4946ca9d1e35d4c641dcebe27378de34f3ddd (patch) | |
tree | add66dd24e7a30441bbe26a4cc35e1124434e5b9 /ipc/msg.c | |
parent | ae7817745eef3b4ed3c2e36cb403e0c50f17d4e4 (diff) |
[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
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/sched.h> | 26 | #include <linux/sched.h> |
27 | #include <linux/syscalls.h> | 27 | #include <linux/syscalls.h> |
28 | #include <linux/audit.h> | 28 | #include <linux/audit.h> |
29 | #include <linux/seq_file.h> | ||
29 | #include <asm/current.h> | 30 | #include <asm/current.h> |
30 | #include <asm/uaccess.h> | 31 | #include <asm/uaccess.h> |
31 | #include "util.h" | 32 | #include "util.h" |
@@ -74,16 +75,16 @@ static struct ipc_ids msg_ids; | |||
74 | static void freeque (struct msg_queue *msq, int id); | 75 | static void freeque (struct msg_queue *msq, int id); |
75 | static int newque (key_t key, int msgflg); | 76 | static int newque (key_t key, int msgflg); |
76 | #ifdef CONFIG_PROC_FS | 77 | #ifdef CONFIG_PROC_FS |
77 | static int sysvipc_msg_read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data); | 78 | static int sysvipc_msg_proc_show(struct seq_file *s, void *it); |
78 | #endif | 79 | #endif |
79 | 80 | ||
80 | void __init msg_init (void) | 81 | void __init msg_init (void) |
81 | { | 82 | { |
82 | ipc_init_ids(&msg_ids,msg_ctlmni); | 83 | ipc_init_ids(&msg_ids,msg_ctlmni); |
83 | 84 | ipc_init_proc_interface("sysvipc/msg", | |
84 | #ifdef CONFIG_PROC_FS | 85 | " key msqid perms cbytes qnum lspid lrpid uid gid cuid cgid stime rtime ctime\n", |
85 | create_proc_read_entry("sysvipc/msg", 0, NULL, sysvipc_msg_read_proc, NULL); | 86 | &msg_ids, |
86 | #endif | 87 | sysvipc_msg_proc_show); |
87 | } | 88 | } |
88 | 89 | ||
89 | static int newque (key_t key, int msgflg) | 90 | static int newque (key_t key, int msgflg) |
@@ -113,6 +114,7 @@ static int newque (key_t key, int msgflg) | |||
113 | return -ENOSPC; | 114 | return -ENOSPC; |
114 | } | 115 | } |
115 | 116 | ||
117 | msq->q_id = msg_buildid(id,msq->q_perm.seq); | ||
116 | msq->q_stime = msq->q_rtime = 0; | 118 | msq->q_stime = msq->q_rtime = 0; |
117 | msq->q_ctime = get_seconds(); | 119 | msq->q_ctime = get_seconds(); |
118 | msq->q_cbytes = msq->q_qnum = 0; | 120 | msq->q_cbytes = msq->q_qnum = 0; |
@@ -123,7 +125,7 @@ static int newque (key_t key, int msgflg) | |||
123 | INIT_LIST_HEAD(&msq->q_senders); | 125 | INIT_LIST_HEAD(&msq->q_senders); |
124 | msg_unlock(msq); | 126 | msg_unlock(msq); |
125 | 127 | ||
126 | return msg_buildid(id,msq->q_perm.seq); | 128 | return msq->q_id; |
127 | } | 129 | } |
128 | 130 | ||
129 | static inline void ss_add(struct msg_queue* msq, struct msg_sender* mss) | 131 | static inline void ss_add(struct msg_queue* msq, struct msg_sender* mss) |
@@ -808,55 +810,25 @@ out_unlock: | |||
808 | } | 810 | } |
809 | 811 | ||
810 | #ifdef CONFIG_PROC_FS | 812 | #ifdef CONFIG_PROC_FS |
811 | static int sysvipc_msg_read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data) | 813 | static int sysvipc_msg_proc_show(struct seq_file *s, void *it) |
812 | { | 814 | { |
813 | off_t pos = 0; | 815 | struct msg_queue *msq = it; |
814 | off_t begin = 0; | 816 | |
815 | int i, len = 0; | 817 | return seq_printf(s, |
816 | 818 | "%10d %10d %4o %10lu %10lu %5u %5u %5u %5u %5u %5u %10lu %10lu %10lu\n", | |
817 | down(&msg_ids.sem); | 819 | msq->q_perm.key, |
818 | len += sprintf(buffer, " key msqid perms cbytes qnum lspid lrpid uid gid cuid cgid stime rtime ctime\n"); | 820 | msq->q_id, |
819 | 821 | msq->q_perm.mode, | |
820 | for(i = 0; i <= msg_ids.max_id; i++) { | 822 | msq->q_cbytes, |
821 | struct msg_queue * msq; | 823 | msq->q_qnum, |
822 | msq = msg_lock(i); | 824 | msq->q_lspid, |
823 | if(msq != NULL) { | 825 | msq->q_lrpid, |
824 | len += sprintf(buffer + len, "%10d %10d %4o %10lu %10lu %5u %5u %5u %5u %5u %5u %10lu %10lu %10lu\n", | 826 | msq->q_perm.uid, |
825 | msq->q_perm.key, | 827 | msq->q_perm.gid, |
826 | msg_buildid(i,msq->q_perm.seq), | 828 | msq->q_perm.cuid, |
827 | msq->q_perm.mode, | 829 | msq->q_perm.cgid, |
828 | msq->q_cbytes, | 830 | msq->q_stime, |
829 | msq->q_qnum, | 831 | msq->q_rtime, |
830 | msq->q_lspid, | 832 | msq->q_ctime); |
831 | msq->q_lrpid, | ||
832 | msq->q_perm.uid, | ||
833 | msq->q_perm.gid, | ||
834 | msq->q_perm.cuid, | ||
835 | msq->q_perm.cgid, | ||
836 | msq->q_stime, | ||
837 | msq->q_rtime, | ||
838 | msq->q_ctime); | ||
839 | msg_unlock(msq); | ||
840 | |||
841 | pos += len; | ||
842 | if(pos < offset) { | ||
843 | len = 0; | ||
844 | begin = pos; | ||
845 | } | ||
846 | if(pos > offset + length) | ||
847 | goto done; | ||
848 | } | ||
849 | |||
850 | } | ||
851 | *eof = 1; | ||
852 | done: | ||
853 | up(&msg_ids.sem); | ||
854 | *start = buffer + (offset - begin); | ||
855 | len -= (offset - begin); | ||
856 | if(len > length) | ||
857 | len = length; | ||
858 | if(len < 0) | ||
859 | len = 0; | ||
860 | return len; | ||
861 | } | 833 | } |
862 | #endif | 834 | #endif |