lkml.org 
[lkml]   [1998]   [Jul]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patches in this message
/
Date
From
Subject[PATCH] /proc/ipc

The patch provides /proc/ipc, which reports informations about IPC
resources: shared memory segments, message queues and semaphore arrays.

I've attached two versions, one against 2.1.109 and another against
2.0.35.


Regards,
Dragos.

---------------------------------------------------------------------
Dragos Acostachioaie dragos@iname.com
http://www.arbornet.org/~dragos
Phone: +40-094-564548
---------------------------------------------------------------------
diff -u --recursive --new-file linux-2.1.109/CREDITS linux/CREDITS
--- linux-2.1.109/CREDITS Thu Jul 16 22:35:26 1998
+++ linux/CREDITS Tue Jul 21 09:10:31 1998
@@ -16,6 +16,14 @@
D: and other hacks..
D: Documenting various parts of network subsystem (kernel side)

+N: Dragos Acostachioaie
+E: dragos@iname.com
+W: http://www.arbornet.org/~dragos
+D: /proc/ipc
+S: C. Negri 6, bl. D3
+S: Iasi 6600
+S: Romania
+
N: Werner Almesberger
E: werner.almesberger@lrc.di.epfl.ch
D: dosfs, LILO, some fd features, various other hacks here and there
diff -u --recursive --new-file linux-2.1.109/fs/proc/array.c linux/fs/proc/array.c
--- linux-2.1.109/fs/proc/array.c Fri Jun 26 19:45:54 1998
+++ linux/fs/proc/array.c Tue Jul 21 08:55:59 1998
@@ -1203,6 +1203,9 @@
extern int get_pci_list(char *);
extern int get_md_status (char *);
extern int get_rtc_status (char *);
+#ifdef CONFIG_SYSVIPC
+extern int get_ipc_status(char *);
+#endif
extern int get_locks_status (char *, char **, off_t, int);
extern int get_swaparea_info (char *);
#ifdef CONFIG_ZORRO
@@ -1284,6 +1287,10 @@
#ifdef CONFIG_RTC
case PROC_RTC:
return get_rtc_status(page);
+#endif
+#ifdef CONFIG_SYSVIPC
+ case PROC_IPC:
+ return get_ipc_status(page);
#endif
case PROC_LOCKS:
return get_locks_status(page, start, offset, length);
diff -u --recursive --new-file linux-2.1.109/fs/proc/root.c linux/fs/proc/root.c
--- linux-2.1.109/fs/proc/root.c Sat Jul 11 01:33:37 1998
+++ linux/fs/proc/root.c Tue Jul 21 09:00:04 1998
@@ -596,6 +596,13 @@
0, &proc_array_inode_operations
};
#endif
+#ifdef CONFIG_SYSVIPC
+static struct proc_dir_entry proc_root_ipc = {
+ PROC_IPC, 3, "ipc",
+ S_IFREG | S_IRUGO, 1, 0, 0,
+ 0, &proc_array_inode_operations
+};
+#endif
static struct proc_dir_entry proc_root_locks = {
PROC_LOCKS, 5, "locks",
S_IFREG | S_IRUGO, 1, 0, 0,
@@ -674,6 +681,9 @@
proc_register(&proc_root, &proc_root_cmdline);
#ifdef CONFIG_RTC
proc_register(&proc_root, &proc_root_rtc);
+#endif
+#ifdef CONFIG_SYSVIPC
+ proc_register(&proc_root, &proc_root_ipc);
#endif
proc_register(&proc_root, &proc_root_locks);

diff -u --recursive --new-file linux-2.1.109/include/linux/proc_fs.h linux/include/linux/proc_fs.h
--- linux-2.1.109/include/linux/proc_fs.h Fri Jul 17 01:11:13 1998
+++ linux/include/linux/proc_fs.h Tue Jul 21 09:02:19 1998
@@ -52,6 +52,7 @@
PROC_STRAM,
PROC_SOUND,
PROC_MTRR, /* whether enabled or not */
+ PROC_IPC,
PROC_FS
};

diff -u --recursive --new-file linux-2.1.109/ipc/msg.c linux/ipc/msg.c
--- linux-2.1.109/ipc/msg.c Wed May 6 20:56:06 1998
+++ linux/ipc/msg.c Tue Jul 21 09:03:11 1998
@@ -508,3 +508,30 @@
return err;
}

+#ifdef CONFIG_PROC_FS
+int get_ipc_msg_status(char *buf)
+{
+ char *p;
+ int i;
+ p = buf;
+ p += sprintf(p, "msg: key msqid perms cbytes qnum lspid lrpid uid gid cuid cgid stime rtime ctime\n");
+ for(i = 0; i < MSGMNI; i++)
+ if(msgque[i] != IPC_UNUSED)
+ p += sprintf(p, "%10d %10d %3o %5u %5u %5u %5u %5u %5u %5u %5u %10lu %10lu %10lu\n",
+ msgque[i]->msg_perm.key,
+ findkey(msgque[i]->msg_perm.key),
+ msgque[i]->msg_perm.mode,
+ msgque[i]->msg_cbytes,
+ msgque[i]->msg_qnum,
+ msgque[i]->msg_lspid,
+ msgque[i]->msg_lrpid,
+ msgque[i]->msg_perm.uid,
+ msgque[i]->msg_perm.gid,
+ msgque[i]->msg_perm.cuid,
+ msgque[i]->msg_perm.cgid,
+ msgque[i]->msg_stime,
+ msgque[i]->msg_rtime,
+ msgque[i]->msg_ctime);
+ return p - buf;
+}
+#endif /* CONFIG_PROC_FS */
diff -u --recursive --new-file linux-2.1.109/ipc/sem.c linux/ipc/sem.c
--- linux-2.1.109/ipc/sem.c Wed May 6 20:56:06 1998
+++ linux/ipc/sem.c Tue Jul 21 09:03:39 1998
@@ -752,3 +752,28 @@
}
current->semundo = NULL;
}
+
+#ifdef CONFIG_PROC_FS
+int get_ipc_sem_status(char *buf)
+{
+ char *p;
+ int i;
+ p = buf;
+ p += sprintf(p, "sem: key semid perms nsems uid gid cuid cgid otime ctime\n");
+ for(i = 0; i < SEMMNI; i++)
+ if(semary[i] != IPC_UNUSED)
+ p += sprintf(p, "%10d %10d %3o %5u %5u %5u %5u %5u %10lu %10lu\n",
+ semary[i]->sem_perm.key,
+ findkey(semary[i]->sem_perm.key),
+ semary[i]->sem_perm.mode,
+ semary[i]->sem_nsems,
+ semary[i]->sem_perm.uid,
+ semary[i]->sem_perm.gid,
+ semary[i]->sem_perm.cuid,
+ semary[i]->sem_perm.cgid,
+ semary[i]->sem_otime,
+ semary[i]->sem_ctime
+ );
+ return p - buf;
+}
+#endif /* CONFIG_PROC_FS */
diff -u --recursive --new-file linux-2.1.109/ipc/shm.c linux/ipc/shm.c
--- linux-2.1.109/ipc/shm.c Tue Jun 9 20:34:33 1998
+++ linux/ipc/shm.c Tue Jul 21 09:04:21 1998
@@ -837,3 +837,31 @@
shm_rss--;
return 1;
}
+
+#ifdef CONFIG_PROC_FS
+int get_ipc_shm_status(char *buf)
+{
+ char *p;
+ int i;
+ p = buf;
+ p += sprintf(p, "shm: key shmid perms size cpid lpid nattch uid gid cuid cgid atime dtime ctime\n");
+ for(i = 0; i < SHMMNI; i++)
+ if(shm_segs[i] != IPC_UNUSED)
+ p += sprintf(p, "%10d %10d %3o %10d %5u %5u %5d %5u %5u %5u %5u %10lu %10lu %10lu\n",
+ shm_segs[i]->shm_perm.key,
+ findkey(shm_segs[i]->shm_perm.key),
+ shm_segs[i]->shm_perm.mode,
+ shm_segs[i]->shm_segsz,
+ shm_segs[i]->shm_cpid,
+ shm_segs[i]->shm_lpid,
+ shm_segs[i]->shm_nattch,
+ shm_segs[i]->shm_perm.uid,
+ shm_segs[i]->shm_perm.gid,
+ shm_segs[i]->shm_perm.cuid,
+ shm_segs[i]->shm_perm.cgid,
+ shm_segs[i]->shm_atime,
+ shm_segs[i]->shm_dtime,
+ shm_segs[i]->shm_ctime);
+ return p - buf;
+}
+#endif /* CONFIG_PROC_FS */
diff -u --recursive --new-file linux-2.1.109/ipc/util.c linux/ipc/util.c
--- linux-2.1.109/ipc/util.c Wed May 6 20:56:06 1998
+++ linux/ipc/util.c Tue Jul 21 09:09:50 1998
@@ -6,6 +6,8 @@
* get BSD style process accounting right.
* Occurs in several places in the IPC code.
* Chris Evans, <chris@ferret.lmh.ox.ac.uk>
+ *
+ * /proc/ipc support by Dragos Acostachioaie <dragos@iname.com>
*/

