[Pvfs2-cvs] commit by slang in pvfs2/src/apps/admin: pvfs2-xattr.c module.mk.in pvfs2-genconfig pvfs2-ln.c pvfs2-ls.c pvfs2-migrate-collection.c pvfs2-mkdir.c pvfs2-mkspace.c pvfs2-perror.c pvfs2-remove-object.c pvfs2-set-debugmask.c pvfs2-showcoll.c pvfs2-stat.c

CVS commit program cvs at parl.clemson.edu
Thu Oct 19 18:16:41 EDT 2006


Update of /projects/cvsroot/pvfs2/src/apps/admin
In directory parlweb1:/tmp/cvs-serv5758/src/apps/admin

Modified Files:
      Tag: WALT3
	module.mk.in pvfs2-genconfig pvfs2-ln.c pvfs2-ls.c 
	pvfs2-migrate-collection.c pvfs2-mkdir.c pvfs2-mkspace.c 
	pvfs2-perror.c pvfs2-remove-object.c pvfs2-set-debugmask.c 
	pvfs2-showcoll.c pvfs2-stat.c 
Added Files:
      Tag: WALT3
	pvfs2-xattr.c 
Log Message:
reverse merge of HEAD to WALT3 branch.


--- /dev/null	2004-06-24 14:04:38.000000000 -0400
+++ pvfs2-xattr.c	2006-10-19 18:16:41.000000000 -0400
@@ -0,0 +1,458 @@
+/*
+ * (C) 2004 Clemson University and The University of Chicago
+ * 
+ * See COPYING in top-level directory.
+ */
+
+#include <unistd.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/time.h>
+#include <time.h>
+#include <stdlib.h>
+#include <getopt.h>
+
+#define __PINT_REQPROTO_ENCODE_FUNCS_C
+#include "pvfs2.h"
+#include "str-utils.h"
+#include "pint-sysint-utils.h"
+#include "pint-util.h"
+#include "pvfs2-internal.h"
+#include "pvfs2-req-proto.h"
+#ifdef HAVE_SYS_XATTR_H
+#include <sys/xattr.h>
+#endif
+
+#ifdef HAVE_ATTR_XATTR_H
+#include <attr/xattr.h>
+#endif
+
+
+#define VALBUFSZ 1024
+
+/* extended attribute name spaces supported in PVFS2 */
+const char *PINT_eattr_namespaces[] =
+{
+    "system.",
+    "user.",
+    "trusted.",
+    "security.",
+    NULL
+};
+
+/* optional parameters, filled in by parse_args() */
+struct options
+{
+    PVFS_ds_keyval key;
+    PVFS_ds_keyval val;
+    char* srcfile;
+    int get, text;
+};
+
+enum object_type { 
+    UNIX_FILE, 
+    PVFS2_FILE 
+};
+
+typedef struct pvfs2_file_object_s {
+    PVFS_fs_id fs_id;
+    PVFS_object_ref ref;
+    char pvfs2_path[PVFS_NAME_MAX];	
+    char user_path[PVFS_NAME_MAX];
+    PVFS_sys_attr attr;
+    PVFS_permissions perms;
+} pvfs2_file_object;
+
+typedef struct unix_file_object_s {
+    int fd;
+    int mode;
+    char path[NAME_MAX];
+    PVFS_fs_id fs_id;
+} unix_file_object;
+
+typedef struct file_object_s {
+    int fs_type;
+    union {
+	unix_file_object ufs;
+	pvfs2_file_object pvfs2;
+    } u;
+} file_object;
+
+static struct options* parse_args(int argc, char* argv[]);
+static int generic_open(file_object *obj, PVFS_credentials *credentials);
+static int pvfs2_eattr(int get, file_object *, PVFS_ds_keyval *key_p,
+        PVFS_ds_keyval *val_p, PVFS_credentials *creds);
+static void usage(int argc, char** argv);
+static int resolve_filename(file_object *obj, char *filename);
+static int modify_val(PVFS_ds_keyval *key_p, PVFS_ds_keyval *val_p);
+static int permit_set(PVFS_ds_keyval *key_p);
+static int eattr_is_prefixed(char* key_name);
+
+int main(int argc, char **argv)
+{
+  int ret = 0;
+  struct options* user_opts = NULL;
+  file_object src;
+  PVFS_credentials credentials;
+
+  memset(&src, 0, sizeof(src));
+  /* look at command line arguments */
+  user_opts = parse_args(argc, argv);
+  if(!user_opts)
+  {
+    fprintf(stderr, "Error: failed to parse "
+            "command line arguments.\n");
+    return(-1);
+  }
+
+  ret = PVFS_util_init_defaults();
+  if(ret < 0)
+  {
+    PVFS_perror("PVFS_util_init_defaults", ret);
+    return(-1);
+  }
+  resolve_filename(&src, user_opts->srcfile);
+
+  PVFS_util_gen_credentials(&credentials);
+  ret = generic_open(&src, &credentials);
+  if (ret < 0)
+  {
+      fprintf(stderr, "Could not open %s\n", user_opts->srcfile);
+      return -1;
+  }
+  if (!eattr_is_prefixed(user_opts->key.buffer))
+  {
+      fprintf(stderr, "extended attribute key is not prefixed %s\n", (char *) user_opts->key.buffer);
+      return -1;
+  }
+  if (!user_opts->get)
+  {
+      if (!permit_set(&user_opts->key))
+      {
+          fprintf(stderr, "Not permitted to set key %s\n", (char *) user_opts->key.buffer);
+          return -1;
+      }
+      if (modify_val(&user_opts->key, &user_opts->val) < 0)
+      {
+          fprintf(stderr, "Invalid value for user-settable hint %s, %s\n", (char *) user_opts->key.buffer, (char *) user_opts->val.buffer);
+          return -1;
+      }
+  }
+
+    ret = pvfs2_eattr(user_opts->get, &src, &user_opts->key, &user_opts->val, &credentials);
+    if (ret != 0) 
+    {
+        return ret;
+    }
+    if (user_opts->get && user_opts->text)  
+    {
+        printf("key:%s Value:\n%s\n",
+                (char *)user_opts->key.buffer,
+                (char *)user_opts->val.buffer);
+    }
+  PVFS_sys_finalize();
+  return(ret);
+}
+
+static int modify_val(PVFS_ds_keyval *key_p, PVFS_ds_keyval *val_p)
+{
+    if (strncmp(key_p->buffer, "user.pvfs2.meta_hint", SPECIAL_METAFILE_HINT_KEYLEN) == 0)
+    {
+        PVFS_metafile_hint hint;
+        memset(&hint, 0, sizeof(hint));
+        if (strncmp(val_p->buffer, "+immutable", 10) == 0)
+            hint.flags |= PVFS_IMMUTABLE_FL;
+        else if (strncmp(val_p->buffer, "-immutable", 10) == 0)
+            hint.flags &= ~PVFS_IMMUTABLE_FL;
+        else if (strncmp(val_p->buffer, "+append", 7) == 0)
+            hint.flags |= PVFS_APPEND_FL;
+        else if (strncmp(val_p->buffer, "-append", 7) == 0)
+            hint.flags &= ~PVFS_APPEND_FL;
+        else if (strncmp(val_p->buffer, "+noatime", 8) == 0)
+            hint.flags |= PVFS_NOATIME_FL;
+        else if (strncmp(val_p->buffer, "-noatime", 8) == 0)
+            hint.flags &= ~PVFS_NOATIME_FL;
+        else 
+            return -1;
+        memcpy(val_p->buffer, &hint, sizeof(hint));
+        val_p->buffer_sz = sizeof(hint);
+    }
+    return 0;
+}
+
+static int permit_set(PVFS_ds_keyval *key_p)
+{
+    if (strncmp(key_p->buffer, "system.", 7) == 0
+            || strncmp(key_p->buffer, "trusted.", 8) == 0
+            || strncmp(key_p->buffer, "security.", 9) == 0)
+        return 0;
+    return 1;
+}
+
+/* pvfs2_geteattr()
+ *
+ * changes the mode of the given file to the given permissions
+ *
+ * returns zero on success and negative one on failure
+ */
+static int pvfs2_eattr(int get, file_object *obj, PVFS_ds_keyval *key_p,
+        PVFS_ds_keyval *val_p, PVFS_credentials *creds) 
+{
+  int ret = -1;
+
+  if (obj->fs_type == UNIX_FILE)
+  {
+      if (get == 1)
+      {
+#ifndef HAVE_FGETXATTR_EXTRA_ARGS
+        if ((ret = fgetxattr(obj->u.ufs.fd, key_p->buffer, val_p->buffer, val_p->buffer_sz)) < 0)
+#else
+        if ((ret = fgetxattr(obj->u.ufs.fd, key_p->buffer, val_p->buffer, val_p->buffer_sz, 0, 0)) < 0)
+#endif
+        {
+            perror("fgetxattr:");
+            return -1;
+        }
+      }
+      else
+      {
+        if ((ret = fsetxattr(obj->u.ufs.fd, key_p->buffer, val_p->buffer, val_p->buffer_sz, 0)) < 0)
+        {
+            perror("fsetxattr:");
+            return -1;
+        }
+      }
+  }
+  else
+  {
+      if (get == 1)
+      {
+          ret = PVFS_sys_geteattr(obj->u.pvfs2.ref, creds, key_p, val_p);
+      }
+      else {
+          ret = PVFS_sys_seteattr(obj->u.pvfs2.ref, creds, key_p, val_p, 0);
+      }
+
+      if (ret < 0)
+      {
+          PVFS_perror("PVFS_sys_geteattr", ret);
+          return -1;
+      }
+  }
+  return 0;
+}
+
+
+/* parse_args()
+ *
+ * parses command line arguments
+ *
+ * returns pointer to options structure on success, NULL on failure
+ */
+static struct options* parse_args(int argc, char* argv[])
+{
+    char flags[] = "k:v:ts";
+    int one_opt = 0;
+
+    struct options* tmp_opts = NULL;
+
+    /* create storage for the command line options */
+    tmp_opts = (struct options*)malloc(sizeof(struct options));
+    if(!tmp_opts){
+	return(NULL);
+    }
+    memset(tmp_opts, 0, sizeof(struct options));
+
+    /* fill in defaults */
+    memset(&tmp_opts->key, 0, sizeof(PVFS_ds_keyval));
+    memset(&tmp_opts->val, 0, sizeof(PVFS_ds_keyval));
+    tmp_opts->srcfile = strdup(argv[argc-1]);
+    tmp_opts->get = 1;
+
+    /* look at command line arguments */
+    while((one_opt = getopt(argc, argv, flags)) != EOF)
+    {
+	switch(one_opt){
+            case 't':
+                tmp_opts->text = 1;
+                break;
+            case 's':
+                tmp_opts->get = 0;
+                break;
+            case 'k':
+                tmp_opts->key.buffer = strdup(optarg);
+                tmp_opts->key.buffer_sz = strlen(tmp_opts->key.buffer) + 1;
+                break;
+            case 'v':
+                tmp_opts->val.buffer = strdup(optarg);
+                tmp_opts->val.buffer_sz = strlen(tmp_opts->val.buffer) + 1;
+                break;
+	    case('?'):
+                printf("?\n");
+		usage(argc, argv);
+		exit(EXIT_FAILURE);
+	}
+    }
+    if (tmp_opts->get == 1)
+    {
+        tmp_opts->val.buffer = calloc(1, VALBUFSZ);
+        tmp_opts->val.buffer_sz = VALBUFSZ;
+        if (tmp_opts->val.buffer == NULL)
+        {
+            fprintf(stderr, "Could not allocate val\n");
+            exit(EXIT_FAILURE);
+        }
+    }
+    else {
+        if (tmp_opts->val.buffer == NULL)
+        {
+            fprintf(stderr, "Please specify value if setting extended attributes\n");
+            usage(argc, argv);
+            exit(EXIT_FAILURE);
+        }
+    }
+    if (tmp_opts->key.buffer == NULL)
+    {
+        fprintf(stderr, "Please specify key if getting extended attributes\n");
+        usage(argc, argv);
+        exit(EXIT_FAILURE);
+    }
+    return(tmp_opts);
+}
+
+
+static void usage(int argc, char** argv)
+{
+    fprintf(stderr,"Usage: %s -s {set xattrs} -k <key> -v <val> -t {print attributes} filename\n",argv[0]);
+    return;
+}
+
+/* resolve_filename:
+ *  given 'filename', find the PVFS2 fs_id and relative pvfs_path.  In case of
+ *  error, assume 'filename' is a unix file.
+ */
+static int resolve_filename(file_object *obj, char *filename)
+{
+    int ret;
+
+    ret = PVFS_util_resolve(filename, &(obj->u.pvfs2.fs_id),
+	    obj->u.pvfs2.pvfs2_path, PVFS_NAME_MAX);
+    if (ret < 0)
+    {
+	obj->fs_type = UNIX_FILE;
+        strncpy(obj->u.ufs.path, filename, NAME_MAX);
+    } else {
+	obj->fs_type = PVFS2_FILE;
+	strncpy(obj->u.pvfs2.user_path, filename, PVFS_NAME_MAX);
+    }
+    return 0;
+}
+
+/* generic_open:
+ *  given a file_object, perform the apropriate open calls.  
+ */
+static int generic_open(file_object *obj, PVFS_credentials *credentials)
+{
+    struct stat stat_buf;
+    PVFS_sysresp_lookup resp_lookup;
+    PVFS_sysresp_getattr resp_getattr;
+    PVFS_object_ref ref;
+    int ret = -1;
+
+    if (obj->fs_type == UNIX_FILE)
+    {
+        PINT_statfs_t statfsbuf;
+        memset(&stat_buf, 0, sizeof(struct stat));
+
+        stat(obj->u.ufs.path, &stat_buf);
+        if (!S_ISREG(stat_buf.st_mode))
+        {
+            fprintf(stderr, "Not a file!\n");
+            return(-1);
+        }
+        obj->u.ufs.fd = open(obj->u.ufs.path, O_RDONLY);
+        obj->u.ufs.mode = (int)stat_buf.st_mode;
+	if (obj->u.ufs.fd < 0)
+	{
+	    perror("open");
+	    fprintf(stderr, "could not open %s\n", obj->u.ufs.path);
+	    return (-1);
+	}
+        if (PINT_statfs_fd_lookup(obj->u.ufs.fd, &statfsbuf) < 0)
+        {
+            perror("fstatfs:");
+            fprintf(stderr, "could not fstatfs %s\n", obj->u.ufs.path);
+        }
+        memcpy(&obj->u.ufs.fs_id, &PINT_statfs_fsid(&statfsbuf), 
+               sizeof(PINT_statfs_fsid(&statfsbuf)));
+        return 0;
+    }
+    else
+    {
+        memset(&resp_lookup, 0, sizeof(PVFS_sysresp_lookup));
+        ret = PVFS_sys_lookup(obj->u.pvfs2.fs_id, 
+                              (char *) obj->u.pvfs2.pvfs2_path,
+                              credentials, 
+                              &resp_lookup,
+                              PVFS2_LOOKUP_LINK_FOLLOW);
+        if (ret < 0)
+        {
+            PVFS_perror("PVFS_sys_lookup", ret);
+            return (-1);
+        }
+        ref.handle = resp_lookup.ref.handle;
+        ref.fs_id = resp_lookup.ref.fs_id;
+
+        memset(&resp_getattr, 0, sizeof(PVFS_sysresp_getattr));
+        ret = PVFS_sys_getattr(ref, PVFS_ATTR_SYS_ALL_NOHINT,
+                               credentials, &resp_getattr);
+        if (ret)
+        {
+            fprintf(stderr, "Failed to do pvfs2 getattr on %s\n",
+                    obj->u.pvfs2.pvfs2_path);
+            return -1;
+        }
+
+        if (resp_getattr.attr.objtype != PVFS_TYPE_METAFILE)
+        {
+            fprintf(stderr, "Not a meta file!\n");
+            return -1;
+        }
+        obj->u.pvfs2.perms = resp_getattr.attr.perms;
+        memcpy(&obj->u.pvfs2.attr, &resp_getattr.attr,
+               sizeof(PVFS_sys_attr));
+        obj->u.pvfs2.attr.mask = PVFS_ATTR_SYS_ALL_SETABLE;
+        obj->u.pvfs2.ref = ref;
+    }
+    return 0;
+}
+
+static int eattr_is_prefixed(char* key_name)
+{
+    int i = 0;
+    while(PINT_eattr_namespaces[i])
+    {
+        if(strncmp(PINT_eattr_namespaces[i], key_name,
+            strlen(PINT_eattr_namespaces[i])) == 0)
+        {
+            return(1);
+        }
+        i++;
+    }
+    return(0);
+}
+
+
+
+/*
+ * Local variables:
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ *
+ * vim: ts=8 sts=4 sw=4 expandtab
+ */
+

