From 44a634183d95dc43306e48f933d27bece7d882ea Mon Sep 17 00:00:00 2001 From: Sukadev Bhattiprolu Date: Thu, 10 May 2007 22:23:08 -0700 Subject: [PATCH] --- yaml --- r: 55923 b: refs/heads/master c: fa0334f19f0e1a1e570fc2a160dfe53536599ade h: refs/heads/master i: 55921: 284bb35003469e327ba4a4f4c83ce936027c6b7a 55919: 6c8a02699e41845b05ca4ae318d05d8ab56c7477 v: v3 --- [refs] | 2 +- trunk/fs/autofs/autofs_i.h | 4 ++-- trunk/fs/autofs/inode.c | 20 ++++++++++++++++---- trunk/fs/autofs/root.c | 6 ++++-- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/[refs] b/[refs] index b13f94b40de7..293c6db757b3 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: d78e53c89a820471837e0cb91fe36b7be1a7c9de +refs/heads/master: fa0334f19f0e1a1e570fc2a160dfe53536599ade diff --git a/trunk/fs/autofs/autofs_i.h b/trunk/fs/autofs/autofs_i.h index 4ef544434b51..8b4cca3c4705 100644 --- a/trunk/fs/autofs/autofs_i.h +++ b/trunk/fs/autofs/autofs_i.h @@ -101,7 +101,7 @@ struct autofs_symlink { struct autofs_sb_info { u32 magic; struct file *pipe; - pid_t oz_pgrp; + struct pid *oz_pgrp; int catatonic; struct super_block *sb; unsigned long exp_timeout; @@ -122,7 +122,7 @@ static inline struct autofs_sb_info *autofs_sbi(struct super_block *sb) filesystem without "magic".) */ static inline int autofs_oz_mode(struct autofs_sb_info *sbi) { - return sbi->catatonic || process_group(current) == sbi->oz_pgrp; + return sbi->catatonic || task_pgrp(current) == sbi->oz_pgrp; } /* Hash operations */ diff --git a/trunk/fs/autofs/inode.c b/trunk/fs/autofs/inode.c index d8315e61731e..e7204d71acc9 100644 --- a/trunk/fs/autofs/inode.c +++ b/trunk/fs/autofs/inode.c @@ -37,6 +37,8 @@ void autofs_kill_sb(struct super_block *sb) if (!sbi->catatonic) autofs_catatonic_mode(sbi); /* Free wait queues, close pipe */ + put_pid(sbi->oz_pgrp); + autofs_hash_nuke(sbi); for (n = 0; n < AUTOFS_MAX_SYMLINKS; n++) { if (test_bit(n, sbi->symlink_bitmap)) @@ -139,6 +141,7 @@ int autofs_fill_super(struct super_block *s, void *data, int silent) int pipefd; struct autofs_sb_info *sbi; int minproto, maxproto; + pid_t pgid; sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); if (!sbi) @@ -150,7 +153,6 @@ int autofs_fill_super(struct super_block *s, void *data, int silent) sbi->pipe = NULL; sbi->catatonic = 1; sbi->exp_timeout = 0; - sbi->oz_pgrp = process_group(current); autofs_initialize_hash(&sbi->dirhash); sbi->queues = NULL; memset(sbi->symlink_bitmap, 0, sizeof(long)*AUTOFS_SYMLINK_BITMAP_LEN); @@ -171,7 +173,7 @@ int autofs_fill_super(struct super_block *s, void *data, int silent) /* Can this call block? - WTF cares? s is locked. */ if (parse_options(data, &pipefd, &root_inode->i_uid, - &root_inode->i_gid, &sbi->oz_pgrp, &minproto, + &root_inode->i_gid, &pgid, &minproto, &maxproto)) { printk("autofs: called with bogus options\n"); goto fail_dput; @@ -184,13 +186,21 @@ int autofs_fill_super(struct super_block *s, void *data, int silent) goto fail_dput; } - DPRINTK(("autofs: pipe fd = %d, pgrp = %u\n", pipefd, sbi->oz_pgrp)); + DPRINTK(("autofs: pipe fd = %d, pgrp = %u\n", pipefd, pgid)); + sbi->oz_pgrp = find_get_pid(pgid); + + if (!sbi->oz_pgrp) { + printk("autofs: could not find process group %d\n", pgid); + goto fail_dput; + } + pipe = fget(pipefd); if (!pipe) { printk("autofs: could not open pipe file descriptor\n"); - goto fail_dput; + goto fail_put_pid; } + if (!pipe->f_op || !pipe->f_op->write) goto fail_fput; sbi->pipe = pipe; @@ -205,6 +215,8 @@ int autofs_fill_super(struct super_block *s, void *data, int silent) fail_fput: printk("autofs: pipe file descriptor does not contain proper ops\n"); fput(pipe); +fail_put_pid: + put_pid(sbi->oz_pgrp); fail_dput: dput(root); goto fail_free; diff --git a/trunk/fs/autofs/root.c b/trunk/fs/autofs/root.c index 6fa04dd6d167..c1489533277a 100644 --- a/trunk/fs/autofs/root.c +++ b/trunk/fs/autofs/root.c @@ -213,8 +213,10 @@ static struct dentry *autofs_root_lookup(struct inode *dir, struct dentry *dentr sbi = autofs_sbi(dir->i_sb); oz_mode = autofs_oz_mode(sbi); - DPRINTK(("autofs_lookup: pid = %u, pgrp = %u, catatonic = %d, oz_mode = %d\n", - current->pid, process_group(current), sbi->catatonic, oz_mode)); + DPRINTK(("autofs_lookup: pid = %u, pgrp = %u, catatonic = %d, " + "oz_mode = %d\n", pid_nr(task_pid(current)), + process_group(current), sbi->catatonic, + oz_mode)); /* * Mark the dentry incomplete, but add it. This is needed so