#include <linux/config.h>
@@ -53,6 +55,21 @@

return 0;
}
+
+#ifdef CONFIG_PROC_FS
+int get_ipc_status(char *buf)
+{
+ extern get_ipc_shm_status(char *);
+ extern get_ipc_sem_status(char *);
+ extern get_ipc_msg_status(char *);
+ char *p;
+ p = buf;
+ p += get_ipc_shm_status(p);
+ p += get_ipc_sem_status(p);
+ p += get_ipc_msg_status(p);
+ return p - buf;
+}
+#endif /* CONFIG_PROC_FS */

#else
/*diff -u --recursive --new-file linux-2.0.35/CREDITS linux/CREDITS
--- linux-2.0.35/CREDITS Mon Jul 20 21:24:26 1998
+++ linux/CREDITS Mon Jul 20 19:34:07 1998
@@ -16,6 +16,14 @@
D: and other hacks..
D: Documenting various parts of network subsystem (kernel side)

+N: Dragos Acostachioaie
+E: dragos@iname.com
+W: http://www.arbornet.org/~dragos
+D: /proc/ipc
+S: C. Negri 6, bl. D3
+S: Iasi 6600
+S: Romania
+
N: Werner Almesberger
E: werner.almesberger@lrc.di.epfl.ch
D: dosfs, LILO, some fd features, various other hacks here and there
diff -u --recursive --new-file linux-2.0.35/fs/proc/array.c linux/fs/proc/array.c
--- linux-2.0.35/fs/proc/array.c Mon Jul 20 21:24:38 1998
+++ linux/fs/proc/array.c Sun Jul 19 23:26:15 1998
@@ -981,6 +981,9 @@
#ifdef __SMP_PROF__
extern int get_smp_prof_list(char *);
#endif
+#ifdef CONFIG_SYSVIPC
+extern int get_ipc_status(char *);
+#endif

static int get_root_array(char * page, int type, char **start, off_t offset, int length)
{
@@ -1054,6 +1057,10 @@
#endif
case PROC_LOCKS:
return get_locks_status(page, start, offset, length);
+#ifdef CONFIG_SYSVIPC
+ case PROC_IPC:
+ return get_ipc_status(page);
+#endif
}
return -EBADF;
}
diff -u --recursive --new-file linux-2.0.35/fs/proc/root.c linux/fs/proc/root.c
--- linux-2.0.35/fs/proc/root.c Tue Apr 30 13:09:45 1996
+++ linux/fs/proc/root.c Sun Jul 19 23:09:52 1998
@@ -372,6 +372,12 @@
S_IFREG | S_IRUGO | S_IWUSR, 1, 0, 0,
});
}
+#ifdef CONFIG_SYSVIPC
+ proc_register(&proc_root, &(struct proc_dir_entry) {
+ PROC_IPC, 3, "ipc",
+ S_IFREG | S_IRUGO, 1, 0, 0,
+ });
+#endif
}


diff -u --recursive --new-file linux-2.0.35/include/linux/proc_fs.h linux/include/linux/proc_fs.h
--- linux-2.0.35/include/linux/proc_fs.h Mon Jul 20 21:24:39 1998
+++ linux/include/linux/proc_fs.h Sun Jul 19 23:52:52 1998
@@ -43,7 +43,8 @@
PROC_MTAB,
PROC_MD,
PROC_RTC,
- PROC_LOCKS
+ PROC_LOCKS,
+ PROC_IPC
};

enum pid_directory_inos {
diff -u --recursive --new-file linux-2.0.35/ipc/msg.c linux/ipc/msg.c
--- linux-2.0.35/ipc/msg.c Sun Sep 1 09:15:33 1996
+++ linux/ipc/msg.c Mon Jul 20 19:15:57 1998
@@ -5,6 +5,8 @@
* Kerneld extensions by Bjorn Ekwall <bj0rn@blox.se> in May 1995, and May 1996
*
* See <linux/kerneld.h> for the (optional) new kerneld protocol
+ *
+ * /proc/ipc support by Dragos Acostachioaie <dragos@iname.com>
*/

