diff --unified --recursive lihnux/fs/proc/inode.c linux/fs/proc/inode.c --- lihnux/fs/proc/inode.c Sat May 9 04:10:30 1998 +++ linux/fs/proc/inode.c Mon Feb 7 23:20:31 2000 @@ -285,19 +285,6 @@ if (de->fill_inode) de->fill_inode(inode, 1); } - /* - * Fixup the root inode's nlink value - */ - if (inode->i_ino == PROC_ROOT_INO) { - struct task_struct *p; - - read_lock(&tasklist_lock); - for_each_task(p) { - if (p->pid) - inode->i_nlink++; - } - read_unlock(&tasklist_lock); - } out: return inode; diff --unified --recursive lihnux/fs/proc/root.c linux/fs/proc/root.c --- lihnux/fs/proc/root.c Wed Oct 27 03:53:42 1999 +++ linux/fs/proc/root.c Mon Feb 7 23:20:31 2000 @@ -29,6 +29,7 @@ static int proc_root_readdir(struct file *, void *, filldir_t); static struct dentry *proc_root_lookup(struct inode *,struct dentry *); +static int proc_revalidate(struct dentry *); static int proc_unlink(struct inode *, struct dentry *); static unsigned char proc_alloc_map[PROC_NDYNAMIC / 8] = {0}; @@ -140,7 +141,10 @@ NULL, /* writepage */ NULL, /* bmap */ NULL, /* truncate */ - NULL /* permission */ + NULL, /* permission */ + NULL, /* smap */ + NULL, /* updatepage */ + proc_revalidate, /* revalidate */ }; /* @@ -819,17 +823,6 @@ struct inode *inode; int len; - if (dir->i_ino == PROC_ROOT_INO) { /* check for safety... */ - dir->i_nlink = proc_root.nlink; - - read_lock(&tasklist_lock); - for_each_task(p) { - if (p->pid) - dir->i_nlink++; - } - read_unlock(&tasklist_lock); - } - if (!proc_lookup(dir, dentry)) return NULL; @@ -866,6 +859,27 @@ dentry->d_op = &proc_dentry_operations; d_add(dentry, inode); return NULL; +} + +/* + * Update the root dentry/inodes i_nlink count for statting here. + */ + +static int proc_revalidate(struct dentry * dentry) +{ + struct task_struct *p; + struct inode * inode = dentry->d_inode; + + inode->i_nlink = proc_root.nlink; + + read_lock(&tasklist_lock); + for_each_task(p) { + if (p->pid) + inode->i_nlink++; + } + read_unlock(&tasklist_lock); + + return 0; } /* diff --unified --recursive lihnux/lib/vsprintf.c linux/lib/vsprintf.c --- lihnux/lib/vsprintf.c Mon Mar 15 21:19:05 1999 +++ linux/lib/vsprintf.c Mon Feb 7 23:20:51 2000 @@ -66,10 +66,22 @@ #define SPECIAL 32 /* 0x */ #define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */ -#define do_div(n,base) ({ \ +#define do_div8(n) ({ \ int __res; \ -__res = ((unsigned long) n) % (unsigned) base; \ -n = ((unsigned long) n) / (unsigned) base; \ +__res = ((unsigned long) n) % 8; \ +n = ((unsigned long) n) / 8; \ +__res; }) + +#define do_div10(n) ({ \ +int __res; \ +__res = ((unsigned long) n) % 10; \ +n = ((unsigned long) n) / 10; \ +__res; }) + +#define do_div16(n) ({ \ +int __res; \ +__res = ((unsigned long) n) % 16; \ +n = ((unsigned long) n) / 16; \ __res; }) static char * number(char * str, long num, int base, int size, int precision @@ -109,8 +121,12 @@ i = 0; if (num == 0) tmp[i++]='0'; - else while (num != 0) - tmp[i++] = digits[do_div(num,base)]; + else if (base==10) while (num != 0) + tmp[i++] = '0'+do_div10(num); + else if (base==16) while (num != 0) + tmp[i++] = digits[do_div16(num)]; + else + tmp[i++] = '0'+do_div8(num); if (i > precision) precision = i; size -= precision;