summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-12-05 07:24:08 +0000
committerEric Andersen <andersen@codepoet.org>2002-12-05 07:24:08 +0000
commitdeca106b6dad70ad0a1312a82d762aa8d8ad52ba (patch)
treef11db23c430298ac9da2f3de80ec6c86cc75be70 /examples
parent6f9b45b9eff22c664b93ace82d20669340a762f8 (diff)
downloadbusybox-w32-deca106b6dad70ad0a1312a82d762aa8d8ad52ba.tar.gz
busybox-w32-deca106b6dad70ad0a1312a82d762aa8d8ad52ba.tar.bz2
busybox-w32-deca106b6dad70ad0a1312a82d762aa8d8ad52ba.zip
Kill CONFIG_FEATURE_USE_DEVPS_PATCH and the devps patch. I'm not
maintaining it anymore, and it is now terribly out of date. -Erik
Diffstat (limited to 'examples')
-rw-r--r--examples/kernel-patches/Will_devps_GoIntoTheKernel104
-rw-r--r--examples/kernel-patches/devps.patch.9_25_20001478
2 files changed, 0 insertions, 1582 deletions
diff --git a/examples/kernel-patches/Will_devps_GoIntoTheKernel b/examples/kernel-patches/Will_devps_GoIntoTheKernel
deleted file mode 100644
index c541c0f8c..000000000
--- a/examples/kernel-patches/Will_devps_GoIntoTheKernel
+++ /dev/null
@@ -1,104 +0,0 @@
1I have been asked several times whether the devps patch will go into the
2mainline Linux kernel. The following emails from Alan Cox and Linus Torvalds
3make it clear that it is not going to happen. This does not mean this patch
4had no value -- it does. It just means that those that like it get to apply it
5themselves...
6
7 -Erik
8
9
10-------------------------------
11
12From alan@lxorguk.ukuu.org.uk Thu Apr 13 08:07:22 2000
13Return-Path: <alan@lxorguk.ukuu.org.uk>
14Delivered-To: andersen@dillweed.dsl.xmission.com
15Received: from localhost (dillweed.dsl.xmission.com [10.0.0.1])
16 by dillweed.dsl.xmission.com (Postfix) with ESMTP id 1D57A11A4F5
17 for <andersen@dillweed.dsl.xmission.com>; Thu, 13 Apr 2000 08:07:22 -0600 (MDT)
18Envelope-to: andersen@xmission.com
19Received: from mail.xmission.com
20 by localhost with IMAP (fetchmail-5.3.3)
21 for andersen@dillweed.dsl.xmission.com (single-drop); Thu, 13 Apr 2000 08:07:22 -0600 (MDT)
22Received: from [194.168.151.1] (helo=the-village.bc.nu)
23 by mail.xmission.com with esmtp (Exim 3.03 #3)
24 id 12fhQk-0002OZ-00
25 for andersen@xmission.com; Thu, 13 Apr 2000 05:05:03 -0600
26Received: from alan by the-village.bc.nu with local (Exim 2.12 #1)
27 id 12fhQ9-0002nD-00
28 for andersen@xmission.com; Thu, 13 Apr 2000 12:04:25 +0100
29Subject: Re: kernel ps drivers [Was: vm locking question]
30To: andersen@xmission.com
31Date: Thu, 13 Apr 2000 12:04:23 +0100 (BST)
32In-Reply-To: <20000412224130.A2748@xmission.com> from "Erik Andersen" at Apr 12, 2000 10:41:30 PM
33X-Mailer: ELM [version 2.5 PL1]
34MIME-Version: 1.0
35Content-Type: text/plain; charset=us-ascii
36Content-Transfer-Encoding: 7bit
37Message-Id: <E12fhQ9-0002nD-00@the-village.bc.nu>
38From: Alan Cox <alan@lxorguk.ukuu.org.uk>
39Status: RO
40X-Status: A
41Content-Length: 242
42Lines: 6
43
44> On the subject of ps, would you be willing to accept my /dev/ps
45> patch into the kernel? If no, any suggestions on what should
46> be done differently (if anything) to make it worthy of inclusion?
47
48For 2.2.x no, for 2.3.x ask Linus not me
49
50
51From torvalds@transmeta.com Thu Apr 13 09:18:16 2000
52Return-Path: <torvalds@transmeta.com>
53Delivered-To: andersen@dillweed.dsl.xmission.com
54Received: from localhost (dillweed.dsl.xmission.com [10.0.0.1])
55 by dillweed.dsl.xmission.com (Postfix) with ESMTP id 3776411A3DF
56 for <andersen@dillweed.dsl.xmission.com>; Thu, 13 Apr 2000 09:18:16 -0600 (MDT)
57Envelope-to: andersen@xmission.com
58Received: from mail.xmission.com
59 by localhost with IMAP (fetchmail-5.3.3)
60 for andersen@dillweed.dsl.xmission.com (single-drop); Thu, 13 Apr 2000 09:18:16 -0600 (MDT)
61Received: from [209.10.217.66] (helo=neon-gw.transmeta.com)
62 by mail.xmission.com with esmtp (Exim 3.03 #3)
63 id 12flK2-0004dd-00
64 for andersen@xmission.com; Thu, 13 Apr 2000 09:14:22 -0600
65Received: (from root@localhost)
66 by neon-gw.transmeta.com (8.9.3/8.9.3) id IAA18635;
67 Thu, 13 Apr 2000 08:10:51 -0700
68Received: from mailhost.transmeta.com(10.1.1.15) by neon-gw.transmeta.com via smap (V2.1)
69 id xma018629; Thu, 13 Apr 00 08:10:25 -0700
70Received: from penguin.transmeta.com (root@penguin.transmeta.com [10.1.2.202])
71 by deepthought.transmeta.com (8.9.3/8.9.3) with ESMTP id IAA12264;
72 Thu, 13 Apr 2000 08:13:53 -0700 (PDT)
73Received: from localhost (torvalds@localhost) by penguin.transmeta.com (8.9.3/8.7.3) with ESMTP id IAA02051; Thu, 13 Apr 2000 08:13:53 -0700
74X-Authentication-Warning: penguin.transmeta.com: torvalds owned process doing -bs
75Date: Thu, 13 Apr 2000 08:13:53 -0700 (PDT)
76From: Linus Torvalds <torvalds@transmeta.com>
77To: Erik Andersen <andersen@xmission.com>
78Cc: Alan Cox <alan@redhat.com>
79Subject: Re: kernel ps drivers [Was: vm locking question]
80In-Reply-To: <20000413083127.A976@xmission.com>
81Message-ID: <Pine.LNX.4.10.10004130812170.2000-100000@penguin.transmeta.com>
82MIME-Version: 1.0
83Content-Type: TEXT/PLAIN; charset=US-ASCII
84Status: RO
85Content-Length: 659
86Lines: 16
87
88
89
90On Thu, 13 Apr 2000, Erik Andersen wrote:
91>
92> For 2.3.x would you be willing to accept my /dev/ps driver into the kernel?
93> (Assuming I remove the /dev/modules driver (since it was pointed out that there
94> is a perfectly good syscall providing that interface). If no, is there anything
95> that could be done differently (if anything) to make it worthy of inclusion?
96
97I do dislike /dev/ps mightily. If the problem is that /proc is too large,
98then the right solution is to just clean up /proc. Which is getting done.
99And yes, /proc will be larger than /dev/ps, but I still find that
100preferable to having two incompatible ways to do the same thing.
101
102 Linus
103
104
diff --git a/examples/kernel-patches/devps.patch.9_25_2000 b/examples/kernel-patches/devps.patch.9_25_2000
deleted file mode 100644
index 086205cf2..000000000
--- a/examples/kernel-patches/devps.patch.9_25_2000
+++ /dev/null
@@ -1,1478 +0,0 @@
1diff -urN --exclude=.version --exclude=.config* --exclude=.*depend linux-2.2.18-9.virgin/drivers/char/Config.in linux/drivers/char/Config.in
2--- linux-2.2.18-9.virgin/drivers/char/Config.in Mon Sep 18 15:02:30 2000
3+++ linux/drivers/char/Config.in Mon Sep 25 16:33:16 2000
4@@ -56,6 +56,8 @@
5 dep_tristate 'Microgate SyncLink card support' CONFIG_SYNCLINK m
6 dep_tristate 'HDLC line discipline support' CONFIG_N_HDLC m
7 fi
8+tristate 'Devps support' CONFIG_DEVPS
9+tristate 'Devmounts support' CONFIG_DEVMTAB
10 bool 'Unix98 PTY support' CONFIG_UNIX98_PTYS
11 if [ "$CONFIG_UNIX98_PTYS" = "y" ]; then
12 int 'Maximum number of Unix98 PTYs in use (0-2048)' CONFIG_UNIX98_PTY_COUNT 256
13diff -urN --exclude=.version --exclude=.config* --exclude=.*depend linux-2.2.18-9.virgin/drivers/char/Makefile linux/drivers/char/Makefile
14--- linux-2.2.18-9.virgin/drivers/char/Makefile Mon Sep 18 15:02:30 2000
15+++ linux/drivers/char/Makefile Mon Sep 25 18:01:12 2000
16@@ -697,6 +697,22 @@
17 M_OBJS += $(sort $(filter $(module-list), $(obj-m)))
18
19
20+ifeq ($(CONFIG_DEVPS),y)
21+O_OBJS += devps.o
22+else
23+ ifeq ($(CONFIG_DEVPS),m)
24+ M_OBJS += devps.o
25+ endif
26+endif
27+
28+ifeq ($(CONFIG_DEVMTAB),y)
29+O_OBJS += devmtab.o
30+else
31+ ifeq ($(CONFIG_DEVMTAB),m)
32+ M_OBJS += devmtab.o
33+ endif
34+endif
35+
36 include $(TOPDIR)/Rules.make
37
38 fastdep:
39diff -urN --exclude=.version --exclude=.config* --exclude=.*depend linux-2.2.18-9.virgin/drivers/char/devmtab.c linux/drivers/char/devmtab.c
40--- linux-2.2.18-9.virgin/drivers/char/devmtab.c Wed Dec 31 17:00:00 1969
41+++ linux/drivers/char/devmtab.c Mon Sep 25 17:00:57 2000
42@@ -0,0 +1,295 @@
43+/* vi: set sw=8 ts=8: */
44+/*
45+ * linux/drivers/char/devmtab.c
46+ *
47+ * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
48+ *
49+ * May be copied or modified under the terms of the GNU General Public License.
50+ * See linux/COPYING for more information.
51+ *
52+ * This driver implements an interface whereby programs such as mount(8),
53+ * umount(8), and df(1) may obtain all the process information they need to do
54+ * their jobs without needing to use /proc. This driver another step in my
55+ * evil plan to completely dismantle /proc. Muhahahaha!
56+ *
57+ * Suggestions are welcome. Patches that work are more welcome though. ;-)
58+ *
59+ *
60+ * When using this driver, running:
61+ * mknod /dev/mtab c 10 22
62+ * could be considered helpful.
63+ *
64+ * ----------------------------------
65+ * 1.00 Mar 07, 2000 -- Initial version.
66+ *
67+ *************************************************************************/
68+
69+#define DEVMTAB_VERSION "1.00"
70+
71+#include <linux/config.h>
72+#include <linux/module.h>
73+#include <linux/types.h>
74+#include <linux/sched.h>
75+#include <linux/fs.h>
76+#include <linux/mm.h>
77+#include <linux/pagemap.h>
78+#include <linux/malloc.h>
79+#include <linux/miscdevice.h>
80+#include <linux/devmtab.h>
81+#include <linux/wrapper.h>
82+#include <asm/pgtable.h>
83+#include <asm/uaccess.h>
84+
85+
86+/* Some variables used by this device */
87+static struct wait_queue *devmtab_waitq = NULL;
88+static int devmtab_already_opened = 0;
89+static char *mtabfile = NULL;
90+static int mtab_ptr;
91+static int mtab_size;
92+
93+
94+
95+/****************************************************************************
96+ * Handle opening and closing of the device
97+ */
98+
99+static long long
100+devmtab_lseek (struct file *file, long long offset, int orig)
101+{
102+ return -ESPIPE;
103+}
104+
105+static ssize_t
106+devmtab_read (struct file *file, char *buf, size_t count, loff_t * ppos)
107+{
108+ int n = mtab_size - mtab_ptr;
109+
110+ if (mtab_size == 0) {
111+ /* Make some space */
112+ if (!(mtabfile = (char *) get_free_page (GFP_KERNEL)))
113+ return -ENOMEM;
114+ /* Grab the mtab */
115+ get_filesystem_info (mtabfile);
116+ mtab_ptr = 0;
117+ mtab_size = strlen (mtabfile);
118+ n = mtab_size - mtab_ptr;
119+ }
120+
121+ if (n > count)
122+ n = count;
123+ if (n <= 0)
124+ return 0;
125+
126+ if (copy_to_user (buf, mtabfile, n))
127+ return -EFAULT;
128+ mtab_ptr += n;
129+ return n;
130+}
131+
132+static int devmtab_open (struct inode *ip, struct file *fp)
133+{
134+ /* Only let one process use us at any time -- putting other
135+ * processes to sleep. Those opening us O_NONBLOCK will
136+ * get an EAGAIN error */
137+ if ((fp->f_flags & O_NONBLOCK) && devmtab_already_opened)
138+ return -EAGAIN;
139+
140+ MOD_INC_USE_COUNT;
141+
142+ while (devmtab_already_opened) {
143+ int i, got_signal=0;
144+
145+ /* Go to sleep until we get woken up
146+ * by devmtab_close or we receive a signal */
147+ module_interruptible_sleep_on(&devmtab_waitq);
148+
149+ for(i=0; i<_NSIG_WORDS && !got_signal; i++)
150+ got_signal = current->signal.sig[i] & ~current->blocked.sig[i];
151+
152+ /* If we got a signal, decrement the use count
153+ * and return to user space */
154+ if (got_signal) {
155+ MOD_DEC_USE_COUNT;
156+ return -EINTR;
157+ }
158+ }
159+
160+ /* Since we got here, then devmtab_already_opened must equal 0 */
161+ devmtab_already_opened=1;
162+ mtab_ptr = 0;
163+ mtab_size = 0;
164+
165+ return 0;
166+}
167+
168+static int devmtab_release (struct inode *ip, struct file *fp)
169+{
170+ /* Clean up */
171+ if (mtabfile != NULL) {
172+ free_page ((unsigned long) mtabfile);
173+ mtabfile = NULL;
174+ }
175+
176+ /* Zero out the reference counter */
177+ devmtab_already_opened=0;
178+
179+ /* Wake up anybody that is waiting to access this device */
180+ module_wake_up(&devmtab_waitq);
181+
182+ MOD_DEC_USE_COUNT;
183+
184+ return 0;
185+}
186+
187+static int
188+devmtab_ioctl (struct inode *ip, struct file *fp,
189+ unsigned int cmd, unsigned long arg)
190+{
191+ switch (cmd) {
192+ case DEVMTAB_COUNT_FILESYSTEMS:{
193+ return(count_kfstypes());
194+ }
195+
196+ case DEVMTAB_GET_FILESYSTEMS:{
197+ int stat, count;
198+ struct k_fstype* fstypelist;
199+
200+ /* How many are there? */
201+ count = count_kfstypes();
202+
203+ /* Make some space */
204+ fstypelist = (struct k_fstype *)kmalloc(sizeof(struct k_fstype) * count, GFP_KERNEL);
205+ if (!fstypelist)
206+ return -ENOMEM;
207+ memset(fstypelist, 0, sizeof(struct k_fstype) * count);
208+
209+ /* Grab the mtab entries */
210+ get_kfstype_list(count, fstypelist);
211+
212+ /* Make sure there is enough room */
213+ stat = verify_area (VERIFY_WRITE, (struct k_fstype *) arg,
214+ sizeof(struct k_fstype) * count);
215+ if (stat) {
216+ printk (KERN_INFO
217+ "devmtab: Insufficient space was provided.\n");
218+ return stat;
219+ }
220+
221+ /* Send it to user space */
222+ copy_to_user_ret ((struct k_fstype *) arg, fstypelist,
223+ sizeof(struct k_fstype) * count,
224+ -EFAULT);
225+
226+ /* Clean up */
227+ kfree( fstypelist);
228+ return 0;
229+ }
230+
231+ case DEVMTAB_COUNT_MOUNTS:{
232+ return(count_mounted_filesystems());
233+ }
234+
235+ case DEVMTAB_GET_MOUNTS:{
236+ int stat, count;
237+ struct k_mntent* mntentlist;
238+
239+ /* How many are there? */
240+ count = count_mounted_filesystems();
241+
242+ /* Make some space */
243+ mntentlist = (struct k_mntent *)kmalloc(sizeof(struct k_mntent) * count, GFP_KERNEL);
244+ if (!mntentlist)
245+ return -ENOMEM;
246+ memset(mntentlist, 0, sizeof(struct k_mntent) * count);
247+
248+ /* Grab the mtab entries */
249+ get_mtab_entries (count, mntentlist);
250+
251+ /* Make sure there is enough room */
252+ stat = verify_area (VERIFY_WRITE, (void*) arg,
253+ sizeof(struct k_mntent) * count);
254+ if (stat) {
255+ printk (KERN_INFO
256+ "devmtab: Insufficient space was provided.\n");
257+ return stat;
258+ }
259+
260+ /* Send it to user space */
261+ copy_to_user_ret ((struct k_mntent *) arg, mntentlist,
262+ sizeof(struct k_mntent) * count,
263+ -EFAULT);
264+
265+ /* Clean up */
266+ kfree( mntentlist);
267+ return 0;
268+ }
269+
270+ default:
271+ return -EINVAL;
272+
273+ }
274+ return 0;
275+}
276+
277+
278+
279+/****************************************************************************
280+ * Set up the file operations devmtab will support
281+ */
282+static struct file_operations devmtab_fops = {
283+ devmtab_lseek,
284+ devmtab_read,
285+ NULL, /* No write */
286+ NULL, /* No readdir */
287+ NULL, /* No poll */
288+ devmtab_ioctl,
289+ NULL, /* No mmap */
290+ devmtab_open,
291+ NULL, /* flush */
292+ devmtab_release,
293+ NULL, /* fsync */
294+ NULL, /* fasync */
295+ NULL, /* check_media_change */
296+ NULL /* revalidate */
297+};
298+
299+static struct miscdevice devmtab_misc_dev = {
300+ DEVMTAB_MINOR,
301+ "devmtab",
302+ &devmtab_fops
303+};
304+
305+/* The real driver initialization function */
306+extern int devmtab_init (void)
307+{
308+ printk (KERN_INFO "devmtab: driver %s loaded\n", DEVMTAB_VERSION);
309+
310+ if (misc_register (&devmtab_misc_dev)) {
311+ printk ("devmtab: can't register misc device %d\n",
312+ DEVMTAB_MINOR);
313+ return -EIO;
314+ }
315+
316+ return 0;
317+}
318+
319+#ifdef MODULE
320+
321+MODULE_AUTHOR ("Erik Andersen <andersee@debian.org>");
322+MODULE_DESCRIPTION
323+ ("devmtab driver -- exports filesystem and mount information to user space");
324+
325+/* Stub driver initialization function */
326+int init_module (void)
327+{
328+ return (devmtab_init ());
329+}
330+
331+void cleanup_module (void)
332+{
333+ printk (KERN_INFO "devmtab: driver unloaded\n");
334+ misc_deregister (&devmtab_misc_dev);
335+}
336+
337+#endif /* MODULE */
338diff -urN --exclude=.version --exclude=.config* --exclude=.*depend linux-2.2.18-9.virgin/drivers/char/devps.c linux/drivers/char/devps.c
339--- linux-2.2.18-9.virgin/drivers/char/devps.c Wed Dec 31 17:00:00 1969
340+++ linux/drivers/char/devps.c Mon Sep 25 17:00:57 2000
341@@ -0,0 +1,518 @@
342+/* vi: set sw=8 ts=8: */
343+/*
344+ * linux/drivers/char/devps.c
345+ *
346+ * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
347+ *
348+ * May be copied or modified under the terms of the GNU General Public License.
349+ * See linux/COPYING for more information.
350+ *
351+ * This driver implements an interface whereby programs such as ps(1), top(1),
352+ * killall(1) and the like may obtain all the process information they need to
353+ * do their jobs. Now you may ask, "Why not use /proc? BSD uses /proc.".
354+ * Thanks for asking. /proc is designed as a virtual filesystem. As such it
355+ * presents all of its information in a nice, human readable format. But not
356+ * human readable enough that mere mortals can actually look at the /proc
357+ * information and know what is happening on their computer (which is why we
358+ * have nice programs like ps(1) to help us out. Additionally, for ps (using
359+ * /proc) to do its job, it has to do something like:
360+ *
361+ * dir = opendir("/proc");
362+ * while ((entry = readdir(dir)) != NULL) {
363+ * if (!isdigit(*entry->d_name))
364+ * continue;
365+ * open_lots_of files();
366+ * parse_lots_of_strings();
367+ * close_lots_of_files();
368+ * print_stuff();
369+ * }
370+ *
371+ *
372+ * This is bad, because:
373+ *
374+ * 1) opening and closing lots of files is slow,
375+ *
376+ * 2) parsing lots of strings is slow,
377+ *
378+ * 3) every one of those strings had to be carefully printed out and formatted
379+ * by the kernel, which is slow,
380+ *
381+ * 4) using a virtual filesystem is not the traditional UN*X solution to
382+ * getting information from the kernel out to userspace (ioctls and syscalls
383+ * are the established way to do this), and worst of all
384+ *
385+ * 5) having a virtual filesystem around has been so inviting that everyone has
386+ * put their own weird little files into it, causing /proc to become a
387+ * cluttered rubbish heap of 64 flavors of strange that takes a ridiculous
388+ * amount of memory.
389+ *
390+ * This driver is the first step in my evil plan to completely
391+ * dismantle /proc. Muhahahaha!
392+ *
393+ * Suggestions are welcome. Patches that work are more welcome though. ;-)
394+ *
395+ * When using this driver, running:
396+ * mknod /dev/ps c 10 21
397+ * could be considered helpful.
398+ *
399+ * ----------------------------------
400+ * 1.00 Mar 07, 2000 -- Initial version.
401+ *
402+ *
403+ * TODO
404+ * ----------------------------------
405+ *
406+ * * Right now none of the vm or fd info is being returned to user space.
407+ * * There is probably other stuff that should be exported to user space.
408+ *
409+ *
410+ *************************************************************************/
411+
412+#define DEVPS_VERSION "1.00"
413+
414+#include <linux/config.h>
415+#include <linux/module.h>
416+#include <linux/types.h>
417+#include <linux/sched.h>
418+#include <linux/fs.h>
419+#include <linux/mm.h>
420+#include <linux/pagemap.h>
421+#include <linux/malloc.h>
422+#include <linux/miscdevice.h>
423+#include <linux/devps.h>
424+#include <linux/wrapper.h>
425+#include <asm/pgtable.h>
426+#include <asm/uaccess.h>
427+
428+/* Some variables used by this device */
429+static struct wait_queue *devps_waitq = NULL;
430+static int devps_already_opened = 0;
431+
432+/****************************************************************************
433+ * Handle opening and closing of the device
434+ */
435+
436+static int devps_open (struct inode *ip, struct file *fp)
437+{
438+ /* Only let one process use us at any time -- putting other
439+ * processes to sleep. Those opening us O_NONBLOCK will
440+ * get an EAGAIN error */
441+ if ((fp->f_flags & O_NONBLOCK) && devps_already_opened)
442+ return -EAGAIN;
443+
444+ MOD_INC_USE_COUNT;
445+
446+ while (devps_already_opened) {
447+ int i, got_signal=0;
448+
449+ /* Go to sleep until we get woken up
450+ * by devps_close or we receive a signal */
451+ module_interruptible_sleep_on(&devps_waitq);
452+
453+ for(i=0; i<_NSIG_WORDS && !got_signal; i++)
454+ got_signal = current->signal.sig[i] & ~current->blocked.sig[i];
455+
456+ /* If we got a signal, decrement the use count
457+ * and return to user space */
458+ if (got_signal) {
459+ MOD_DEC_USE_COUNT;
460+ return -EINTR;
461+ }
462+ }
463+
464+ /* Since we got here, then device_already_opened must equal 0 */
465+ devps_already_opened=1;
466+ return 0;
467+}
468+
469+static int devps_release (struct inode *ip, struct file *fp)
470+{
471+ /* Zero out the reference counter */
472+ devps_already_opened=0;
473+
474+ /* Wake up anybody that is waiting to access this device */
475+ module_wake_up(&devps_waitq);
476+
477+ MOD_DEC_USE_COUNT;
478+ return 0;
479+}
480+
481+
482+/*
483+ * This pretty-prints the pathname of a dentry,
484+ * clarifying sockets etc.
485+ */
486+static int
487+get_name_from_dentry (struct dentry *dentry, char *buffer, int buflen)
488+{
489+ struct inode *inode;
490+ char *tmp = (char *) __get_free_page (GFP_KERNEL), *path, *pattern;
491+ int len;
492+
493+ if (tmp == NULL)
494+ return -ENOMEM;
495+
496+ /* Check for special dentries.. */
497+ pattern = NULL;
498+ inode = dentry->d_inode;
499+ if (inode && dentry->d_parent == dentry) {
500+ if (S_ISSOCK (inode->i_mode))
501+ pattern = "socket:[%lu]";
502+ if (S_ISFIFO (inode->i_mode))
503+ pattern = "pipe:[%lu]";
504+ }
505+
506+ if (pattern) {
507+ len = sprintf (tmp, pattern, inode->i_ino);
508+ path = tmp;
509+ } else {
510+ path = d_path (dentry, tmp, PAGE_SIZE);
511+ len = tmp + PAGE_SIZE - 1 - path;
512+ }
513+
514+ if (len < buflen)
515+ buflen = len;
516+ dput (dentry);
517+ strncpy (buffer, path, buflen);
518+ free_page ((unsigned long) tmp);
519+ return buflen;
520+}
521+
522+static unsigned long get_phys_addr (struct task_struct *p,
523+ unsigned long ptr)
524+{
525+ pgd_t *page_dir;
526+ pmd_t *page_middle;
527+ pte_t pte;
528+
529+ if (!p || !p->mm || ptr >= TASK_SIZE)
530+ return 0;
531+ /* Check for NULL pgd .. shouldn't happen! */
532+ if (!p->mm->pgd) {
533+ printk ("get_phys_addr: pid %d has NULL pgd!\n", p->pid);
534+ return 0;
535+ }
536+
537+ page_dir = pgd_offset (p->mm, ptr);
538+ if (pgd_none (*page_dir))
539+ return 0;
540+ if (pgd_bad (*page_dir)) {
541+ printk ("bad page directory entry %08lx\n",
542+ pgd_val (*page_dir));
543+ pgd_clear (page_dir);
544+ return 0;
545+ }
546+ page_middle = pmd_offset (page_dir, ptr);
547+ if (pmd_none (*page_middle))
548+ return 0;
549+ if (pmd_bad (*page_middle)) {
550+ printk ("bad page middle entry %08lx\n",
551+ pmd_val (*page_middle));
552+ pmd_clear (page_middle);
553+ return 0;
554+ }
555+ pte = *pte_offset (page_middle, ptr);
556+ if (!pte_present (pte))
557+ return 0;
558+ return pte_page (pte) + (ptr & ~PAGE_MASK);
559+}
560+
561+static int get_array (struct task_struct *p, unsigned long start,
562+ unsigned long end, char *buffer)
563+{
564+ unsigned long addr;
565+ int size = 0, result = 0;
566+ char c;
567+
568+ if (start >= end)
569+ return result;
570+ for (;;) {
571+ addr = get_phys_addr (p, start);
572+ if (!addr)
573+ return result;
574+ do {
575+ c = *(char *) addr;
576+ if (!c)
577+ result = size;
578+ if (size < PAGE_SIZE)
579+ buffer[size++] = c;
580+ else
581+ return result;
582+ addr++;
583+ start++;
584+ if (!c && start >= end)
585+ return result;
586+ } while (addr & ~PAGE_MASK);
587+ }
588+ return result;
589+}
590+
591+static int
592+devps_ioctl (struct inode *ip, struct file *fp,
593+ unsigned int cmd, unsigned long arg)
594+{
595+ switch (cmd) {
596+
597+ /* Count up the total number of processes,
598+ * and then return that total */
599+ case DEVPS_GET_NUM_PIDS:{
600+ struct task_struct *p;
601+ pid_t num_pids = 0;
602+
603+ read_lock (&tasklist_lock);
604+ for_each_task (p) {
605+ if (!p->pid)
606+ continue;
607+ num_pids++;
608+ }
609+ read_unlock (&tasklist_lock);
610+
611+ copy_to_user_ret ((pid_t *) arg, &num_pids,
612+ sizeof (num_pids), -EFAULT);
613+ return 0;
614+ }
615+
616+ /* Returns an array containing all current pids, where
617+ pidlist[0]=number of PIDs in the array. pidlist[0] also
618+ specifies the size of the array for the kernel to
619+ fill... */
620+ case DEVPS_GET_PID_LIST:{
621+ struct task_struct *p;
622+ pid_t *pid_array = NULL;
623+ pid_t num_pids;
624+ int stat;
625+
626+ /* Grab the first element to see how many * entries
627+ they want us to fill */
628+ stat = verify_area (VERIFY_READ, (char *) arg,
629+ sizeof (pid_t));
630+ if (stat) {
631+ printk (KERN_INFO
632+ "devps: can't tell how many "
633+ "to pid's to write.\n");
634+ return stat;
635+ }
636+
637+ copy_from_user (&num_pids, (void *) arg,
638+ sizeof (num_pids));
639+
640+ /* Now make sure we can write the specified amount
641+ of stuff into the array. If we can't we might
642+ as well quit now and save ourselves the bother. */
643+ stat = verify_area (VERIFY_WRITE, (char *) arg,
644+ sizeof (pid_t) * num_pids);
645+ if (stat) {
646+ printk (KERN_INFO
647+ "devps: Insufficient space was "
648+ "provided to write %d pid's.\n",
649+ num_pids);
650+ return stat;
651+ }
652+
653+ /* Allocate some memory to hold this stuff in before
654+ * we copy it out to user-space */
655+ pid_array = (pid_t *) kmalloc (num_pids *
656+ sizeof (pid_t),
657+ GFP_KERNEL);
658+ if (pid_array == NULL)
659+ return -ENOMEM;
660+
661+ /* Now march through the PID list */
662+ pid_array[0] = 0;
663+ read_lock (&tasklist_lock);
664+ for_each_task (p) {
665+ if (!p->pid)
666+ continue;
667+ (pid_array[0])++;
668+ if (pid_array[0] >= (num_pids - 1))
669+ continue;
670+ pid_array[pid_array[0]] = p->pid;
671+ }
672+ read_unlock (&tasklist_lock);
673+
674+ /* Copy out to the user the number we actually filled
675+ */
676+ copy_to_user_ret ((void *) arg, pid_array,
677+ sizeof (pid_t) * pid_array[0],
678+ -EFAULT);
679+ kfree (pid_array);
680+
681+ return 0;
682+ }
683+
684+ /* Find the details on a particular pid, and fill out a
685+ struct with all the gory details. */
686+ case DEVPS_GET_PID_INFO:{
687+ struct task_struct *p;
688+ struct pid_info mypidinfo;
689+ unsigned int state;
690+ /* 'R' running */
691+ /* 'S' sleeping */
692+ /* 'D' disk sleep */
693+ /* 'Z' zombie */
694+ /* 'T' stopped */
695+ /* 'W' paging */
696+ const char *state_string = "RSDZTW";
697+
698+ copy_from_user_ret (&mypidinfo,
699+ (struct pid_info *) arg,
700+ sizeof (mypidinfo), -EFAULT);
701+
702+ read_lock (&tasklist_lock);
703+ p = find_task_by_pid (mypidinfo.pid);
704+ read_unlock (&tasklist_lock);
705+
706+ /* Now copy all this crap so we can tell user space
707+ all about it. ick. */
708+ memset (mypidinfo.name, 0,
709+ sizeof (mypidinfo.name));
710+ strcpy (mypidinfo.name, p->comm);
711+ mypidinfo.flags = p->flags;
712+ mypidinfo.pgrp = p->pgrp;
713+ mypidinfo.tms_cutime = p->times.tms_cutime;
714+ mypidinfo.tms_cstime = p->times.tms_cstime;
715+ mypidinfo.tms_utime = p->times.tms_utime;
716+ mypidinfo.tms_stime = p->times.tms_stime;
717+ mypidinfo.min_flt = p->min_flt;
718+ mypidinfo.cmin_flt = p->cmin_flt;
719+ mypidinfo.maj_flt = p->maj_flt;
720+ mypidinfo.cmaj_flt = p->cmaj_flt;
721+ mypidinfo.session = p->session;
722+ mypidinfo.pid = p->pid;
723+ mypidinfo.ppid = p->p_pptr->pid;
724+ mypidinfo.tty =
725+ p->tty ? kdev_t_to_nr (p->tty->device) : 0;
726+ mypidinfo.start_time = p->start_time;
727+ mypidinfo.uid = p->uid;
728+ mypidinfo.euid = p->euid;
729+ mypidinfo.suid = p->suid;
730+ mypidinfo.fsuid = p->fsuid;
731+ mypidinfo.gid = p->gid;
732+ mypidinfo.egid = p->egid;
733+ mypidinfo.sgid = p->sgid;
734+ mypidinfo.fsgid = p->fsgid;
735+ mypidinfo.priority = 20 - (p->counter * 10 +
736+ DEF_PRIORITY / 2) / DEF_PRIORITY;
737+ mypidinfo.nice = 20 - (mypidinfo.priority * 20 +
738+ DEF_PRIORITY / 2) / DEF_PRIORITY;
739+ state = p-> state & (TASK_RUNNING | TASK_INTERRUPTIBLE
740+ | TASK_UNINTERRUPTIBLE |
741+ TASK_ZOMBIE | TASK_STOPPED |
742+ TASK_SWAPPING);
743+ while (state) {
744+ state_string++;
745+ state >>= 1;
746+ }
747+ mypidinfo.state = *state_string;
748+ mypidinfo.processor = p->processor;
749+ mypidinfo.nswap = p->nswap;
750+ mypidinfo.cnswap = p->cnswap;
751+ if (p && p->mm) {
752+ char *page = NULL;
753+
754+ /* Look for some elbow room */
755+ if (!(page = (char*)get_free_page (GFP_KERNEL)))
756+ return -ENOMEM;
757+ /* Grab the command line */
758+ get_array (p, p->mm->arg_start,
759+ p->mm->arg_end, page);
760+ memcpy( mypidinfo.command_line, page, sizeof( mypidinfo.command_line));
761+ mypidinfo.command_line[sizeof( mypidinfo.command_line)-1]='\0';
762+
763+ /* Grab the environment */
764+ memset (page, 0, PAGE_SIZE);
765+ get_array (p, p->mm->env_start,
766+ p->mm->env_end, page);
767+ memcpy( mypidinfo.environment, page, sizeof( mypidinfo.environment));
768+ mypidinfo.command_line[sizeof( mypidinfo.environment)-1]='\0';
769+ free_page ((unsigned long) page);
770+ }
771+ memset (mypidinfo.cwd, 0, sizeof (mypidinfo.cwd));
772+ get_name_from_dentry (dget (p->fs->pwd), mypidinfo.cwd,
773+ sizeof (mypidinfo.cwd));
774+ memset (mypidinfo.root, 0, sizeof (mypidinfo.root));
775+ get_name_from_dentry (dget (p->fs->root),
776+ mypidinfo.root,
777+ sizeof (mypidinfo.root));
778+
779+ copy_to_user_ret ((struct pid_info *) arg,
780+ &mypidinfo, sizeof (mypidinfo),
781+ -EFAULT);
782+
783+ return 0;
784+ }
785+
786+ /* Return the PID of the current process */
787+ case DEVPS_GET_CURRENT_PID:{
788+ return current->pid;
789+ }
790+
791+ default:
792+ return -EINVAL;
793+
794+ }
795+ return 0;
796+}
797+
798+
799+
800+/****************************************************************************
801+ * Set up the file operations devps will support
802+ */
803+static struct file_operations devps_fops = {
804+ NULL, /* No lseek */
805+ NULL, /* No read */
806+ NULL, /* No write */
807+ NULL, /* No readdir */
808+ NULL, /* No poll */
809+ devps_ioctl,
810+ NULL, /* No mmap */
811+ devps_open,
812+ NULL, /* flush */
813+ devps_release,
814+ NULL, /* fsync */
815+ NULL, /* fasync */
816+ NULL, /* check_media_change */
817+ NULL /* revalidate */
818+};
819+
820+static struct miscdevice devps_misc_dev = {
821+ DEVPS_MINOR,
822+ "devps",
823+ &devps_fops
824+};
825+
826+/* The real driver initialization function */
827+extern int devps_init (void)
828+{
829+ printk (KERN_INFO "devps driver %s loaded\n", DEVPS_VERSION);
830+
831+ if (misc_register (&devps_misc_dev)) {
832+ printk ("devps: unable to get misc device %d\n",
833+ DEVPS_MINOR);
834+ return -EIO;
835+ }
836+
837+ return 0;
838+}
839+
840+#ifdef MODULE
841+
842+MODULE_AUTHOR ("Erik Andersen <andersee@debian.org>");
843+MODULE_DESCRIPTION
844+ ("devps driver -- exports kernel process information to user space");
845+
846+
847+/* Stub driver initialization function */
848+int init_module (void)
849+{
850+ return (devps_init ());
851+}
852+
853+void cleanup_module (void)
854+{
855+ printk (KERN_INFO "devps driver unloaded\n");
856+ misc_deregister (&devps_misc_dev);
857+}
858+
859+#endif /* endif MODULE */
860diff -urN --exclude=.version --exclude=.config* --exclude=.*depend linux-2.2.18-9.virgin/drivers/char/makedevps.sh linux/drivers/char/makedevps.sh
861--- linux-2.2.18-9.virgin/drivers/char/makedevps.sh Wed Dec 31 17:00:00 1969
862+++ linux/drivers/char/makedevps.sh Mon Sep 25 17:00:57 2000
863@@ -0,0 +1,5 @@
864+#!/bin/sh -x
865+
866+gcc -Wall -g -I /usr/src/linux/include ps-devps.c -o ps-devps
867+gcc -Wall -g -I /usr/src/linux/include mounts.c -o mounts
868+
869diff -urN --exclude=.version --exclude=.config* --exclude=.*depend linux-2.2.18-9.virgin/drivers/char/misc.c linux/drivers/char/misc.c
870--- linux-2.2.18-9.virgin/drivers/char/misc.c Mon Sep 18 15:02:31 2000
871+++ linux/drivers/char/misc.c Mon Sep 25 17:00:57 2000
872@@ -85,6 +85,8 @@
873 extern int pmu_device_init(void);
874 extern int tosh_init(void);
875 extern int rng_init(void);
876+extern int devps_init(void);
877+extern int devmtab_init(void);
878
879 static int misc_read_proc(char *buf, char **start, off_t offset,
880 int len, int *eof, void *private)
881@@ -268,6 +270,12 @@
882 #endif
883 #ifdef CONFIG_PMAC_PBOOK
884 pmu_device_init();
885+#endif
886+#ifdef CONFIG_DEVPS
887+ devps_init();
888+#endif
889+#ifdef CONFIG_DEVMTAB
890+ devmtab_init();
891 #endif
892 #ifdef CONFIG_SGI_NEWPORT_GFX
893 gfx_register ();
894diff -urN --exclude=.version --exclude=.config* --exclude=.*depend linux-2.2.18-9.virgin/drivers/char/mounts.c linux/drivers/char/mounts.c
895--- linux-2.2.18-9.virgin/drivers/char/mounts.c Wed Dec 31 17:00:00 1969
896+++ linux/drivers/char/mounts.c Mon Sep 25 17:00:57 2000
897@@ -0,0 +1,116 @@
898+/* vi: set sw=4 ts=4: */
899+/*
900+ * devmtab tester
901+ *
902+ *
903+ * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
904+ *
905+ * This program is free software; you can redistribute it and/or modify
906+ * it under the terms of the GNU General Public License as published by
907+ * the Free Software Foundation; either version 2 of the License, or
908+ * (at your option) any later version.
909+ *
910+ * This program is distributed in the hope that it will be useful,
911+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
912+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
913+ * General Public License for more details.
914+ *
915+ * You should have received a copy of the GNU General Public License
916+ * along with this program; if not, write to the Free Software
917+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
918+ *
919+ */
920+
921+#include <stdio.h>
922+#include <stdlib.h>
923+#include <errno.h>
924+#include <string.h>
925+#include <unistd.h>
926+#include <time.h>
927+#include <fcntl.h>
928+#include <sys/ioctl.h>
929+#include <sys/types.h>
930+#include <linux/devmtab.h>
931+
932+
933+int main (int argc, char **argv)
934+{
935+ char device[80] = "/dev/mtab";
936+ int fd; /* file descriptor for devmtab device */
937+ int i, numfilesystems;
938+ struct k_fstype *fslist;
939+ struct k_mntent *mntentlist;
940+
941+ if (argc > 1 && **(argv + 1) == '-') {
942+ fprintf(stderr, "Usage: mounts\n\nReport mounted stuff\n\nThis version of mounts accepts no options.\n\n");
943+ exit(1);
944+ }
945+
946+ /* open device */
947+ if ((fd = open(device, O_RDONLY)) < 0) {
948+ fprintf (stderr, "open failed for `%s': %s\n",
949+ device, strerror (errno));
950+ exit (1);
951+ }
952+
953+ /* How many filesystems? We need to know to allocate
954+ * enough space for later... */
955+ numfilesystems = ioctl (fd, DEVMTAB_COUNT_FILESYSTEMS);
956+ if (numfilesystems<0) {
957+ fprintf (stderr, "\nDEVMTAB_COUNT_FILESYSTEMS: %s\n",
958+ strerror (errno));
959+ exit (1);
960+ }
961+ fslist = (struct k_fstype *) calloc ( numfilesystems, sizeof(struct k_fstype));
962+
963+ /* Grab the list of available filesystems */
964+ if (ioctl (fd, DEVMTAB_GET_FILESYSTEMS, fslist)<0) {
965+ fprintf (stderr, "\nDEVMTAB_GET_FILESYSTEMS: %s\n",
966+ strerror (errno));
967+ exit (1);
968+ }
969+ fprintf( stdout, "\nEquivalent of /proc/filesystems:\n");
970+ for( i = 0 ; i < numfilesystems ; i++) {
971+ fprintf( stdout, "%s%s\n", fslist[i].mnt_type,
972+ (fslist[i].mnt_nodev)? " nodev" : "");
973+ }
974+
975+
976+ /* How many mounted filesystems? We need to know to
977+ * allocate enough space for later... */
978+ numfilesystems = ioctl (fd, DEVMTAB_COUNT_MOUNTS);
979+ if (numfilesystems<0) {
980+ fprintf (stderr, "\nDEVMTAB_COUNT_MOUNTS: %s\n",
981+ strerror (errno));
982+ exit (1);
983+ }
984+ mntentlist = (struct k_mntent *) calloc ( numfilesystems, sizeof(struct k_mntent));
985+
986+ /* Grab the list of mounted filesystems */
987+ if (ioctl (fd, DEVMTAB_GET_MOUNTS, mntentlist)<0) {
988+ fprintf (stderr, "\nDEVMTAB_GET_MOUNTS: %s\n",
989+ strerror (errno));
990+ exit (1);
991+ }
992+
993+ fprintf( stdout, "\nEquivalent of /proc/mounts:\n");
994+ for( i = 0 ; i < numfilesystems ; i++) {
995+ fprintf( stdout, "%s %s %s %s %d %d\n", mntentlist[i].mnt_fsname,
996+ mntentlist[i].mnt_dir, mntentlist[i].mnt_type,
997+ mntentlist[i].mnt_opts, mntentlist[i].mnt_freq,
998+ mntentlist[i].mnt_passno);
999+ }
1000+
1001+
1002+ /* clean up */
1003+ free( fslist);
1004+ free( mntentlist);
1005+ if (close (fd) != 0) {
1006+ fprintf (stderr, "close failed for `%s': %s\n",
1007+ device, strerror (errno));
1008+ exit (1);
1009+ }
1010+
1011+ exit (0);
1012+}
1013+
1014diff -urN --exclude=.version --exclude=.config* --exclude=.*depend linux-2.2.18-9.virgin/drivers/char/ps-devps.c linux/drivers/char/ps-devps.c
1015--- linux-2.2.18-9.virgin/drivers/char/ps-devps.c Wed Dec 31 17:00:00 1969
1016+++ linux/drivers/char/ps-devps.c Mon Sep 25 17:32:19 2000
1017@@ -0,0 +1,148 @@
1018+/* vi: set sw=4 ts=4: */
1019+/*
1020+ * Mini ps implementation for use with the Linux devps driver
1021+ *
1022+ *
1023+ * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
1024+ *
1025+ * This program is free software; you can redistribute it and/or modify
1026+ * it under the terms of the GNU General Public License as published by
1027+ * the Free Software Foundation; either version 2 of the License, or
1028+ * (at your option) any later version.
1029+ *
1030+ * This program is distributed in the hope that it will be useful,
1031+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1032+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1033+ * General Public License for more details.
1034+ *
1035+ * You should have received a copy of the GNU General Public License
1036+ * along with this program; if not, write to the Free Software
1037+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1038+ *
1039+ */
1040+
1041+#include <stdio.h>
1042+#include <stdlib.h>
1043+#include <errno.h>
1044+#include <string.h>
1045+#include <unistd.h>
1046+#include <time.h>
1047+#include <fcntl.h>
1048+#include <sys/ioctl.h>
1049+#include <linux/devps.h>
1050+#include <pwd.h>
1051+#include <grp.h>
1052+#include <sys/types.h>
1053+
1054+
1055+#define MAX_COLUMN 79
1056+
1057+int
1058+main (int argc, char **argv)
1059+{
1060+ char device[80] = "/dev/ps";
1061+ int i, j, len;
1062+ int fd; /* file descriptor for devps device */
1063+ int status; /* return status for system calls */
1064+ pid_t num_pids;
1065+ pid_t* pid_array = NULL;
1066+ struct pid_info info;
1067+ struct passwd *pwd;
1068+ struct group *grp;
1069+ char uidName[10] = "";
1070+ char groupName[10] = "";
1071+
1072+ if (argc > 1 && **(argv + 1) == '-') {
1073+ fprintf(stderr, "Usage: ps-devps\n\nReport process status\n\nThis version of ps accepts no options.\n\n");
1074+ exit(1);
1075+ }
1076+
1077+ /* open device */
1078+ //fd = open(device, O_RDWR);
1079+ fd = open(device, O_RDONLY);
1080+ if (fd < 0) {
1081+ fprintf (stderr, "open failed for `%s': %s\n",
1082+ device, strerror (errno));
1083+ goto error;
1084+ }
1085+
1086+ /* Find out how many processes there are */
1087+ status = ioctl (fd, DEVPS_GET_NUM_PIDS, &num_pids);
1088+ if (status<0) {
1089+ fprintf (stderr, "\nDEVPS_GET_PID_LIST: %s\n",
1090+ strerror (errno));
1091+ goto error;
1092+ }
1093+
1094+ /* Allocate some memory -- grab a few extras just in case
1095+ * some new processes start up while we wait. The kernel will
1096+ * just ignore any extras if we give it too many, and will trunc.
1097+ * the list if we give it too few. */
1098+ pid_array = (pid_t*) calloc( num_pids+10, sizeof(pid_t));
1099+ pid_array[0] = num_pids+10;
1100+
1101+ /* Now grab the pid list */
1102+ status = ioctl (fd, DEVPS_GET_PID_LIST, pid_array);
1103+ if (status<0) {
1104+ fprintf (stderr, "\nDEVPS_GET_PID_LIST: %s\n",
1105+ strerror (errno));
1106+ goto error;
1107+ }
1108+
1109+ /* Print up a ps listing */
1110+ fprintf(stdout, "%5s %-8s %-3s %5s %s\n", "PID", "Uid", "Gid",
1111+ "State", "Command");
1112+
1113+ for (i=1; i<pid_array[0] ; i++) {
1114+ info.pid = pid_array[i];
1115+ status = ioctl (fd, DEVPS_GET_PID_INFO, &info);
1116+ if (status<0) {
1117+ fprintf (stderr, "\nDEVPS_GET_PID_INFO: %s\n",
1118+ strerror (errno));
1119+ goto error;
1120+ }
1121+ /* Make some adjustments as needed */
1122+ pwd = getpwuid(info.euid);
1123+ if (pwd == NULL)
1124+ sprintf(uidName, "%lu", info.euid);
1125+ else
1126+ sprintf(uidName, "%s", pwd->pw_name);
1127+ grp = getgrgid(info.egid);
1128+ if (grp == NULL)
1129+ sprintf(groupName, "%lu", info.egid);
1130+ else
1131+ sprintf(groupName, "%s", grp->gr_name);
1132+
1133+ len = fprintf(stdout, "%5d %-8s %-8s %c ", info.pid, uidName, groupName, info.state);
1134+
1135+ if (strlen(info.command_line) > 1) {
1136+ for( j=0; j<(sizeof(info.command_line)-1) && j < (MAX_COLUMN-len); j++) {
1137+ if (*(info.command_line+j) == '\0' && *(info.command_line+j+1) != '\0') {
1138+ *(info.command_line+j) = ' ';
1139+ }
1140+ }
1141+ *(info.command_line+j) = '\0';
1142+ fprintf(stdout, "%s\n", info.command_line);
1143+ } else {
1144+ fprintf(stdout, "[%s]\n", info.name);
1145+ }
1146+ }
1147+
1148+ /* Free memory */
1149+ free( pid_array);
1150+
1151+ /* close device */
1152+ status = close (fd);
1153+ if (status != 0) {
1154+ fprintf (stderr, "close failed for `%s': %s\n",
1155+ device, strerror (errno));
1156+ goto error;
1157+ }
1158+
1159+ exit (0);
1160+error:
1161+ fflush(stdout);
1162+ fflush(stderr);
1163+ exit (1);
1164+}
1165+
1166diff -urN --exclude=.version --exclude=.config* --exclude=.*depend linux-2.2.18-9.virgin/fs/Makefile linux/fs/Makefile
1167--- linux-2.2.18-9.virgin/fs/Makefile Wed Aug 25 18:29:49 1999
1168+++ linux/fs/Makefile Mon Sep 25 16:33:16 2000
1169@@ -11,9 +11,10 @@
1170 L_OBJS = $(join $(SUB_DIRS),$(SUB_DIRS:%=/%.o))
1171 O_TARGET := fs.o
1172 O_OBJS = open.o read_write.o devices.o file_table.o buffer.o \
1173- super.o block_dev.o stat.o exec.o pipe.o namei.o fcntl.o \
1174+ block_dev.o stat.o exec.o pipe.o namei.o fcntl.o \
1175 ioctl.o readdir.o select.o fifo.o locks.o filesystems.o \
1176 dcache.o inode.o attr.o bad_inode.o file.o $(BINFMTS)
1177+OX_OBJS = super.o
1178
1179 MOD_LIST_NAME := FS_MODULES
1180 ALL_SUB_DIRS = coda minix ext2 fat msdos vfat proc isofs nfs umsdos ntfs \
1181diff -urN --exclude=.version --exclude=.config* --exclude=.*depend linux-2.2.18-9.virgin/fs/super.c linux/fs/super.c
1182--- linux-2.2.18-9.virgin/fs/super.c Mon Sep 18 15:02:34 2000
1183+++ linux/fs/super.c Mon Sep 25 17:00:57 2000
1184@@ -18,6 +18,7 @@
1185 */
1186
1187 #include <linux/config.h>
1188+#include <linux/module.h>
1189 #include <linux/malloc.h>
1190 #include <linux/locks.h>
1191 #include <linux/smp_lock.h>
1192@@ -25,6 +26,7 @@
1193 #include <linux/init.h>
1194 #include <linux/quotaops.h>
1195 #include <linux/acct.h>
1196+#include <linux/devmtab.h>
1197
1198 #include <asm/uaccess.h>
1199
1200@@ -311,7 +313,57 @@
1201 { 0, NULL }
1202 };
1203
1204-int get_filesystem_info( char *buf )
1205+
1206+extern int count_mounted_filesystems()
1207+{
1208+ struct vfsmount *tmp = vfsmntlist;
1209+ int count = 0;
1210+
1211+ while (tmp)
1212+ {
1213+ tmp = tmp->mnt_next;
1214+ count++;
1215+ }
1216+
1217+ return count;
1218+}
1219+EXPORT_SYMBOL(count_mounted_filesystems);
1220+
1221+
1222+extern void get_mtab_entries( int count, struct k_mntent* mntentlist)
1223+{
1224+ struct vfsmount *tmp = vfsmntlist;
1225+ struct proc_fs_info *fs_infop;
1226+ int i = 0, len;
1227+
1228+ while (tmp && i < count)
1229+ {
1230+ strncpy(mntentlist[i].mnt_fsname, tmp->mnt_devname,
1231+ sizeof(mntentlist[i].mnt_fsname));
1232+ strncpy(mntentlist[i].mnt_dir, tmp->mnt_dirname,
1233+ sizeof(mntentlist[i].mnt_dir));
1234+ strncpy(mntentlist[i].mnt_type, tmp->mnt_sb->s_type->name,
1235+ sizeof(mntentlist[i].mnt_type));
1236+ len = 0;
1237+ len+=sprintf(mntentlist[i].mnt_opts, "%s",
1238+ tmp->mnt_flags & MS_RDONLY ? "ro" : "rw");
1239+ for (fs_infop = fs_info; fs_infop->flag; fs_infop++) {
1240+ if (tmp->mnt_flags & fs_infop->flag) {
1241+ strncpy(mntentlist[i].mnt_opts+len, fs_infop->str,
1242+ sizeof(mntentlist[i].mnt_opts)-len);
1243+ len += strlen(fs_infop->str);
1244+ }
1245+ }
1246+
1247+ /* TODO -- add in NFS stuff */
1248+
1249+ tmp = tmp->mnt_next;
1250+ i++;
1251+ }
1252+}
1253+EXPORT_SYMBOL(get_mtab_entries);
1254+
1255+extern int get_filesystem_info( char *buf )
1256 {
1257 struct vfsmount *tmp = vfsmntlist;
1258 struct proc_fs_info *fs_infop;
1259@@ -383,8 +435,37 @@
1260
1261 return len;
1262 }
1263+EXPORT_SYMBOL(get_filesystem_info);
1264+
1265+extern int count_kfstypes()
1266+{
1267+ struct file_system_type * tmp = file_systems;
1268+ int count = 0;
1269+
1270+ while (tmp) {
1271+ count++;
1272+ tmp = tmp->next;
1273+ }
1274+
1275+ return count;
1276+}
1277+EXPORT_SYMBOL(count_kfstypes);
1278+
1279+extern void get_kfstype_list(int count, struct k_fstype* fstypelist)
1280+{
1281+ int i = 0;
1282+ struct file_system_type * tmp = file_systems;
1283+
1284+ while (tmp && i < count) {
1285+ strncpy(fstypelist[i].mnt_type, tmp->name, sizeof(fstypelist[i].mnt_type));
1286+ fstypelist[i].mnt_nodev = (tmp->fs_flags & FS_REQUIRES_DEV)? 0 : 1;
1287+ tmp = tmp->next;
1288+ i++;
1289+ }
1290+}
1291+EXPORT_SYMBOL(get_kfstype_list);
1292
1293-int get_filesystem_list(char * buf)
1294+extern int get_filesystem_list(char * buf)
1295 {
1296 int len = 0;
1297 struct file_system_type * tmp;
1298@@ -398,6 +479,7 @@
1299 }
1300 return len;
1301 }
1302+EXPORT_SYMBOL(get_filesystem_list);
1303
1304 struct file_system_type *get_fs_type(const char *name)
1305 {
1306diff -urN --exclude=.version --exclude=.config* --exclude=.*depend linux-2.2.18-9.virgin/include/linux/devmtab.h linux/include/linux/devmtab.h
1307--- linux-2.2.18-9.virgin/include/linux/devmtab.h Wed Dec 31 17:00:00 1969
1308+++ linux/include/linux/devmtab.h Mon Sep 25 17:00:57 2000
1309@@ -0,0 +1,55 @@
1310+/* vi: set sw=8 ts=8: */
1311+/*
1312+ * -- <linux/devmtab.h>
1313+ *
1314+ * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
1315+ *
1316+ * May be copied or modified under the terms of the GNU General Public License.
1317+ * See linux/COPYING for more information.
1318+ *
1319+ * This driver implements an interface whereby programs such as mount(8),
1320+ * umount(8), and df(1) may obtain all the process information they need to do
1321+ * their jobs without needing to use /proc.
1322+ *
1323+ */
1324+
1325+#ifndef _LINUX_DEVMTAB_H
1326+#define _LINUX_DEVMTAB_H
1327+
1328+
1329+/*******************************************************
1330+ * The list of all ioctl(2) commands suported by devmtab.
1331+ * For the devmtab ioctls, I have commandeered some of the
1332+ * higher bits of byte 0xeb.
1333+ *******************************************************/
1334+#define DEVMTAB_COUNT_FILESYSTEMS 0xebaa /* Get a list of all fs */
1335+#define DEVMTAB_GET_FILESYSTEMS 0xebab /* Get a list of all fs */
1336+#define DEVMTAB_COUNT_MOUNTS 0xebac /* Returns number of mounted filesystems */
1337+#define DEVMTAB_GET_MOUNTS 0xebad /* Get a list of a mounted fs */
1338+#define DEVMTAB_SET_ROOTFS_DEVNAME 0xebae /* Replace /dev/root with real name */
1339+
1340+/*******************************************************
1341+ * devmtab ioctl(2) structures
1342+ *******************************************************/
1343+
1344+/* An array of these is returned by the DEVMTAB_GET_FILESYSTEMS ioctl.
1345+ */
1346+struct k_fstype {
1347+ char mnt_type[255]; /* filesystem type: ext2, nfs, etc. */
1348+ int mnt_nodev; /* Is this a device-less filesystem? */
1349+};
1350+
1351+/* An array of these is returned by the DEVMTAB_GET_MOUNTS ioctl.
1352+ * This struct should be the same as what libc returns via the
1353+ * getmntent(3) function (excat this comes from the kernel, not
1354+ * from whatever noise is in /etc/mtab at the moment... */
1355+struct k_mntent {
1356+ char mnt_fsname[255]; /* name of mounted file system */
1357+ char mnt_dir[255]; /* path of file system mount point */
1358+ char mnt_type[255]; /* filesystem type: ext2, nfs, etc. */
1359+ char mnt_opts[255]; /* Comma-separated list of mount options */
1360+ int mnt_freq; /* dump frequency in days */
1361+ int mnt_passno; /* pass number for parallel fsck */
1362+};
1363+
1364+#endif /* _LINUX_DEVMTAB_H */
1365diff -urN --exclude=.version --exclude=.config* --exclude=.*depend linux-2.2.18-9.virgin/include/linux/devps.h linux/include/linux/devps.h
1366--- linux-2.2.18-9.virgin/include/linux/devps.h Wed Dec 31 17:00:00 1969
1367+++ linux/include/linux/devps.h Mon Sep 25 17:00:57 2000
1368@@ -0,0 +1,78 @@
1369+/*
1370+ * -- <linux/devps.h>
1371+ *
1372+ * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
1373+ *
1374+ * May be copied or modified under the terms of the GNU General Public License.
1375+ * See linux/COPYING for more information.
1376+ *
1377+ * This driver implements an interface whereby programs such as ps(1), top(1),
1378+ * killall(1) and the like may obtain all the process information they need to
1379+ * do their jobs.
1380+ *
1381+ */
1382+
1383+#ifndef _LINUX_DEVPS_H
1384+#define _LINUX_DEVPS_H
1385+
1386+
1387+/*******************************************************
1388+ * The list of all ioctl(2) commands suported by devps.
1389+ * For the devps ioctls, I have commandeered some of the
1390+ * higher bits of byte 0xeb.
1391+ *******************************************************/
1392+#define DEVPS_GET_NUM_PIDS 0xeba1 /* Get a list of all PIDs */
1393+#define DEVPS_GET_PID_LIST 0xeba2 /* Get a list of all PIDs */
1394+#define DEVPS_GET_PID_INFO 0xeba3 /* Get info about a specific PID */
1395+#define DEVPS_GET_CURRENT_PID 0xeba4 /* Get the current PID */
1396+
1397+/*******************************************************
1398+ * devps ioctl(2) structures
1399+ *******************************************************/
1400+
1401+
1402+struct pid_info
1403+{
1404+ char name[16];
1405+ long flags;
1406+ pid_t pgrp;
1407+ clock_t tms_cutime;
1408+ clock_t tms_cstime;
1409+ clock_t tms_utime;
1410+ clock_t tms_stime;
1411+ unsigned long min_flt;
1412+ unsigned long cmin_flt;
1413+ unsigned long maj_flt;
1414+ unsigned long cmaj_flt;
1415+ pid_t session;
1416+ pid_t pid;
1417+ pid_t ppid;
1418+ int tty;
1419+ unsigned long start_time;
1420+ unsigned long uid,euid,suid,fsuid;
1421+ unsigned long gid,egid,sgid,fsgid;
1422+ long priority, nice;
1423+ char state;
1424+ int processor;
1425+ unsigned long nswap, cnswap;
1426+ char command_line[256];
1427+ char environment[256];
1428+ char root[256];
1429+ char cwd[256];
1430+#if 0
1431+ /* TODO: Add in this (and probably more) stuff */
1432+
1433+ int resident;
1434+ int size;
1435+ int share;
1436+ unsigned long vsize;
1437+ char exe[MAX_PATH];
1438+ unsigned long vm_total, vm_locked, vm_rss, vm_data, vm_stack, vm_exec, vm_lib;
1439+ unsigned long start_code, end_code, start_data, eip, esp;
1440+ unsigned long signal, blocked;
1441+#endif
1442+
1443+
1444+};
1445+
1446+#endif /* _LINUX_DEVPS_H */
1447diff -urN --exclude=.version --exclude=.config* --exclude=.*depend linux-2.2.18-9.virgin/include/linux/fs.h linux/include/linux/fs.h
1448--- linux-2.2.18-9.virgin/include/linux/fs.h Mon Sep 18 15:08:47 2000
1449+++ linux/include/linux/fs.h Mon Sep 25 17:37:50 2000
1450@@ -573,6 +573,16 @@
1451 struct semaphore s_vfs_rename_sem; /* Kludge */
1452 };
1453
1454+/* fs/super.c */
1455+#include <linux/devmtab.h>
1456+
1457+extern int count_kfstypes( void);
1458+extern void get_kfstype_list( int count, struct k_fstype* fstypelist);
1459+extern int count_mounted_filesystems( void);
1460+extern int get_filesystem_info(char *buf);
1461+extern int get_filesystem_list(char *buf);
1462+extern void get_mtab_entries( int count, struct k_mntent* mntentlist);
1463+
1464 /*
1465 * VFS helper functions..
1466 */
1467diff -urN --exclude=.version --exclude=.config* --exclude=.*depend linux-2.2.18-9.virgin/include/linux/miscdevice.h linux/include/linux/miscdevice.h
1468--- linux-2.2.18-9.virgin/include/linux/miscdevice.h Mon Aug 9 13:04:41 1999
1469+++ linux/include/linux/miscdevice.h Mon Sep 25 16:33:17 2000
1470@@ -11,6 +11,8 @@
1471 #define APOLLO_MOUSE_MINOR 7
1472 #define PC110PAD_MINOR 9
1473 #define MAC_MOUSE_MINOR 10
1474+#define DEVPS_MINOR 21
1475+#define DEVMTAB_MINOR 22
1476 #define WATCHDOG_MINOR 130 /* Watchdog timer */
1477 #define TEMP_MINOR 131 /* Temperature Sensor */
1478 #define RTC_MINOR 135