#include <linux/config.h>
@@ -765,3 +767,31 @@
#endif /* CONFIG_KERNELD */
return status;
}
+
+#ifdef CONFIG_PROC_FS
+int get_ipc_msg_status(char *buf)
+{
+ char *p;
+ int i;
+ p = buf;
+ p += sprintf(p, "msg: key msqid perms cbytes qnum lspid lrpid uid gid cuid cgid stime rtime ctime\n");
+ for(i = 0; i < MSGMNI; i++)
+ if(msgque[i] != IPC_UNUSED)
+ p += sprintf(p, "%10d %10d %3o %5u %5u %5u %5u %5u %5u %5u %5u %10lu %10lu %10lu\n",
+ msgque[i]->msg_perm.key,
+ findkey(msgque[i]->msg_perm.key),
+ msgque[i]->msg_perm.mode,
+ msgque[i]->msg_cbytes,
+ msgque[i]->msg_qnum,
+ msgque[i]->msg_lspid,
+ msgque[i]->msg_lrpid,
+ msgque[i]->msg_perm.uid,
+ msgque[i]->msg_perm.gid,
+ msgque[i]->msg_perm.cuid,
+ msgque[i]->msg_perm.cgid,
+ msgque[i]->msg_stime,
+ msgque[i]->msg_rtime,
+ msgque[i]->msg_ctime);
+ return p - buf;
+}
+#endif /* CONFIG_PROC_FS */
diff -u --recursive --new-file linux-2.0.35/ipc/sem.c linux/ipc/sem.c
--- linux-2.0.35/ipc/sem.c Sun Sep 1 09:15:34 1996
+++ linux/ipc/sem.c Mon Jul 20 19:15:49 1998
@@ -29,6 +29,8 @@
* see a clean way to get the old behavior with the new design.
* The POSIX standard and SVID should be consulted to determine
* what behavior is mandated.
+ *
+ * /proc/ipc support by Dragos Acostachioaie <dragos@iname.com>
*/

