[PVFS2-CVS] commit by robl in pvfs2-1/src/kernel/linux-2.6: acl.c inode.c pvfs2-utils.c super.c

CVS commit program cvs at parl.clemson.edu
Mon Nov 28 11:49:51 EST 2005


Update of /projects/cvsroot/pvfs2-1/src/kernel/linux-2.6
In directory parlweb:/tmp/cvs-serv4069/src/kernel/linux-2.6

Modified Files:
      Tag: pvfs2-1-3-1-branch
	acl.c inode.c pvfs2-utils.c super.c 
Log Message:
Murali's fix for permissions on the root directory.  Make the root directory
sticky by default and prevent updating inode->i_mode if it's the root
directory.


Index: acl.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/kernel/linux-2.6/acl.c,v
diff -u -w -p -u -r1.7 -r1.7.4.1
--- acl.c	26 Oct 2005 16:27:18 -0000	1.7
+++ acl.c	28 Nov 2005 16:49:50 -0000	1.7.4.1
@@ -436,7 +436,7 @@ int pvfs2_init_acl(struct inode *inode, 
             if (IS_ERR(acl))
                 return PTR_ERR(acl);
         }
-        if (!acl)
+        if (!acl && dir != inode)
         {
             inode->i_mode &= ~current->fs->umask;
         }
@@ -534,7 +534,17 @@ static int pvfs2_check_acl(struct inode 
 int pvfs2_permission(struct inode *inode, int mask, struct nameidata *nd)
 {
 #ifdef HAVE_GENERIC_PERMISSION
-    return generic_permission(inode, mask, pvfs2_check_acl);
+    int ret;
+
+    ret = generic_permission(inode, mask, pvfs2_check_acl);
+    pvfs2_print("pvfs2_permission: inode: %p mask = %x mode = %x current->fsuid = %x "
+            "inode->i_uid = %x, inode->i_gid = %x  ret = %d\n",
+            inode, mask, inode->i_mode, current->fsuid, inode->i_uid, 
+                inode->i_gid, ret);
+    pvfs2_print("pvfs2_permission: mode [%x] & mask [%x] & S_IRWXO [%x] = %d == mask [%x]?\n", 
+            inode->i_mode, mask, S_IRWXO, (inode->i_mode & mask & S_IRWXO), 
+                mask);
+    return ret;
 #else
     /* We sort of duplicate the code below from generic_permission. */
     int mode = inode->i_mode;

Index: inode.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/kernel/linux-2.6/inode.c,v
diff -u -w -p -u -r1.61 -r1.61.4.1
--- inode.c	27 Oct 2005 18:43:09 -0000	1.61
+++ inode.c	28 Nov 2005 16:49:50 -0000	1.61.4.1
@@ -430,7 +430,10 @@ struct inode *pvfs2_get_custom_inode(
             return NULL;
         }
 
+        if (inode->i_ino != PVFS2_SB(inode->i_sb)->root_handle)
+        {
         inode->i_mode = mode;
+        }
         inode->i_mapping->host = inode;
         inode->i_uid = current->fsuid;
         inode->i_gid = current->fsgid;

Index: pvfs2-utils.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/kernel/linux-2.6/pvfs2-utils.c,v
diff -u -w -p -u -r1.109.2.1 -r1.109.2.2
--- pvfs2-utils.c	11 Nov 2005 21:38:12 -0000	1.109.2.1
+++ pvfs2-utils.c	28 Nov 2005 16:49:51 -0000	1.109.2.2
@@ -48,7 +48,7 @@ static inline int copy_attributes_to_ino
     char *symname)
 {
     int ret = -1;
-    int perm_mode = 0;
+    int perm_mode = 0, old_mode = 0;
     pvfs2_inode_t *pvfs2_inode = NULL;
     loff_t inode_size = 0, rounded_up_size = 0;
 
@@ -135,6 +135,7 @@ static inline int copy_attributes_to_ino
         inode->i_mtime.tv_nsec = 0;
         inode->i_ctime.tv_nsec = 0;
 #endif
+        old_mode = inode->i_mode;
         inode->i_mode = 0;
 
         if (attrs->perms & PVFS_O_EXECUTE)
@@ -162,6 +163,16 @@ static inline int copy_attributes_to_ino
             perm_mode |= S_ISGID;
 
         inode->i_mode |= perm_mode;
+        /* NOTE: this will change once we move from the iget() model to the
+         * iget5() interface where i_ino will only be a hash and not the actual
+         * handle itself!
+         * Most file systems have moved to that model
+         */
+        if (inode->i_ino == PVFS2_SB(inode->i_sb)->root_handle)
+        {
+            /* special case: mark the root inode as sticky */
+            inode->i_mode |= S_ISVTX;
+        }
 
         switch (attrs->objtype)
         {
@@ -210,6 +221,8 @@ static inline int copy_attributes_to_ino
                 pvfs2_error("pvfs2:copy_attributes_to_inode: got invalid "
                             "attribute type %d\n", attrs->objtype);
         }
+        pvfs2_print("pvfs2: copy_attributes_to_inode: setting inode->i_mode to %x from %x\n",
+                inode->i_mode, old_mode);
     }
     return ret;
 }

Index: super.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/kernel/linux-2.6/super.c,v
diff -u -w -p -u -r1.64.4.1 -r1.64.4.2
--- super.c	28 Nov 2005 16:36:18 -0000	1.64.4.1
+++ super.c	28 Nov 2005 16:49:51 -0000	1.64.4.2
@@ -604,14 +604,16 @@ struct super_block* pvfs2_get_sb(
     sb->s_blocksize_bits = PVFS2_BUFMAP_DEFAULT_DESC_SHIFT;
     sb->s_maxbytes = MAX_LFS_FILESIZE;
 
-    /* alloc and initialize our root directory inode */
+    /* alloc and initialize our root directory inode by explicitly requesting
+     * the sticky bit to be set */
     root = pvfs2_get_custom_inode(
-        sb, NULL, (S_IFDIR | 0755), 0, PVFS2_SB(sb)->root_handle);
+        sb, NULL, (S_IFDIR | 0755 | S_ISVTX), 0, PVFS2_SB(sb)->root_handle);
     if (!root)
     {
         ret = -ENOMEM;
         goto error_exit;
     }
+    pvfs2_print("Allocated root inode [%p] with mode %x\n", root, root->i_mode);
     PVFS2_I(root)->refn.fs_id = PVFS2_SB(sb)->fs_id;
 
     /* allocates and places root dentry in dcache */
@@ -711,13 +713,15 @@ int pvfs2_fill_sb(
     sb->s_blocksize_bits = PVFS2_BUFMAP_DEFAULT_DESC_SHIFT;
     sb->s_maxbytes = MAX_LFS_FILESIZE;
 
-    /* alloc and initialize our root directory inode */
-    root = pvfs2_get_custom_inode(sb, NULL, (S_IFDIR | 0755),
+    /* alloc and initialize our root directory inode. be explicit about sticky
+     * bit */
+    root = pvfs2_get_custom_inode(sb, NULL, (S_IFDIR | 0755 | S_ISVTX),
                                   0, PVFS2_SB(sb)->root_handle);
     if (!root)
     {
         return -ENOMEM;
     }
+    pvfs2_print("Allocated root inode [%p] with mode %x\n", root, root->i_mode);
     PVFS2_I(root)->refn.handle = PVFS2_SB(sb)->root_handle;
     PVFS2_I(root)->refn.fs_id = PVFS2_SB(sb)->fs_id;
 



More information about the PVFS2-CVS mailing list