aboutsummaryrefslogtreecommitdiffstats
path: root/ipc/shm.c
diff options
context:
space:
mode:
authorMike Waychison <mikew@google.com>2005-09-06 18:17:10 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-09-07 19:57:26 -0400
commit19b4946ca9d1e35d4c641dcebe27378de34f3ddd (patch)
treeadd66dd24e7a30441bbe26a4cc35e1124434e5b9 /ipc/shm.c
parentae7817745eef3b4ed3c2e36cb403e0c50f17d4e4 (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/shm.c')
-rw-r--r--ipc/shm.c86
1 files changed, 28 insertions, 58 deletions
diff --git a/ipc/shm.c b/ipc/shm.c
index 1d6cf08d950b..dca90489e3b0 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -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);
51static void shm_open (struct vm_area_struct *shmd); 51static void shm_open (struct vm_area_struct *shmd);
52static void shm_close (struct vm_area_struct *shmd); 52static void shm_close (struct vm_area_struct *shmd);
53#ifdef CONFIG_PROC_FS 53#ifdef CONFIG_PROC_FS
54static int sysvipc_shm_read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data); 54static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
55#endif 55#endif
56 56
57size_t shm_ctlmax = SHMMAX; 57size_t shm_ctlmax = SHMMAX;
@@ -63,9 +63,10 @@ static int shm_tot; /* total number of shared memory pages */
63void __init shm_init (void) 63void __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
71static inline int shm_checkid(struct shmid_kernel *s, int id) 72static 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
872static int sysvipc_shm_read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data) 873static 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;
921done:
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