[PVFS2-CVS]
commit by bradles in pvfs2/test/client/sysint: create-with-dist.c
module.mk.in
CVS commit program
cvs at parl.clemson.edu
Mon May 17 12:58:11 EDT 2004
Update of /projects/cvsroot/pvfs2/test/client/sysint
In directory styx.parl.clemson.edu:/tmp/cvs-serv15405/client/sysint
Modified Files:
module.mk.in
Added Files:
create-with-dist.c
Log Message:
Updates for distribution renaming, and added test case for creation with
user specified distributions.
--- /dev/null 2003-01-30 05:24:37.000000000 -0500
+++ create-with-dist.c 2004-05-17 11:58:11.000000000 -0400
@@ -0,0 +1,114 @@
+/*
+ * (C) 2001 Clemson University and The University of Chicago
+ *
+ * See COPYING in top-level directory.
+ */
+
+#include <time.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+#include "client.h"
+#include "pvfs2-util.h"
+#include "str-utils.h"
+
+int main(int argc, char **argv)
+{
+ int ret = -1;
+ char str_buf[256] = {0};
+ char *filename = (char *)0;
+ PVFS_fs_id cur_fs;
+ PVFS_sysresp_create resp_create;
+ char* entry_name;
+ PVFS_object_ref parent_refn;
+ PVFS_sys_attr attr;
+ PVFS_credentials credentials;
+ PVFS_sys_dist* dist;
+
+ if (argc != 2)
+ {
+ fprintf(stderr,"Usage: %s filename\n",argv[0]);
+ return ret;
+ }
+ filename = argv[1];
+
+ ret = PVFS_util_init_defaults();
+ if (ret < 0)
+ {
+ PVFS_perror("PVFS_util_init_defaults", ret);
+ return (-1);
+ }
+ ret = PVFS_util_get_default_fsid(&cur_fs);
+ if (ret < 0)
+ {
+ PVFS_perror("PVFS_util_get_default_fsid", ret);
+ return (-1);
+ }
+
+ if (PVFS_util_remove_base_dir(filename,str_buf,256))
+ {
+ if (filename[0] != '/')
+ {
+ printf("You forgot the leading '/'\n");
+ }
+ printf("Cannot retrieve entry name for creation on %s\n",
+ filename);
+ return(-1);
+ }
+
+ memset(&resp_create, 0, sizeof(PVFS_sysresp_create));
+ PVFS_util_gen_credentials(&credentials);
+
+ entry_name = str_buf;
+ attr.mask = PVFS_ATTR_SYS_ALL_SETABLE;
+ attr.owner = credentials.uid;
+ attr.group = credentials.gid;
+ attr.perms = 1877;
+ attr.atime = attr.ctime = attr.mtime =
+ time(NULL);
+
+ ret = PVFS_util_lookup_parent(filename, cur_fs, credentials,
+ &parent_refn.handle);
+ if(ret < 0)
+ {
+ PVFS_perror("PVFS_util_lookup_parent", ret);
+ return(-1);
+ }
+ parent_refn.fs_id = cur_fs;
+
+ printf("File to be created is %s under parent %Lu\n",
+ str_buf, Lu(parent_refn.handle));
+
+ /* Lookup the distribution to use */
+ dist = PVFS_sys_dist_lookup("basic_dist");
+ if (0 == dist)
+ {
+ printf("Failed to create distribution basic_dist.");
+ return -1;
+ }
+
+ ret = PVFS_sys_create(entry_name, parent_refn, attr,
+ credentials, dist, &resp_create);
+ if (ret < 0)
+ {
+ PVFS_perror("create failed with errcode", ret);
+ return(-1);
+ }
+
+ /* Free the distribution */
+ PVFS_sys_dist_free(dist);
+
+ // print the handle
+ printf("--create--\n");
+ printf("Handle: %Ld\n",Ld(resp_create.ref.handle));
+
+ ret = PVFS_sys_finalize();
+ if (ret < 0)
+ {
+ printf("finalizing sysint failed with errcode = %d\n", ret);
+ return (-1);
+ }
+
+ return(0);
+}
Index: module.mk.in
===================================================================
RCS file: /projects/cvsroot/pvfs2/test/client/sysint/module.mk.in,v
diff -p -u -r1.43 -r1.44
--- module.mk.in 15 Apr 2004 00:19:59 -0000 1.43
+++ module.mk.in 17 May 2004 15:58:11 -0000 1.44
@@ -15,6 +15,7 @@ TESTSRC += \
$(DIR)/ls.c \
$(DIR)/path-test.c\
$(DIR)/create.c\
+ $(DIR)/create-with-dist.c\
$(DIR)/symlink.c\
$(DIR)/flush-1.c\
$(DIR)/flush-2.c\
More information about the PVFS2-CVS
mailing list