minix: replace inode uid,gid,mode init with helper
[safe/jmp/linux-2.6] / fs / ext2 / namei.c
index e1dedb0..71efb0e 100644 (file)
@@ -31,6 +31,7 @@
  */
 
 #include <linux/pagemap.h>
+#include <linux/quotaops.h>
 #include "ext2.h"
 #include "xattr.h"
 #include "acl.h"
@@ -70,7 +71,7 @@ static struct dentry *ext2_lookup(struct inode * dir, struct dentry *dentry, str
                        if (PTR_ERR(inode) == -ESTALE) {
                                ext2_error(dir->i_sb, __func__,
                                                "deleted inode referenced: %lu",
-                                               ino);
+                                               (unsigned long) ino);
                                return ERR_PTR(-EIO);
                        } else {
                                return ERR_CAST(inode);
@@ -99,24 +100,27 @@ struct dentry *ext2_get_parent(struct dentry *child)
  */
 static int ext2_create (struct inode * dir, struct dentry * dentry, int mode, struct nameidata *nd)
 {
-       struct inode * inode = ext2_new_inode (dir, mode);
-       int err = PTR_ERR(inode);
-       if (!IS_ERR(inode)) {
-               inode->i_op = &ext2_file_inode_operations;
-               if (ext2_use_xip(inode->i_sb)) {
-                       inode->i_mapping->a_ops = &ext2_aops_xip;
-                       inode->i_fop = &ext2_xip_file_operations;
-               } else if (test_opt(inode->i_sb, NOBH)) {
-                       inode->i_mapping->a_ops = &ext2_nobh_aops;
-                       inode->i_fop = &ext2_file_operations;
-               } else {
-                       inode->i_mapping->a_ops = &ext2_aops;
-                       inode->i_fop = &ext2_file_operations;
-               }
-               mark_inode_dirty(inode);
-               err = ext2_add_nondir(dentry, inode);
+       struct inode *inode;
+
+       dquot_initialize(dir);
+
+       inode = ext2_new_inode(dir, mode);
+       if (IS_ERR(inode))
+               return PTR_ERR(inode);
+
+       inode->i_op = &ext2_file_inode_operations;
+       if (ext2_use_xip(inode->i_sb)) {
+               inode->i_mapping->a_ops = &ext2_aops_xip;
+               inode->i_fop = &ext2_xip_file_operations;
+       } else if (test_opt(inode->i_sb, NOBH)) {
+               inode->i_mapping->a_ops = &ext2_nobh_aops;
+               inode->i_fop = &ext2_file_operations;
+       } else {
+               inode->i_mapping->a_ops = &ext2_aops;
+               inode->i_fop = &ext2_file_operations;
        }
-       return err;
+       mark_inode_dirty(inode);
+       return ext2_add_nondir(dentry, inode);
 }
 
 static int ext2_mknod (struct inode * dir, struct dentry *dentry, int mode, dev_t rdev)
@@ -127,6 +131,8 @@ static int ext2_mknod (struct inode * dir, struct dentry *dentry, int mode, dev_
        if (!new_valid_dev(rdev))
                return -EINVAL;
 
+       dquot_initialize(dir);
+
        inode = ext2_new_inode (dir, mode);
        err = PTR_ERR(inode);
        if (!IS_ERR(inode)) {
@@ -151,6 +157,8 @@ static int ext2_symlink (struct inode * dir, struct dentry * dentry,
        if (l > sb->s_blocksize)
                goto out;
 
+       dquot_initialize(dir);
+
        inode = ext2_new_inode (dir, S_IFLNK | S_IRWXUGO);
        err = PTR_ERR(inode);
        if (IS_ERR(inode))
@@ -194,6 +202,8 @@ static int ext2_link (struct dentry * old_dentry, struct inode * dir,
        if (inode->i_nlink >= EXT2_LINK_MAX)
                return -EMLINK;
 
+       dquot_initialize(dir);
+
        inode->i_ctime = CURRENT_TIME_SEC;
        inode_inc_link_count(inode);
        atomic_inc(&inode->i_count);
@@ -216,6 +226,8 @@ static int ext2_mkdir(struct inode * dir, struct dentry * dentry, int mode)
        if (dir->i_nlink >= EXT2_LINK_MAX)
                goto out;
 
+       dquot_initialize(dir);
+
        inode_inc_link_count(dir);
 
        inode = ext2_new_inode (dir, S_IFDIR | mode);
@@ -262,6 +274,8 @@ static int ext2_unlink(struct inode * dir, struct dentry *dentry)
        struct page * page;
        int err = -ENOENT;
 
+       dquot_initialize(dir);
+
        de = ext2_find_entry (dir, &dentry->d_name, &page);
        if (!de)
                goto out;
@@ -304,6 +318,9 @@ static int ext2_rename (struct inode * old_dir, struct dentry * old_dentry,
        struct ext2_dir_entry_2 * old_de;
        int err = -ENOENT;
 
+       dquot_initialize(old_dir);
+       dquot_initialize(new_dir);
+
        old_de = ext2_find_entry (old_dir, &old_dentry->d_name, &old_page);
        if (!old_de)
                goto out;
@@ -362,6 +379,10 @@ static int ext2_rename (struct inode * old_dir, struct dentry * old_dentry,
        if (dir_de) {
                if (old_dir != new_dir)
                        ext2_set_link(old_inode, dir_de, dir_page, new_dir, 0);
+               else {
+                       kunmap(dir_page);
+                       page_cache_release(dir_page);
+               }
                inode_dec_link_count(old_dir);
        }
        return 0;
@@ -396,7 +417,7 @@ const struct inode_operations ext2_dir_inode_operations = {
        .removexattr    = generic_removexattr,
 #endif
        .setattr        = ext2_setattr,
-       .permission     = ext2_permission,
+       .check_acl      = ext2_check_acl,
 };
 
 const struct inode_operations ext2_special_inode_operations = {
@@ -407,5 +428,5 @@ const struct inode_operations ext2_special_inode_operations = {
        .removexattr    = generic_removexattr,
 #endif
        .setattr        = ext2_setattr,
-       .permission     = ext2_permission,
+       .check_acl      = ext2_check_acl,
 };