[Pvfs2-cvs] commit by nlmills in pvfs2/src/kernel/linux-2.6: .cvsignore namei.c pvfs2-utils.c

CVS commit program cvs at parl.clemson.edu
Fri May 21 13:34:22 EDT 2010


Update of /projects/cvsroot/pvfs2/src/kernel/linux-2.6
In directory parlweb1:/tmp/cvs-serv1309/src/kernel/linux-2.6

Modified Files:
      Tag: cu-security-branch
	namei.c pvfs2-utils.c 
Added Files:
      Tag: cu-security-branch
	.cvsignore 
Log Message:
revert cu-security-branch to before the attempted merge with Orange-Branch



Index: namei.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/namei.c,v
diff -p -u -r1.83.8.2 -r1.83.8.3
--- namei.c	2 Sep 2009 20:16:15 -0000	1.83.8.2
+++ namei.c	21 May 2010 17:34:22 -0000	1.83.8.3
@@ -200,9 +200,9 @@ static struct dentry *pvfs2_lookup(
     inode = pvfs2_iget(sb, &new_op->downcall.resp.lookup.refn);
     if (inode && !is_bad_inode(inode))
     {
+        struct dentry *res;
         gossip_debug(GOSSIP_NAME_DEBUG, "%s:%s:%d Found good inode [%lu] with count [%d]\n", 
             __FILE__, __func__, __LINE__, inode->i_ino, (int)atomic_read(&inode->i_count));
-        struct dentry *res;
 
         /* update dentry/inode pair into dcache */
         dentry->d_op = &pvfs2_dentry_operations;

Index: pvfs2-utils.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/pvfs2-utils.c,v
diff -p -u -r1.151.2.4 -r1.151.2.5
--- pvfs2-utils.c	2 Sep 2009 20:16:15 -0000	1.151.2.4
+++ pvfs2-utils.c	21 May 2010 17:34:22 -0000	1.151.2.5
@@ -667,6 +667,32 @@ int pvfs2_flush_inode(struct inode *inod
 /* directory entry key */
 #define DIRENT_KEY  "system.pvfs2." DIRECTORY_ENTRY_KEYSTR
 
+/* Extended attributes helper functions */
+static char *xattr_non_zero_terminated[] = {
+    DFILE_KEY,
+    DIST_KEY,
+    ROOT_KEY,
+};
+
+/* Extended attributes helper functions */
+
+/*
+ * this function returns 
+ * 0 if the val corresponding to name is known to be not terminated with an explicit \0
+ * 1 if the val corresponding to name is known to be \0 terminated
+ */
+static int xattr_zero_terminated(const char *name)
+{
+    int i;
+    static int xattr_count = sizeof(xattr_non_zero_terminated)/sizeof(char *);
+    for (i = 0;i < xattr_count; i++)
+    {
+        if (strcmp(name, xattr_non_zero_terminated[i]) == 0)
+            return 0;
+    }
+    return 1;
+}
+
 static char *xattr_resvd_keys[] = {
     DFILE_KEY,
     DIST_KEY,
@@ -764,15 +790,33 @@ ssize_t pvfs2_inode_getxattr(struct inod
          */
         if (ret == 0)
         {
+            ssize_t new_length;
             length = new_op->downcall.resp.getxattr.val_sz;
+            /*
+             * if the xattr corresponding to name was not terminated with a \0
+             * then we return the entire response length
+             */
+            if (xattr_zero_terminated(name) == 0)
+            {
+                new_length = length;
+            }
+            /*
+             * if it was terminated by a \0 then we return 1 less for the getfattr
+             * programs to play nicely with displaying it
+             */
+            else {
+                new_length = length - 1;
+            }
+            /* Just return the length of the queried attribute after
+             * subtracting the \0 thingie */
             if (size == 0)
             {
-                ret = length;
+                ret = new_length;
             }
             else
             {
-                /* check to see if val length is > provided buffer size */
-                if (length > size)
+                /* check to see if key length is > provided buffer size */
+                if (new_length > size)
                 {
                     ret = -ERANGE;
                 }
@@ -781,10 +825,10 @@ ssize_t pvfs2_inode_getxattr(struct inod
                     /* No size problems */
                     memset(buffer, 0, size);
                     memcpy(buffer, new_op->downcall.resp.getxattr.val, 
-                           length);
-                    ret = length; 
-                    gossip_debug(GOSSIP_XATTR_DEBUG,"pvfs2_inode_getxattr: "
-                        "inode %llu key %s key_sz %d, val_length %d\n", 
+                            new_length);
+                    ret = new_length;
+                    gossip_debug(GOSSIP_XATTR_DEBUG, "pvfs2_inode_getxattr: inode %llu key %s "
+                            " key_sz %d, val_length %d\n", 
                         llu(get_handle_from_ino(inode)),
                         (char*)new_op->upcall.req.getxattr.key, 
                         (int) new_op->upcall.req.getxattr.key_sz, (int) ret);
@@ -794,10 +838,8 @@ ssize_t pvfs2_inode_getxattr(struct inod
         else if (ret == -ENOENT)
         {
             ret = -ENODATA; /* if no such keys exists we set this to be errno */
-            gossip_debug(GOSSIP_XATTR_DEBUG,"pvfs2_inode_getxattr: inode %llu "
-                                            "key %s does not exist!\n"
-                                      ,llu(get_handle_from_ino(inode))
-                                      ,(char *)new_op->upcall.req.getxattr.key);
+            gossip_debug(GOSSIP_XATTR_DEBUG, "pvfs2_inode_getxattr: inode %llu key %s does not exist!\n",
+                    llu(get_handle_from_ino(inode)), (char *) new_op->upcall.req.getxattr.key);
         }
 
         /* when request is serviced properly, free req op struct */
@@ -818,8 +860,6 @@ int pvfs2_inode_setxattr(struct inode *i
     int ret = -ENOMEM;
     pvfs2_kernel_op_t *new_op = NULL;
     pvfs2_inode_t *pvfs2_inode = NULL;
-    int i;
-    char *valBuf;
 
     if (size < 0 || size >= PVFS_MAX_XATTR_VALUELEN || flags < 0)
     {
@@ -895,28 +935,21 @@ int pvfs2_inode_setxattr(struct inode *i
         new_op->upcall.req.setxattr.keyval.key_sz = 
             ret + 1;
         memcpy(new_op->upcall.req.setxattr.keyval.val, value, size);
-        new_op->upcall.req.setxattr.keyval.val_sz = size;
-
-        gossip_debug(GOSSIP_XATTR_DEBUG,"Upcall: size=%d\n"
-                    ,new_op->upcall.req.setxattr.keyval.val_sz);
-        valBuf = (char *)new_op->upcall.req.setxattr.keyval.val;
-        for (i=0; i<new_op->upcall.req.setxattr.keyval.val_sz; i++)
-            gossip_debug(GOSSIP_XATTR_DEBUG,"\tval[%d]=%#x\n"
-                        ,i
-                        ,(unsigned int)valBuf[i]);
+        new_op->upcall.req.setxattr.keyval.val[size] = '\0';
+        /* For some reason, val_sz should include the \0 at the end as well */
+        new_op->upcall.req.setxattr.keyval.val_sz = size + 1;
 
-        gossip_debug(GOSSIP_XATTR_DEBUG, "pvfs2_inode_setxattr: key %s, "
-                "key_sz %d value size %zd\n", 
+        gossip_debug(GOSSIP_XATTR_DEBUG, "pvfs2_inode_setxattr: key %s, key_sz %d "
+                " value size %zd\n", 
                  (char*)new_op->upcall.req.setxattr.keyval.key, 
                  (int) new_op->upcall.req.setxattr.keyval.key_sz,
-                 size);
+                 size + 1);
 
         ret = service_operation(
             new_op, "pvfs2_inode_setxattr", 
             get_interruptible_flag(inode));
 
-        gossip_debug(GOSSIP_XATTR_DEBUG,"pvfs2_inode_setxattr: returning %d\n"
-                                       , ret);
+        gossip_debug(GOSSIP_XATTR_DEBUG, "pvfs2_inode_setxattr: returning %d\n", ret);
 
         /* when request is serviced properly, free req op struct */
         op_release(new_op);



More information about the Pvfs2-cvs mailing list