diff options
Diffstat (limited to 'ipc')
-rw-r--r-- | ipc/msg.c | 82 | ||||
-rw-r--r-- | ipc/sem.c | 73 | ||||
-rw-r--r-- | ipc/shm.c | 86 |
3 files changed, 78 insertions, 163 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 |
@@ -73,6 +73,7 @@ | |||
73 | #include <linux/security.h> | 73 | #include <linux/security.h> |
74 | #include <linux/syscalls.h> | 74 | #include <linux/syscalls.h> |
75 | #include <linux/audit.h> | 75 | #include <linux/audit.h> |
76 | #include <linux/seq_file.h> | ||
76 | #include <asm/uaccess.h> | 77 | #include <asm/uaccess.h> |
77 | #include "util.h" | 78 | #include "util.h" |
78 | 79 | ||
@@ -89,7 +90,7 @@ static struct ipc_ids sem_ids; | |||
89 | static int newary (key_t, int, int); | 90 | static int newary (key_t, int, int); |
90 | static void freeary (struct sem_array *sma, int id); | 91 | static void freeary (struct sem_array *sma, int id); |
91 | #ifdef CONFIG_PROC_FS | 92 | #ifdef CONFIG_PROC_FS |
92 | static int sysvipc_sem_read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data); | 93 | static int sysvipc_sem_proc_show(struct seq_file *s, void *it); |
93 | #endif | 94 | #endif |
94 | 95 | ||
95 | #define SEMMSL_FAST 256 /* 512 bytes on stack */ | 96 | #define SEMMSL_FAST 256 /* 512 bytes on stack */ |
@@ -116,10 +117,10 @@ void __init sem_init (void) | |||
116 | { | 117 | { |
117 | used_sems = 0; | 118 | used_sems = 0; |
118 | ipc_init_ids(&sem_ids,sc_semmni); | 119 | ipc_init_ids(&sem_ids,sc_semmni); |
119 | 120 | ipc_init_proc_interface("sysvipc/sem", | |
120 | #ifdef CONFIG_PROC_FS | 121 | " key semid perms nsems uid gid cuid cgid otime ctime\n", |
121 | create_proc_read_entry("sysvipc/sem", 0, NULL, sysvipc_sem_read_proc, NULL); | 122 | &sem_ids, |
122 | #endif | 123 | sysvipc_sem_proc_show); |
123 | } | 124 | } |
124 | 125 | ||
125 | /* | 126 | /* |
@@ -193,6 +194,7 @@ static int newary (key_t key, int nsems, int semflg) | |||
193 | } | 194 | } |
194 | used_sems += nsems; | 195 | used_sems += nsems; |
195 | 196 | ||
197 | sma->sem_id = sem_buildid(id, sma->sem_perm.seq); | ||
196 | sma->sem_base = (struct sem *) &sma[1]; | 198 | sma->sem_base = (struct sem *) &sma[1]; |
197 | /* sma->sem_pending = NULL; */ | 199 | /* sma->sem_pending = NULL; */ |
198 | sma->sem_pending_last = &sma->sem_pending; | 200 | sma->sem_pending_last = &sma->sem_pending; |
@@ -201,7 +203,7 @@ static int newary (key_t key, int nsems, int semflg) | |||
201 | sma->sem_ctime = get_seconds(); | 203 | sma->sem_ctime = get_seconds(); |
202 | sem_unlock(sma); | 204 | sem_unlock(sma); |
203 | 205 | ||
204 | return sem_buildid(id, sma->sem_perm.seq); | 206 | return sma->sem_id; |
205 | } | 207 | } |
206 | 208 | ||
207 | asmlinkage long sys_semget (key_t key, int nsems, int semflg) | 209 | asmlinkage long sys_semget (key_t key, int nsems, int semflg) |
@@ -1328,50 +1330,21 @@ next_entry: | |||
1328 | } | 1330 | } |
1329 | 1331 | ||
1330 | #ifdef CONFIG_PROC_FS | 1332 | #ifdef CONFIG_PROC_FS |
1331 | static int sysvipc_sem_read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data) | 1333 | static int sysvipc_sem_proc_show(struct seq_file *s, void *it) |
1332 | { | 1334 | { |
1333 | off_t pos = 0; | 1335 | struct sem_array *sma = it; |
1334 | off_t begin = 0; | 1336 | |
1335 | int i, len = 0; | 1337 | return seq_printf(s, |
1336 | 1338 | "%10d %10d %4o %10lu %5u %5u %5u %5u %10lu %10lu\n", | |
1337 | len += sprintf(buffer, " key semid perms nsems uid gid cuid cgid otime ctime\n"); | 1339 | sma->sem_perm.key, |
1338 | down(&sem_ids.sem); | 1340 | sma->sem_id, |
1339 | 1341 | sma->sem_perm.mode, | |
1340 | for(i = 0; i <= sem_ids.max_id; i++) { | 1342 | sma->sem_nsems, |
1341 | struct sem_array *sma; | 1343 | sma->sem_perm.uid, |
1342 | sma = sem_lock(i); | 1344 | sma->sem_perm.gid, |
1343 | if(sma) { | 1345 | sma->sem_perm.cuid, |
1344 | len += sprintf(buffer + len, "%10d %10d %4o %10lu %5u %5u %5u %5u %10lu %10lu\n", | 1346 | sma->sem_perm.cgid, |
1345 | sma->sem_perm.key, | 1347 | sma->sem_otime, |
1346 | sem_buildid(i,sma->sem_perm.seq), | 1348 | sma->sem_ctime); |
1347 | sma->sem_perm.mode, | ||
1348 | sma->sem_nsems, | ||
1349 | sma->sem_perm.uid, | ||
1350 | sma->sem_perm.gid, | ||
1351 | sma->sem_perm.cuid, | ||
1352 | sma->sem_perm.cgid, | ||
1353 | sma->sem_otime, | ||
1354 | sma->sem_ctime); | ||
1355 | sem_unlock(sma); | ||
1356 | |||
1357 | pos += len; | ||
1358 | if(pos < offset) { | ||
1359 | len = 0; | ||
1360 | begin = pos; | ||
1361 | } | ||
1362 | if(pos > offset + length) | ||
1363 | goto done; | ||
1364 | } | ||
1365 | } | ||
1366 | *eof = 1; | ||
1367 | done: | ||
1368 | up(&sem_ids.sem); | ||
1369 | *start = buffer + (offset - begin); | ||
1370 | len -= (offset - begin); | ||
1371 | if(len > length) | ||
1372 | len = length; | ||
1373 | if(len < 0) | ||
1374 | len = 0; | ||
1375 | return len; | ||
1376 | } | 1349 | } |
1377 | #endif | 1350 | #endif |
@@ -23,12 +23,12 @@ | |||
23 | #include <linux/init.h> | 23 | #include <linux/init.h> |
24 | #include <linux/file.h> | 24 | #include <linux/file.h> |
25 | #include <linux/mman.h> | 25 | #include <linux/mman.h> |
26 | #include <linux/proc_fs.h> | ||
27 | #include <linux/shmem_fs.h> | 26 | #include <linux/shmem_fs.h> |
28 | #include <linux/security.h> | 27 | #include <linux/security.h> |
29 | #include <linux/syscalls.h> | 28 | #include <linux/syscalls.h> |
30 | #include <linux/audit.h> | 29 | #include <linux/audit.h> |
31 | #include <linux/ptrace.h> | 30 | #include <linux/ptrace.h> |
31 | #include <linux/seq_file.h> | ||
32 | 32 | ||
33 | #include <asm/uaccess.h> | 33 | #include <asm/uaccess.h> |
34 | 34 | ||
@@ -51,7 +51,7 @@ static int newseg (key_t key, int shmflg, size_t size); | |||
51 | static void shm_open (struct vm_area_struct *shmd); | 51 | static void shm_open (struct vm_area_struct *shmd); |
52 | static void shm_close (struct vm_area_struct *shmd); | 52 | static void shm_close (struct vm_area_struct *shmd); |
53 | #ifdef CONFIG_PROC_FS | 53 | #ifdef CONFIG_PROC_FS |
54 | static int sysvipc_shm_read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data); | 54 | static int sysvipc_shm_proc_show(struct seq_file *s, void *it); |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | size_t shm_ctlmax = SHMMAX; | 57 | size_t shm_ctlmax = SHMMAX; |
@@ -63,9 +63,10 @@ static int shm_tot; /* total number of shared memory pages */ | |||
63 | void __init shm_init (void) | 63 | void __init shm_init (void) |
64 | { | 64 | { |
65 | ipc_init_ids(&shm_ids, 1); | 65 | ipc_init_ids(&shm_ids, 1); |
66 | #ifdef CONFIG_PROC_FS | 66 | ipc_init_proc_interface("sysvipc/shm", |
67 | create_proc_read_entry("sysvipc/shm", 0, NULL, sysvipc_shm_read_proc, NULL); | 67 | " key shmid perms size cpid lpid nattch uid gid cuid cgid atime dtime ctime\n", |
68 | #endif | 68 | &shm_ids, |
69 | sysvipc_shm_proc_show); | ||
69 | } | 70 | } |
70 | 71 | ||
71 | static inline int shm_checkid(struct shmid_kernel *s, int id) | 72 | static inline int shm_checkid(struct shmid_kernel *s, int id) |
@@ -869,63 +870,32 @@ asmlinkage long sys_shmdt(char __user *shmaddr) | |||
869 | } | 870 | } |
870 | 871 | ||
871 | #ifdef CONFIG_PROC_FS | 872 | #ifdef CONFIG_PROC_FS |
872 | static int sysvipc_shm_read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data) | 873 | static int sysvipc_shm_proc_show(struct seq_file *s, void *it) |
873 | { | 874 | { |
874 | off_t pos = 0; | 875 | struct shmid_kernel *shp = it; |
875 | off_t begin = 0; | 876 | char *format; |
876 | int i, len = 0; | ||
877 | |||
878 | down(&shm_ids.sem); | ||
879 | len += sprintf(buffer, " key shmid perms size cpid lpid nattch uid gid cuid cgid atime dtime ctime\n"); | ||
880 | 877 | ||
881 | for(i = 0; i <= shm_ids.max_id; i++) { | ||
882 | struct shmid_kernel* shp; | ||
883 | |||
884 | shp = shm_lock(i); | ||
885 | if(shp!=NULL) { | ||
886 | #define SMALL_STRING "%10d %10d %4o %10u %5u %5u %5d %5u %5u %5u %5u %10lu %10lu %10lu\n" | 878 | #define SMALL_STRING "%10d %10d %4o %10u %5u %5u %5d %5u %5u %5u %5u %10lu %10lu %10lu\n" |
887 | #define BIG_STRING "%10d %10d %4o %21u %5u %5u %5d %5u %5u %5u %5u %10lu %10lu %10lu\n" | 879 | #define BIG_STRING "%10d %10d %4o %21u %5u %5u %5d %5u %5u %5u %5u %10lu %10lu %10lu\n" |
888 | char *format; | ||
889 | 880 | ||
890 | if (sizeof(size_t) <= sizeof(int)) | 881 | if (sizeof(size_t) <= sizeof(int)) |
891 | format = SMALL_STRING; | 882 | format = SMALL_STRING; |
892 | else | 883 | else |
893 | format = BIG_STRING; | 884 | format = BIG_STRING; |
894 | len += sprintf(buffer + len, format, | 885 | return seq_printf(s, format, |
895 | shp->shm_perm.key, | 886 | shp->shm_perm.key, |
896 | shm_buildid(i, shp->shm_perm.seq), | 887 | shp->id, |
897 | shp->shm_flags, | 888 | shp->shm_flags, |
898 | shp->shm_segsz, | 889 | shp->shm_segsz, |
899 | shp->shm_cprid, | 890 | shp->shm_cprid, |
900 | shp->shm_lprid, | 891 | shp->shm_lprid, |
901 | is_file_hugepages(shp->shm_file) ? (file_count(shp->shm_file) - 1) : shp->shm_nattch, | 892 | is_file_hugepages(shp->shm_file) ? (file_count(shp->shm_file) - 1) : shp->shm_nattch, |
902 | shp->shm_perm.uid, | 893 | shp->shm_perm.uid, |
903 | shp->shm_perm.gid, | 894 | shp->shm_perm.gid, |
904 | shp->shm_perm.cuid, | 895 | shp->shm_perm.cuid, |
905 | shp->shm_perm.cgid, | 896 | shp->shm_perm.cgid, |
906 | shp->shm_atim, | 897 | shp->shm_atim, |
907 | shp->shm_dtim, | 898 | shp->shm_dtim, |
908 | shp->shm_ctim); | 899 | shp->shm_ctim); |
909 | shm_unlock(shp); | ||
910 | |||
911 | pos += len; | ||
912 | if(pos < offset) { | ||
913 | len = 0; | ||
914 | begin = pos; | ||
915 | } | ||
916 | if(pos > offset + length) | ||
917 | goto done; | ||
918 | } | ||
919 | } | ||
920 | *eof = 1; | ||
921 | done: | ||
922 | up(&shm_ids.sem); | ||
923 | *start = buffer + (offset - begin); | ||
924 | len -= (offset - begin); | ||
925 | if(len > length) | ||
926 | len = length; | ||
927 | if(len < 0) | ||
928 | len = 0; | ||
929 | return len; | ||
930 | } | 900 | } |
931 | #endif | 901 | #endif |