X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=fs%2Fproc%2Finode.c;h=2120c80905ba935c2d51d09450baefd0d6d5ee5b;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=2d38f02c9e4eb8d69a812649ad719f69ee74b564;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/fs/proc/inode.c b/fs/proc/inode.c index 2d38f02c9..2120c8090 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c @@ -14,13 +14,12 @@ #include #include #include -#include #include #include #include -extern void free_proc_entry(struct proc_dir_entry *); +#include "internal.h" static inline struct proc_dir_entry * de_get(struct proc_dir_entry *de) { @@ -61,6 +60,8 @@ static void proc_delete_inode(struct inode *inode) struct proc_dir_entry *de; struct task_struct *tsk; + truncate_inode_pages(&inode->i_data, 0); + /* Let go of any associated process */ tsk = PROC_I(inode)->task; if (tsk) @@ -120,7 +121,8 @@ int __init proc_init_inodecache(void) { proc_inode_cachep = kmem_cache_create("proc_inode_cache", sizeof(struct proc_inode), - 0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT, + 0, (SLAB_RECLAIM_ACCOUNT| + SLAB_MEM_SPREAD), init_once, NULL); if (proc_inode_cachep == NULL) return -ENOMEM; @@ -143,51 +145,6 @@ static struct super_operations proc_sops = { .remount_fs = proc_remount, }; -enum { - Opt_uid, Opt_gid, Opt_err -}; - -static match_table_t tokens = { - {Opt_uid, "uid=%u"}, - {Opt_gid, "gid=%u"}, - {Opt_err, NULL} -}; - -static int parse_options(char *options,uid_t *uid,gid_t *gid) -{ - char *p; - int option; - - *uid = current->uid; - *gid = current->gid; - if (!options) - return 1; - - while ((p = strsep(&options, ",")) != NULL) { - substring_t args[MAX_OPT_ARGS]; - int token; - if (!*p) - continue; - - token = match_token(p, tokens, args); - switch (token) { - case Opt_uid: - if (match_int(args, &option)) - return 0; - *uid = option; - break; - case Opt_gid: - if (match_int(args, &option)) - return 0; - *gid = option; - break; - default: - return 0; - } - } - return 1; -} - struct inode *proc_get_inode(struct super_block *sb, unsigned int ino, struct proc_dir_entry *de) { @@ -200,10 +157,13 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino, WARN_ON(de && de->deleted); + if (de != NULL && !try_module_get(de->owner)) + goto out_mod; + inode = iget(sb, ino); if (!inode) - goto out_fail; - + goto out_ino; + PROC_I(inode)->pde = de; if (de) { if (de->mode) { @@ -211,24 +171,26 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino, inode->i_uid = de->uid; inode->i_gid = de->gid; } + if (de->vx_flags) + PROC_I(inode)->vx_flags = de->vx_flags; if (de->size) inode->i_size = de->size; if (de->nlink) inode->i_nlink = de->nlink; - if (!try_module_get(de->owner)) - goto out_fail; if (de->proc_iops) inode->i_op = de->proc_iops; if (de->proc_fops) inode->i_fop = de->proc_fops; } -out: return inode; -out_fail: +out_ino: + if (de != NULL) + module_put(de->owner); +out_mod: de_put(de); - goto out; + return NULL; } int proc_fill_super(struct super_block *s, void *data, int silent) @@ -240,18 +202,16 @@ int proc_fill_super(struct super_block *s, void *data, int silent) s->s_blocksize_bits = 10; s->s_magic = PROC_SUPER_MAGIC; s->s_op = &proc_sops; + s->s_time_gran = 1; root_inode = proc_get_inode(s, PROC_ROOT_INO, &proc_root); if (!root_inode) goto out_no_root; - /* - * Fixup the root inode's nlink value - */ - root_inode->i_nlink += nr_processes(); + root_inode->i_uid = 0; + root_inode->i_gid = 0; s->s_root = d_alloc_root(root_inode); if (!s->s_root) goto out_no_root; - parse_options(data, &root_inode->i_uid, &root_inode->i_gid); return 0; out_no_root: