nfsd: move most of nfsfh.h to fs/nfsd
[safe/jmp/linux-2.6] / fs / reiserfs / namei.c
index d9c1c8b..2715791 100644 (file)
@@ -106,7 +106,7 @@ key of the first directory entry in it.
 This function first calls search_by_key, then, if item whose first
 entry matches is not found it looks for the entry inside directory
 item found by search_by_key. Fills the path to the entry, and to the
-entry position in the item 
+entry position in the item
 
 */
 
@@ -338,21 +338,8 @@ static struct dentry *reiserfs_lookup(struct inode *dir, struct dentry *dentry,
                                &path_to_entry, &de);
        pathrelse(&path_to_entry);
        if (retval == NAME_FOUND) {
-               /* Hide the .reiserfs_priv directory */
-               if (reiserfs_xattrs(dir->i_sb) &&
-                   !old_format_only(dir->i_sb) &&
-                   REISERFS_SB(dir->i_sb)->priv_root &&
-                   REISERFS_SB(dir->i_sb)->priv_root->d_inode &&
-                   de.de_objectid ==
-                   le32_to_cpu(INODE_PKEY
-                               (REISERFS_SB(dir->i_sb)->priv_root->d_inode)->
-                               k_objectid)) {
-                       reiserfs_write_unlock(dir->i_sb);
-                       return ERR_PTR(-EACCES);
-               }
-
-               inode =
-                   reiserfs_iget(dir->i_sb, (struct cpu_key *)&(de.de_dir_id));
+               inode = reiserfs_iget(dir->i_sb,
+                                     (struct cpu_key *)&(de.de_dir_id));
                if (!inode || IS_ERR(inode)) {
                        reiserfs_write_unlock(dir->i_sb);
                        return ERR_PTR(-EACCES);
@@ -371,7 +358,7 @@ static struct dentry *reiserfs_lookup(struct inode *dir, struct dentry *dentry,
        return d_splice_alias(inode, dentry);
 }
 
-/* 
+/*
 ** looks up the dentry of the parent directory for child.
 ** taken from ext2_get_parent
 */
@@ -401,7 +388,7 @@ struct dentry *reiserfs_get_parent(struct dentry *child)
        return d_obtain_alias(inode);
 }
 
-/* add entry to the directory (entry can be hidden). 
+/* add entry to the directory (entry can be hidden).
 
 insert definition of when hidden directories are used here -Hans
 
@@ -552,15 +539,15 @@ static int reiserfs_add_entry(struct reiserfs_transaction_handle *th,
 */
 static int drop_new_inode(struct inode *inode)
 {
-       DQUOT_DROP(inode);
+       vfs_dq_drop(inode);
        make_bad_inode(inode);
        inode->i_flags |= S_NOQUOTA;
        iput(inode);
        return 0;
 }
 
-/* utility function that does setup for reiserfs_new_inode.  
-** DQUOT_INIT needs lots of credits so it's better to have it
+/* utility function that does setup for reiserfs_new_inode.
+** vfs_dq_init needs lots of credits so it's better to have it
 ** outside of a transaction, so we had to pull some bits of
 ** reiserfs_new_inode out into this func.
 */
@@ -583,7 +570,7 @@ static int new_inode_init(struct inode *inode, struct inode *dir, int mode)
        } else {
                inode->i_gid = current_fsgid();
        }
-       DQUOT_INIT(inode);
+       vfs_dq_init(inode);
        return 0;
 }
 
