diff options
Diffstat (limited to 'ipc/sem.c')
-rw-r--r-- | ipc/sem.c | 73 |
1 files changed, 23 insertions, 50 deletions
@@ -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 |