Index: module.mk.in
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/apps/admin/module.mk.in,v
diff -p -u -r1.39.10.1 -r1.39.10.2
--- module.mk.in	18 Sep 2006 15:05:01 -0000	1.39.10.1
+++ module.mk.in	19 Oct 2006 22:16:39 -0000	1.39.10.2
@@ -21,6 +21,7 @@ ADMINSRC := \
 	$(DIR)/pvfs2-fsck.c\
 	$(DIR)/pvfs2-cp.c \
 	$(DIR)/pvfs2-viewdist.c \
+	$(DIR)/pvfs2-xattr.c \
 	$(DIR)/pvfs2-touch.c \
 	$(DIR)/pvfs2-remove-object.c \
 	$(DIR)/pvfs2-ln.c \

Index: pvfs2-genconfig
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/apps/admin/pvfs2-genconfig,v
diff -p -u -r1.61.2.1 -r1.61.2.2
--- pvfs2-genconfig	18 Sep 2006 15:05:01 -0000	1.61.2.1
+++ pvfs2-genconfig	19 Oct 2006 22:16:39 -0000	1.61.2.2
@@ -23,6 +23,7 @@ my $opt_metaservers = '';
 my $opt_logfile = '';
 my $opt_storage = '';
 my $opt_trovesync = '1';