#include <linux/errno.h>
@@ -706,3 +708,28 @@
}
current->semundo = NULL;
}
+
+#ifdef CONFIG_PROC_FS
+int get_ipc_sem_status(char *buf)
+{
+ char *p;
+ int i;
+ p = buf;
+ p += sprintf(p, "sem: key semid perms nsems uid gid cuid cgid otime ctime\n");
+ for(i = 0; i < SEMMNI; i++)
+ if(semary[i] != IPC_UNUSED)
+ p += sprintf(p, "%10d %10d %3o %5u %5u %5u %5u %5u %10lu %10lu\n",
+ semary[i]->sem_perm.key,
+ findkey(semary[i]->sem_perm.key),
+ semary[i]->sem_perm.mode,
+ semary[i]->sem_nsems,
+ semary[i]->sem_perm.uid,
+ semary[i]->sem_perm.gid,
+ semary[i]->sem_perm.cuid,
+ semary[i]->sem_perm.cgid,
+ semary[i]->sem_otime,
+ semary[i]->sem_ctime
+ );
+ return p - buf;
+}
+#endif /* CONFIG_PROC_FS */
diff -u --recursive --new-file linux-2.0.35/ipc/shm.c linux/ipc/shm.c
--- linux-2.0.35/ipc/shm.c Thu Jun 4 01:17:50 1998
+++ linux/ipc/shm.c Mon Jul 20 19:15:40 1998
@@ -3,6 +3,8 @@
* Copyright (C) 1992, 1993 Krishna Balasubramanian
* Many improvements/fixes by Bruno Haible.
* Replaced `struct shm_desc' by `struct vm_area_struct', July 1994.
+ *
+ * /proc/ipc support by Dragos Acostachioaie <dragos@iname.com>
*/

#include <linux/errno.h>
@@ -804,3 +806,31 @@
shm_rss--;
return 1;
}
+
+#ifdef CONFIG_PROC_FS
+int get_ipc_shm_status(char *buf)
+{
+ char *p;
+ int i;
+ p = buf;
+ p += sprintf(p, "shm: key shmid perms size cpid lpid nattch uid gid cuid cgid atime dtime ctime\n");
+ for(i = 0; i < SHMMNI; i++)
+ if(shm_segs[i] != IPC_UNUSED)
+ p += sprintf(p, "%10d %10d %3o %10d %5u %5u %5d %5u %5u %5u %5u %10lu %10lu %10lu\n",
+ shm_segs[i]->shm_perm.key,
+ findkey(shm_segs[i]->shm_perm.key),
+ shm_segs[i]->shm_perm.mode,
+ shm_segs[i]->shm_segsz,
+ shm_segs[i]->shm_cpid,
+ shm_segs[i]->shm_lpid,
+ shm_segs[i]->shm_nattch,
+ shm_segs[i]->shm_perm.uid,
+ shm_segs[i]->shm_perm.gid,
+ shm_segs[i]->shm_perm.cuid,
+ shm_segs[i]->shm_perm.cgid,
+ shm_segs[i]->shm_atime,
+ shm_segs[i]->shm_dtime,
+ shm_segs[i]->shm_ctime);
+ return p - buf;
+}
+#endif /* CONFIG_PROC_FS */
diff -u --recursive --new-file linux-2.0.35/ipc/util.c linux/ipc/util.c
--- linux-2.0.35/ipc/util.c Wed Jan 17 07:32:09 1996
+++ linux/ipc/util.c Mon Jul 20 19:16:23 1998
@@ -1,6 +1,8 @@
/*
* linux/ipc/util.c
* Copyright (C) 1992 Krishna Balasubramanian
+ *
+ * /proc/ipc support by Dragos Acostachioaie <dragos@iname.com>
*/

#include <linux/config.h>
@@ -46,6 +48,21 @@
return -1;
return 0;
}
+
+#ifdef CONFIG_PROC_FS
+int get_ipc_status(char *buf)
+{
+ extern get_ipc_shm_status(char *);
+ extern get_ipc_sem_status(char *);
+ extern get_ipc_msg_status(char *);
+ char *p;
+ p = buf;
+ p += get_ipc_shm_status(p);
+ p += get_ipc_sem_status(p);
+ p += get_ipc_msg_status(p);
+ return p - buf;
+}
+#endif /* CONFIG_PROC_FS */

#else
/*
\
 
 \ /
  Last update: 2005-03-22 13:43    [W:0.081 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site