diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1998-08-25 09:12:35 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 1998-08-25 09:12:35 +0000 |
commit | c7fc24dc4420057f103afe8fc64524ebc25c5d37 (patch) | |
tree | 3682407a599b8f9f03fc096298134cafba1c9b2f /fs/proc/root.c | |
parent | 1d793fade8b063fde3cf275bf1a5c2d381292cd9 (diff) |
o Merge with Linux 2.1.116.
o New Newport console code.
o New G364 console code.
Diffstat (limited to 'fs/proc/root.c')
-rw-r--r-- | fs/proc/root.c | 121 |
1 files changed, 80 insertions, 41 deletions
diff --git a/fs/proc/root.c b/fs/proc/root.c index afc440fc0..999783ee5 100644 --- a/fs/proc/root.c +++ b/fs/proc/root.c @@ -13,10 +13,14 @@ #include <linux/proc_fs.h> #include <linux/stat.h> #include <linux/config.h> +#include <linux/init.h> #include <asm/bitops.h> #ifdef CONFIG_KMOD #include <linux/kmod.h> #endif +#ifdef CONFIG_ZORRO +#include <linux/zorro.h> +#endif /* * Offset of the first process in the /proc root directory.. @@ -498,25 +502,25 @@ static struct proc_dir_entry proc_root_version = { S_IFREG | S_IRUGO, 1, 0, 0, 0, &proc_array_inode_operations }; -#ifdef CONFIG_ZORRO -static struct proc_dir_entry proc_root_zorro = { - PROC_ZORRO, 5, "zorro", - S_IFREG | S_IRUGO, 1, 0, 0, - 0, &proc_array_inode_operations -}; -#endif static struct proc_dir_entry proc_root_cpuinfo = { PROC_CPUINFO, 7, "cpuinfo", S_IFREG | S_IRUGO, 1, 0, 0, 0, &proc_array_inode_operations }; -#if defined (CONFIG_AMIGA) || defined (CONFIG_ATARI) +#if defined (CONFIG_PROC_HARDWARE) static struct proc_dir_entry proc_root_hardware = { PROC_HARDWARE, 8, "hardware", S_IFREG | S_IRUGO, 1, 0, 0, 0, &proc_array_inode_operations }; #endif +#ifdef CONFIG_STRAM_PROC +static struct proc_dir_entry proc_root_stram = { + PROC_STRAM, 5, "stram", + S_IFREG | S_IRUGO, 1, 0, 0, + 0, &proc_array_inode_operations +}; +#endif static struct proc_dir_entry proc_root_self = { PROC_SELF, 4, "self", S_IFLNK | S_IRUGO | S_IWUGO | S_IXUGO, 1, 0, 0, @@ -556,6 +560,11 @@ static struct proc_dir_entry proc_root_devices = { S_IFREG | S_IRUGO, 1, 0, 0, 0, &proc_array_inode_operations }; +static struct proc_dir_entry proc_root_partitions = { + PROC_PARTITIONS, 10, "partitions", + S_IFREG | S_IRUGO, 1, 0, 0, + 0, &proc_array_inode_operations +}; static struct proc_dir_entry proc_root_interrupts = { PROC_INTERRUPTS, 10,"interrupts", S_IFREG | S_IRUGO, 1, 0, 0, @@ -566,6 +575,14 @@ static struct proc_dir_entry proc_root_filesystems = { S_IFREG | S_IRUGO, 1, 0, 0, 0, &proc_array_inode_operations }; +struct proc_dir_entry proc_root_fs = { + PROC_FS, 2, "fs", + S_IFDIR | S_IRUGO | S_IXUGO, 2, 0, 0, + 0, &proc_dir_inode_operations, + NULL, NULL, + NULL, + NULL, NULL +}; static struct proc_dir_entry proc_root_dma = { PROC_DMA, 3, "dma", S_IFREG | S_IRUGO, 1, 0, 0, @@ -631,7 +648,7 @@ static struct proc_dir_entry proc_root_ppc_htab = { }; #endif -void proc_root_init(void) +__initfunc(void proc_root_init(void)) { proc_base_init(); proc_register(&proc_root, &proc_root_loadavg); @@ -639,9 +656,6 @@ void proc_root_init(void) proc_register(&proc_root, &proc_root_meminfo); proc_register(&proc_root, &proc_root_kmsg); proc_register(&proc_root, &proc_root_version); -#ifdef CONFIG_ZORRO - proc_register(&proc_root, &proc_root_zorro); -#endif proc_register(&proc_root, &proc_root_cpuinfo); proc_register(&proc_root, &proc_root_self); proc_net = create_proc_entry("net", S_IFDIR, 0); @@ -665,8 +679,10 @@ void proc_root_init(void) #endif proc_register(&proc_root, &proc_root_stat); proc_register(&proc_root, &proc_root_devices); + proc_register(&proc_root, &proc_root_partitions); proc_register(&proc_root, &proc_root_interrupts); proc_register(&proc_root, &proc_root_filesystems); + proc_register(&proc_root, &proc_root_fs); proc_register(&proc_root, &proc_root_dma); proc_register(&proc_root, &proc_root_ioports); proc_register(&proc_root, &proc_root_cmdline); @@ -687,14 +703,17 @@ void proc_root_init(void) #endif proc_register(&proc_root, &proc_openprom); #endif -#if defined (CONFIG_AMIGA) || defined (CONFIG_ATARI) +#ifdef CONFIG_PROC_HARDWARE proc_register(&proc_root, &proc_root_hardware); #endif +#ifdef CONFIG_STRAM_PROC + proc_register(&proc_root, &proc_root_stram); +#endif proc_register(&proc_root, &proc_root_slab); if (prof_shift) { proc_register(&proc_root, &proc_root_profile); - proc_root_profile.size = (1+prof_len) * sizeof(unsigned long); + proc_root_profile.size = (1+prof_len) * sizeof(unsigned int); } proc_tty_init(); @@ -810,16 +829,14 @@ static int proc_root_lookup(struct inode * dir, struct dentry * dentry) } read_lock(&tasklist_lock); p = find_task_by_pid(pid); + read_unlock(&tasklist_lock); inode = NULL; if (pid && p) { unsigned long ino = (pid << 16) + PROC_PID_INO; inode = proc_get_inode(dir->i_sb, ino, &proc_pid); - if (!inode) { - read_unlock(&tasklist_lock); + if (!inode) return -EINVAL; - } } - read_unlock(&tasklist_lock); dentry->d_op = &proc_dentry_operations; d_add(dentry, inode); @@ -886,46 +903,68 @@ int proc_readdir(struct file * filp, return 1; } -#define NUMBUF 10 +#define PROC_NUMBUF 10 +#define PROC_MAXPIDS 20 + +/* + * Get a few pid's to return for filldir - we need to hold the + * tasklist lock while doing this, and we must release it before + * we actually do the filldir itself, so we use a temp buffer.. + */ +static int get_pid_list(unsigned int index, unsigned int *pids) +{ + struct task_struct *p; + int nr = FIRST_PROCESS_ENTRY; + int nr_pids = 0; + + read_lock(&tasklist_lock); + for_each_task(p) { + int pid; + if (nr++ < index) + continue; + pid = p->pid; + if (!pid) + continue; + pids[nr_pids] = pid; + nr_pids++; + if (nr_pids >= PROC_MAXPIDS) + break; + } + read_unlock(&tasklist_lock); + return nr_pids; +} static int proc_root_readdir(struct file * filp, void * dirent, filldir_t filldir) { - struct task_struct *p; - char buf[NUMBUF]; + unsigned int pid_array[PROC_MAXPIDS]; + char buf[PROC_NUMBUF]; unsigned int nr = filp->f_pos; + unsigned int nr_pids, i; if (nr < FIRST_PROCESS_ENTRY) { int error = proc_readdir(filp, dirent, filldir); if (error <= 0) return error; - filp->f_pos = FIRST_PROCESS_ENTRY; + filp->f_pos = nr = FIRST_PROCESS_ENTRY; } - nr = FIRST_PROCESS_ENTRY; - read_lock(&tasklist_lock); - for_each_task(p) { - unsigned int pid; + nr_pids = get_pid_list(nr, pid_array); - if(nr++ < filp->f_pos) - continue; + for (i = 0; i < nr_pids; i++) { + int pid = pid_array[i]; + unsigned long j = PROC_NUMBUF; - if((pid = p->pid) != 0) { - unsigned long j = NUMBUF, i = pid; + do { + j--; + buf[j] = '0' + (pid % 10); + pid /= 10; + } while (pid); - do { - j--; - buf[j] = '0' + (i % 10); - i /= 10; - } while (i); - - if (filldir(dirent, buf+j, NUMBUF-j, - filp->f_pos, (pid << 16) + PROC_PID_INO) < 0) - break; - } + if (filldir(dirent, buf+j, PROC_NUMBUF-j, filp->f_pos, (pid << 16) + PROC_PID_INO) < 0) + break; filp->f_pos++; } - read_unlock(&tasklist_lock); return 0; } |