+my $opt_trovemethod = 'dbpf';
 my $opt_quiet = '';
 my $opt_logging = '';
 my $opt_logstamp = '';
@@ -198,6 +199,7 @@ sub emit_defaults
     print $target "\tClientJobFlowTimeoutSecs $client_job_timeout\n";
     print $target "\tClientRetryLimit 5\n";
     print $target "\tClientRetryDelayMilliSecs 2000\n";
+    print $target "\tTroveMethod $opt_trovemethod\n";
 
     print $target "</Defaults>\n";
 }
@@ -459,6 +461,7 @@ Usage: pvfs2-genconfig [OPTIONS] <fs.con
      --notrovesync                     sync metadata only upon request
      --server-job-timeout <NUM>        server job timeout value (seconds)
      --client-job-timeout <NUM>        server job timeout value (seconds)
+     --trove-method <STRING>           specify a trove method
      --first-handle <NUM>              first handle value to reserve
      --last-handle  <NUM>              last handle value to reserve
      --root-handle  <NUM>              handle value to reserve for root object
@@ -1116,6 +1119,7 @@ GetOptions('protocol=s'    => \$opt_prot
     'help'          => \$show_help,
     'quiet!'        => \$opt_quiet,
     'trovesync!'    => \$opt_trovesync,
+    'trove-method=s' => \$opt_trovemethod,
     'iospec=s'     => \$opt_iospec,
     'metaspec=s'   => \$opt_metaspec, 
     'spec-usage!'  => \$show_specusage,

Index: pvfs2-ln.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/apps/admin/pvfs2-ln.c,v
diff -p -u -r1.3.20.1 -r1.3.20.2
--- pvfs2-ln.c	18 Sep 2006 15:05:01 -0000	1.3.20.1
+++ pvfs2-ln.c	19 Oct 2006 22:16:40 -0000	1.3.20.2
@@ -131,7 +131,7 @@ static int make_link(PVFS_credentials   
     /* We need to change the PINT_remove_base_dir to an API call (pvfs_util), 
      * and we need to change this to use it 
      */
-    ret = PINT_remove_base_dir( (char *) pszPvfsPath, 
+    ret = PINT_remove_base_dir( pszPvfsPath, 
                                 szBaseName, 
                                 sizeof(szBaseName));
     
@@ -209,7 +209,7 @@ static int parse_args(int argc, char** a
     int    ret             = 0, 
            option_index    = 0,
            create_softlink = 0;
-    char * cur_option      = NULL;
+    const char * cur_option      = NULL;
     char   flags[]         = "hvVs";  /* Options available on command line */
 
     static struct option long_opts[] =
@@ -225,7 +225,7 @@ static int parse_args(int argc, char** a
         switch (ret)
         {
             case 0:
-                cur_option = (char*)long_opts[option_index].name;
+                cur_option = long_opts[option_index].name;
    
                 if(strcmp("help", cur_option) == 0)
                 {

Index: pvfs2-ls.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/apps/admin/pvfs2-ls.c,v
diff -p -u -r1.65.2.2 -r1.65.2.3
--- pvfs2-ls.c	28 Sep 2006 18:35:42 -0000	1.65.2.2
+++ pvfs2-ls.c	19 Oct 2006 22:16:40 -0000	1.65.2.3
@@ -405,7 +405,6 @@ int do_list(
     PVFS_ds_position token;
     uint64_t dir_version = 0;
     double begin = 0.0, end;
-
     name = start;
 
     memset(&lk_response,0,sizeof(PVFS_sysresp_lookup));
@@ -541,7 +540,7 @@ int do_list(
 static struct options* parse_args(int argc, char* argv[])
 {
     int i = 0, ret = 0, option_index = 0;
-    char *cur_option = NULL;
+    const char *cur_option = NULL;
     struct options* tmp_opts = NULL;
     static struct option long_opts[] =
     {
@@ -573,7 +572,7 @@ static struct options* parse_args(int ar
 	switch(ret)
         {
             case 0:
-                cur_option = (char *)long_opts[option_index].name;
+                cur_option = long_opts[option_index].name;
 
                 if (strcmp("help", cur_option) == 0)
                 {

Index: pvfs2-migrate-collection.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/apps/admin/pvfs2-migrate-collection.c,v
diff -p -u -r1.15.6.1 -r1.15.6.2
--- pvfs2-migrate-collection.c	18 Sep 2006 15:05:02 -0000	1.15.6.1
+++ pvfs2-migrate-collection.c	19 Oct 2006 22:16:40 -0000	1.15.6.2
@@ -615,7 +615,6 @@ static int translate_0_0_1(
      * will create
      */
     char handle_range[] = "4-64000000000";
-    char* method_name = NULL;
     TROVE_op_id op_id;
     TROVE_context_id trove_context = -1;
     char current_path[PATH_MAX];
@@ -681,7 +680,8 @@ static int translate_0_0_1(
     }
 
     /* initialize trove and lookup collection */
-    ret = trove_initialize(storage_space, 0, &method_name, 0);
+    ret = trove_initialize(
+        TROVE_METHOD_DBPF, NULL, storage_space, 0);
     if (ret < 0)
     {
         PVFS_perror("trove_initialize", ret);
@@ -689,7 +689,8 @@ static int translate_0_0_1(
         pvfs2_rmspace(storage_space, coll_name, coll_id, 1, 0);
         return(-1);
     }
-    ret = trove_collection_lookup(coll_name, &coll_id, NULL, &op_id);
+    ret = trove_collection_lookup(
+        TROVE_METHOD_DBPF, coll_name, &coll_id, NULL, &op_id);
     if (ret != 1)
     {   
         fprintf(stderr, "Error: failed to lookup new collection.\n");
@@ -740,7 +741,7 @@ static int translate_0_0_1(
 
     /* at this point, we are done with the Trove API */
     trove_close_context(coll_id, trove_context);
-    trove_finalize();
+    trove_finalize(TROVE_METHOD_DBPF);
     PINT_dist_finalize();
 
     /* convert bstreams */

Index: pvfs2-mkdir.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/apps/admin/pvfs2-mkdir.c,v
diff -p -u -r1.8.16.1 -r1.8.16.2
--- pvfs2-mkdir.c	18 Sep 2006 15:05:02 -0000	1.8.16.1
+++ pvfs2-mkdir.c	19 Oct 2006 22:16:40 -0000	1.8.16.2
@@ -334,7 +334,7 @@ static int make_directory(PVFS_credentia
 static int parse_args(int argc, char** argv, struct options * opts)
 {
     int i = 0, ret = 0,option_index = 0, mode_requested = 0;
-    char * cur_option = NULL;
+    const char * cur_option = NULL;
     char flags[] = "hm:pvV";  /* Options available on command line */
 
     static struct option long_opts[] =
@@ -351,7 +351,7 @@ static int parse_args(int argc, char** a
         switch (ret)
         {
             case 0:
-                cur_option = (char*)long_opts[option_index].name;
+                cur_option = long_opts[option_index].name;
    
                 if(strcmp("help", cur_option) == 0)
                 {

Index: pvfs2-mkspace.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/apps/admin/pvfs2-mkspace.c,v
diff -p -u -r1.19 -r1.19.16.1
--- pvfs2-mkspace.c	11 Nov 2005 21:30:57 -0000	1.19
+++ pvfs2-mkspace.c	19 Oct 2006 22:16:40 -0000	1.19.16.1
@@ -46,7 +46,7 @@ static void print_help(char *progname, o
 static int parse_args(int argc, char **argv, options_t *opts)
 {
     int ret = 0, option_index = 0;
-    char *cur_option = NULL;
+    const char *cur_option = NULL;
     static struct option long_opts[] =
     {
         {"help",0,0,0},
@@ -76,7 +76,7 @@ static int parse_args(int argc, char **a
 	switch (ret)
         {
             case 0:
-                cur_option = (char *)long_opts[option_index].name;
+                cur_option = long_opts[option_index].name;
 
                 if (strcmp("help", cur_option) == 0)
                 {

Index: pvfs2-perror.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/apps/admin/pvfs2-perror.c,v
diff -p -u -r1.2 -r1.2.8.1
--- pvfs2-perror.c	29 May 2006 16:16:36 -0000	1.2
+++ pvfs2-perror.c	19 Oct 2006 22:16:40 -0000	1.2.8.1
@@ -43,7 +43,7 @@ int main(int argc, char **argv)
 	return(-1);
     }
 
-    fprintf(stderr, "Error code %d: ", user_opts->error_code);
+    fprintf(stderr, "Error code %d", user_opts->error_code);
     PVFS_perror("", -user_opts->error_code);
 
     return(0);

Index: pvfs2-remove-object.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/apps/admin/pvfs2-remove-object.c,v
diff -p -u -r1.7 -r1.7.16.1
--- pvfs2-remove-object.c	11 Nov 2005 21:30:58 -0000	1.7
+++ pvfs2-remove-object.c	19 Oct 2006 22:16:40 -0000	1.7.16.1
@@ -56,7 +56,7 @@ static void usage(int argc, char **argv)
 static options_t *parse_args(int argc, char **argv)
 {
     int ret = 0, option_index = 0;
-    char *cur_option = NULL;
+    const char *cur_option = NULL;
     options_t *tmp_opts = NULL;
     static struct option long_opts[] =
     {
@@ -87,7 +87,7 @@ static options_t *parse_args(int argc, c
 	switch(ret)
         {
             case 0:
-                cur_option = (char *)long_opts[option_index].name;
+                cur_option = long_opts[option_index].name;
 
                 if (strcmp("help", cur_option) == 0)
                 {

Index: pvfs2-set-debugmask.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/apps/admin/pvfs2-set-debugmask.c,v
diff -p -u -r1.23 -r1.23.4.1
--- pvfs2-set-debugmask.c	29 May 2006 16:21:10 -0000	1.23
+++ pvfs2-set-debugmask.c	19 Oct 2006 22:16:40 -0000	1.23.4.1
@@ -108,7 +108,7 @@ int main(int argc, char **argv)
 static struct options *parse_args(int argc, char **argv)
 {
     int ret = -1, len = 0, option_index = 0;
-    char *cur_option = NULL;
+    const char *cur_option = NULL;
     struct options *tmp_opts = NULL;
     static struct option long_opts[] =
     {
@@ -136,7 +136,7 @@ static struct options *parse_args(int ar
         switch(ret)
         {
             case 0:
-                cur_option = (char *)long_opts[option_index].name;
+                cur_option = long_opts[option_index].name;
 
                 if (strcmp("help", cur_option) == 0)
                 {

Index: pvfs2-showcoll.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/apps/admin/pvfs2-showcoll.c,v
diff -p -u -r1.22 -r1.22.2.1
--- pvfs2-showcoll.c	14 Jun 2006 18:41:24 -0000	1.22
+++ pvfs2-showcoll.c	19 Oct 2006 22:16:40 -0000	1.22.2.1
@@ -60,8 +60,6 @@ int main(int argc, char **argv)
     TROVE_ds_state state;
     TROVE_keyval_s key, val;
     TROVE_context_id trove_context = -1;
-    char *method_name;
-    char root_handle_string[] = ROOT_HANDLE_KEYSTR;
 
     ret = parse_args(argc, argv);
     if (ret < 0) {
@@ -72,8 +70,10 @@ int main(int argc, char **argv)
     }
 
     /* initialize trove, verifying storage space exists */
-    ret = trove_initialize(storage_space, 0, &method_name, 0);
-    if (ret < 0) {
+    ret = trove_initialize(
+        TROVE_METHOD_DBPF, NULL, storage_space, 0);
+    if (ret < 0) 
+    {
 	fprintf(stderr,
 		"%s: error: trove initialize failed; aborting!\n",
 		argv[0]);
@@ -92,10 +92,10 @@ int main(int argc, char **argv)
 	    fprintf(stderr,
 		    "%s: error: collection iterate failed; aborting!\n",
 		    argv[0]);
-	    trove_finalize();
+	    trove_finalize(TROVE_METHOD_DBPF);
 	    return -1;
 	}
-	trove_finalize();
+	trove_finalize(TROVE_METHOD_DBPF);
 	return 0;
     }
 
@@ -105,7 +105,8 @@ int main(int argc, char **argv)
      * - print out information on the dataspaces in the collection
      */
 
-    ret = trove_collection_lookup(collection,
+    ret = trove_collection_lookup(TROVE_METHOD_DBPF,
+                                  collection,
 				  &coll_id,
 				  NULL,
 				  &op_id);
@@ -114,7 +115,7 @@ int main(int argc, char **argv)
 		"%s: error: collection lookup failed for collection '%s'; aborting!.\n",
 		argv[0],
 		collection);
-	trove_finalize();
+	trove_finalize(TROVE_METHOD_DBPF);
 	return -1;
     }
 
@@ -132,8 +133,8 @@ int main(int argc, char **argv)
     }
 
     /* find root handle */
-    key.buffer = root_handle_string;
-    key.buffer_sz = strlen(root_handle_string) + 1;
+    key.buffer = ROOT_HANDLE_KEYSTR;
+    key.buffer_sz = ROOT_HANDLE_KEYLEN;
     val.buffer = &root_handle;
     val.buffer_sz = sizeof(root_handle);
     ret = trove_collection_geteattr(coll_id,
@@ -190,7 +191,7 @@ int main(int argc, char **argv)
     }
 
     trove_close_context(coll_id, trove_context);
-    trove_finalize();
+    trove_finalize(TROVE_METHOD_DBPF);
 
     return 0;
 }
@@ -500,7 +501,8 @@ static int print_collections(void)
     fprintf(stdout, "Storage space %s collections:\n", storage_space);
 
     while (count > 0) {
-	ret = trove_collection_iterate(&pos,
+	ret = trove_collection_iterate(TROVE_METHOD_DBPF,
+                                       &pos,
 				       &name,
 				       &coll_id,
 				       &count,

Index: pvfs2-stat.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/apps/admin/pvfs2-stat.c,v
diff -p -u -r1.6.6.1 -r1.6.6.2
--- pvfs2-stat.c	18 Sep 2006 15:05:02 -0000	1.6.6.1
+++ pvfs2-stat.c	19 Oct 2006 22:16:40 -0000	1.6.6.2
@@ -255,7 +255,7 @@ static int parse_args(int argc, char** a
     int    i            = 0, 
            ret          = 0, 
            option_index = 0;
-    char * cur_option   = NULL;
+    const char * cur_option   = NULL;
 
     static struct option long_opts[] =
     {
@@ -271,7 +271,7 @@ static int parse_args(int argc, char** a
       switch (ret)
       {
          case 0:
-               cur_option = (char*)long_opts[option_index].name;
+               cur_option = long_opts[option_index].name;
    
                if(strcmp("help", cur_option) == 0)
                {
@@ -478,7 +478,22 @@ void print_stats(const PVFS_object_ref *
    {
       fprintf(stdout, "  dir entries   : %llu\n", llu(attr->dirent_count));
    }
-   
+
+   if ((attr->mask & PVFS_ATTR_SYS_TYPE) && 
+          (attr->objtype & PVFS_TYPE_METAFILE))
+   {
+       if (attr->flags == 0)
+           fprintf(stdout, "  flags         : none");
+       else
+           fprintf(stdout, "  flags         : ");
+       if (attr->flags & PVFS_IMMUTABLE_FL)
+           fprintf(stdout, "immutable, ");
+       if (attr->flags & PVFS_APPEND_FL)
+           fprintf(stdout, "append-only, ");
+       if (attr->flags & PVFS_NOATIME_FL)
+           fprintf(stdout, "noatime ");
+       fprintf(stdout, "\n");
+   }
 }
 
 static void usage(int argc, char** argv)



More information about the Pvfs2-cvs mailing list