drm/nouveau: off by one in init_i2c_device_find()
[safe/jmp/linux-2.6] / fs / autofs / root.c
index c148953..9a0520b 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/stat.h>
+#include <linux/slab.h>
 #include <linux/param.h>
 #include <linux/time.h>
 #include <linux/smp_lock.h>
@@ -27,6 +28,7 @@ static int autofs_root_mkdir(struct inode *,struct dentry *,int);
 static int autofs_root_ioctl(struct inode *, struct file *,unsigned int,unsigned long);
 
 const struct file_operations autofs_root_operations = {
+       .llseek         = generic_file_llseek,
        .read           = generic_read_dir,
        .readdir        = autofs_root_readdir,
        .ioctl          = autofs_root_ioctl,
@@ -114,8 +116,8 @@ static int try_to_fill_dentry(struct dentry *dentry, struct super_block *sb, str
        dentry->d_time = (unsigned long) ent;
        
        if (!dentry->d_inode) {
-               inode = iget(sb, ent->ino);
-               if (!inode) {
+               inode = autofs_iget(sb, ent->ino);
+               if (IS_ERR(inode)) {
                        /* Failed, but leave pending for next time */
                        return 1;
                }
@@ -192,7 +194,7 @@ static int autofs_revalidate(struct dentry * dentry, struct nameidata *nd)
        return 1;
 }
 
-static struct dentry_operations autofs_dentry_operations = {
+static const struct dentry_operations autofs_dentry_operations = {
        .d_revalidate   = autofs_revalidate,
 };
 
@@ -214,8 +216,8 @@ static struct dentry *autofs_root_lookup(struct inode *dir, struct dentry *dentr
 
        oz_mode = autofs_oz_mode(sbi);
        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 = %d\n", task_pid_nr(current),
+                               task_pgrp_nr(current), sbi->catatonic,
                                oz_mode));
 
        /*
@@ -274,6 +276,7 @@ static int autofs_root_symlink(struct inode *dir, struct dentry *dentry, const c
        unsigned int n;
        int slsize;
        struct autofs_symlink *sl;
+       struct inode *inode;
 
        DPRINTK(("autofs_root_symlink: %s <- ", symname));
        autofs_say(dentry->d_name.name,dentry->d_name.len);
@@ -331,7 +334,12 @@ static int autofs_root_symlink(struct inode *dir, struct dentry *dentry, const c
        ent->dentry = NULL;     /* We don't keep the dentry for symlinks */
 
        autofs_hash_insert(dh,ent);
-       d_instantiate(dentry, iget(dir->i_sb,ent->ino));
+
+       inode = autofs_iget(dir->i_sb, ent->ino);
+       if (IS_ERR(inode))
+               return PTR_ERR(inode);
+
+       d_instantiate(dentry, inode);
        unlock_kernel();
        return 0;
 }
@@ -428,6 +436,7 @@ static int autofs_root_mkdir(struct inode *dir, struct dentry *dentry, int mode)
        struct autofs_sb_info *sbi = autofs_sbi(dir->i_sb);
        struct autofs_dirhash *dh = &sbi->dirhash;
        struct autofs_dir_ent *ent;
+       struct inode *inode;
        ino_t ino;
 
        lock_kernel();
@@ -469,7 +478,14 @@ static int autofs_root_mkdir(struct inode *dir, struct dentry *dentry, int mode)
        autofs_hash_insert(dh,ent);
 
        inc_nlink(dir);
-       d_instantiate(dentry, iget(dir->i_sb,ino));
+
+       inode = autofs_iget(dir->i_sb, ino);
+       if (IS_ERR(inode)) {
+               drop_nlink(dir);
+               return PTR_ERR(inode);
+       }
+
+       d_instantiate(dentry, inode);
        unlock_kernel();
 
        return 0;
@@ -536,7 +552,7 @@ static int autofs_root_ioctl(struct inode *inode, struct file *filp,
        struct autofs_sb_info *sbi = autofs_sbi(inode->i_sb);
        void __user *argp = (void __user *)arg;
 
-       DPRINTK(("autofs_ioctl: cmd = 0x%08x, arg = 0x%08lx, sbi = %p, pgrp = %u\n",cmd,arg,sbi,process_group(current)));
+       DPRINTK(("autofs_ioctl: cmd = 0x%08x, arg = 0x%08lx, sbi = %p, pgrp = %u\n",cmd,arg,sbi,task_pgrp_nr(current)));
 
        if (_IOC_TYPE(cmd) != _IOC_TYPE(AUTOFS_IOC_FIRST) ||
             _IOC_NR(cmd) - _IOC_NR(AUTOFS_IOC_FIRST) >= AUTOFS_IOC_COUNT)