@@ -598,6 +585,7 @@ static int reiserfs_create(struct inode *dir, struct dentry *dentry, int mode,
            2 * (REISERFS_QUOTA_INIT_BLOCKS(dir->i_sb) +
                 REISERFS_QUOTA_TRANS_BLOCKS(dir->i_sb));
        struct reiserfs_transaction_handle th;
+       struct reiserfs_security_handle security;
 
        if (!(inode = new_inode(dir->i_sb))) {
                return -ENOMEM;
@@ -605,6 +593,12 @@ static int reiserfs_create(struct inode *dir, struct dentry *dentry, int mode,
        new_inode_init(inode, dir, mode);
 
        jbegin_count += reiserfs_cache_default_acl(dir);
+       retval = reiserfs_security_init(dir, inode, &security);
+       if (retval < 0) {
+               drop_new_inode(inode);
+               return retval;
+       }
+       jbegin_count += retval;
        reiserfs_write_lock(dir->i_sb);
 
        retval = journal_begin(&th, dir->i_sb, jbegin_count);
@@ -615,7 +609,7 @@ static int reiserfs_create(struct inode *dir, struct dentry *dentry, int mode,
 
        retval =
            reiserfs_new_inode(&th, dir, mode, NULL, 0 /*i_size */ , dentry,
-                              inode);
+                              inode, &security);
        if (retval)
                goto out_failed;
 
@@ -655,6 +649,7 @@ static int reiserfs_mknod(struct inode *dir, struct dentry *dentry, int mode,
        int retval;
        struct inode *inode;
        struct reiserfs_transaction_handle th;
+       struct reiserfs_security_handle security;
        /* We need blocks for transaction + (user+group)*(quotas for new inode + update of quota for directory owner) */
        int jbegin_count =
            JOURNAL_PER_BALANCE_CNT * 3 +
@@ -670,6 +665,12 @@ static int reiserfs_mknod(struct inode *dir, struct dentry *dentry, int mode,
        new_inode_init(inode, dir, mode);
 
        jbegin_count += reiserfs_cache_default_acl(dir);
+       retval = reiserfs_security_init(dir, inode, &security);
+       if (retval < 0) {
+               drop_new_inode(inode);
+               return retval;
+       }
+       jbegin_count += retval;
        reiserfs_write_lock(dir->i_sb);
 
        retval = journal_begin(&th, dir->i_sb, jbegin_count);
@@ -680,7 +681,7 @@ static int reiserfs_mknod(struct inode *dir, struct dentry *dentry, int mode,
 
        retval =
            reiserfs_new_inode(&th, dir, mode, NULL, 0 /*i_size */ , dentry,
-                              inode);
+                              inode, &security);
        if (retval) {
                goto out_failed;
        }
@@ -723,6 +724,7 @@ static int reiserfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
        int retval;
        struct inode *inode;
        struct reiserfs_transaction_handle th;
+       struct reiserfs_security_handle security;
        /* We need blocks for transaction + (user+group)*(quotas for new inode + update of quota for directory owner) */
        int jbegin_count =
            JOURNAL_PER_BALANCE_CNT * 3 +
@@ -740,6 +742,12 @@ static int reiserfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
        new_inode_init(inode, dir, mode);
 
        jbegin_count += reiserfs_cache_default_acl(dir);
+       retval = reiserfs_security_init(dir, inode, &security);
+       if (retval < 0) {
+               drop_new_inode(inode);
+               return retval;
+       }
+       jbegin_count += retval;
        reiserfs_write_lock(dir->i_sb);
 
        retval = journal_begin(&th, dir->i_sb, jbegin_count);
@@ -756,7 +764,7 @@ static int reiserfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
            retval = reiserfs_new_inode(&th, dir, mode, NULL /*symlink */ ,
                                        old_format_only(dir->i_sb) ?
                                        EMPTY_DIR_SIZE_V1 : EMPTY_DIR_SIZE,
-                                       dentry, inode);
+                                       dentry, inode, &security);
        if (retval) {
                dir->i_nlink--;
                goto out_failed;
@@ -799,7 +807,7 @@ static inline int reiserfs_empty_dir(struct inode *inode)
 {
        /* we can cheat because an old format dir cannot have
         ** EMPTY_DIR_SIZE, and a new format dir cannot have
-        ** EMPTY_DIR_SIZE_V1.  So, if the inode is either size, 
+        ** EMPTY_DIR_SIZE_V1.  So, if the inode is either size,
         ** regardless of disk format version, the directory is empty.
         */
        if (inode->i_size != EMPTY_DIR_SIZE &&
@@ -999,6 +1007,7 @@ static int reiserfs_symlink(struct inode *parent_dir,
        char *name;
        int item_len;
        struct reiserfs_transaction_handle th;
+       struct reiserfs_security_handle security;
        int mode = S_IFLNK | S_IRWXUGO;
        /* We need blocks for transaction + (user+group)*(quotas for new inode + update of quota for directory owner) */
        int jbegin_count =
@@ -1011,6 +1020,13 @@ static int reiserfs_symlink(struct inode *parent_dir,
        }
        new_inode_init(inode, parent_dir, mode);
 
+       retval = reiserfs_security_init(parent_dir, inode, &security);
+       if (retval < 0) {
+               drop_new_inode(inode);
+               return retval;
+       }
+       jbegin_count += retval;
+
        reiserfs_write_lock(parent_dir->i_sb);
        item_len = ROUND_UP(strlen(symname));
        if (item_len > MAX_DIRECT_ITEM_LEN(parent_dir->i_sb->s_blocksize)) {
@@ -1037,7 +1053,7 @@ static int reiserfs_symlink(struct inode *parent_dir,
 
        retval =
            reiserfs_new_inode(&th, parent_dir, mode, name, strlen(symname),
-                              dentry, inode);
+                              dentry, inode, &security);
        kfree(name);
        if (retval) {           /* reiserfs_new_inode iputs for us */
                goto out_failed;
@@ -1133,7 +1149,7 @@ static int reiserfs_link(struct dentry *old_dentry, struct inode *dir,
        return retval;
 }
 
-// de contains information pointing to an entry which 
+/* de contains information pointing to an entry which */
 static int de_still_valid(const char *name, int len,
                          struct reiserfs_dir_entry *de)
 {
@@ -1177,10 +1193,10 @@ static void set_ino_in_dir_entry(struct reiserfs_dir_entry *de,
        de->de_deh[de->de_entry_num].deh_objectid = key->k_objectid;
 }
 
-/* 
+/*
  * process, that is going to call fix_nodes/do_balance must hold only
  * one path. If it holds 2 or more, it can get into endless waiting in
- * get_empty_nodes or its clones 
+ * get_empty_nodes or its clones
  */
 static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
                           struct inode *new_dir, struct dentry *new_dentry)
@@ -1234,7 +1250,7 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 
        old_inode_mode = old_inode->i_mode;
        if (S_ISDIR(old_inode_mode)) {
-               // make sure, that directory being renamed has correct ".." 
+               // make sure, that directory being renamed has correct ".."
                // and that its new parent directory has not too many links
                // already
 
@@ -1245,8 +1261,8 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
                        }
                }
 
-               /* directory is renamed, its parent directory will be changed, 
-                ** so find ".." entry 
+               /* directory is renamed, its parent directory will be changed,
+                ** so find ".." entry
                 */
                dot_dot_de.de_gen_number_bit_string = NULL;
                retval =
@@ -1356,9 +1372,9 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
                   this stuff, yes? Then, having
                   gathered everything into RAM we
                   should lock the buffers, yes?  -Hans */
-               /* probably.  our rename needs to hold more 
-                ** than one path at once.  The seals would 
-                ** have to be written to deal with multi-path 
+               /* probably.  our rename needs to hold more
+                ** than one path at once.  The seals would
+                ** have to be written to deal with multi-path
                 ** issues -chris
                 */
                /* sanity checking before doing the rename - avoid races many
@@ -1436,7 +1452,7 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
        }
 
        if (S_ISDIR(old_inode_mode)) {
-               // adjust ".." of renamed directory 
+               /* adjust ".." of renamed directory */
                set_ino_in_dir_entry(&dot_dot_de, INODE_PKEY(new_dir));
                journal_mark_dirty(&th, new_dir->i_sb, dot_dot_de.de_bh);