[PVFS2-CVS] commit by neill in pvfs2/src/common/misc: pvfs2-util.c

CVS commit program cvs at parl.clemson.edu
Fri May 21 15:52:07 EDT 2004


Update of /projects/cvsroot/pvfs2/src/common/misc
In directory parlweb:/tmp/cvs-serv16386/src/common/misc

Modified Files:
	pvfs2-util.c 
Log Message:
- for non-blocking the passed in sys_attr structures need to be copied
  to avoid stack corruption/bunk values (similar to credential problem;
  there are probably more instances just like this, and they'll be fixed
  as they come)


Index: pvfs2-util.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/common/misc/pvfs2-util.c,v
diff -p -u -r1.59 -r1.60
--- pvfs2-util.c	21 May 2004 17:22:39 -0000	1.59
+++ pvfs2-util.c	21 May 2004 18:52:07 -0000	1.60
@@ -86,6 +86,49 @@ void PVFS_util_release_credentials(
     }
 }
 
+int PVFS_util_copy_sys_attr(
+    PVFS_sys_attr *dest, PVFS_sys_attr *src)
+{
+    int ret = -PVFS_EINVAL;
+
+    if (src && dest)
+    {
+        dest->owner = src->owner;
+        dest->group = src->group;
+        dest->perms = src->perms;
+        dest->atime = src->atime;
+        dest->mtime = src->mtime;
+        dest->ctime = src->ctime;
+        dest->dfile_count = src->dfile_count;
+        dest->objtype = src->objtype;
+        dest->mask = src->mask;
+
+        if ((src->mask & PVFS_ATTR_COMMON_TYPE) &&
+            (src->objtype == PVFS_TYPE_SYMLINK) && src->link_target)
+        {
+            dest->link_target = strdup(src->link_target);
+            if (!dest->link_target)
+            {
+                ret = -PVFS_ENOMEM;
+            }
+        }
+    }
+    return ret;
+}
+
+void PVFS_util_release_sys_attr(PVFS_sys_attr *attr)
+{
+    if (attr)
+    {
+        if ((attr->mask & PVFS_ATTR_COMMON_TYPE) &&
+            (attr->objtype == PVFS_TYPE_SYMLINK) && attr->link_target)
+        {
+            free(attr->link_target);
+            attr->link_target = NULL;
+        }
+    }
+}
+
 /* PVFS_util_parse_pvfstab()
  *
  * parses either the file pointed to by the PVFS2TAB_FILE env



More information about the PVFS2-CVS mailing list