[Pvfs2-cvs] commit by sampson in pvfs2/src/apps/admin: pvfs2-ls.c
CVS commit program
cvs at parl.clemson.edu
Mon Nov 29 17:26:00 EST 2010
Update of /projects/cvsroot/pvfs2/src/apps/admin
In directory parlweb1:/tmp/cvs-serv8287/src/apps/admin
Modified Files:
Tag: windows-client
pvfs2-ls.c
Log Message:
Testing command-line apps
Index: pvfs2-ls.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/apps/admin/pvfs2-ls.c,v
diff -p -u -r1.85.10.4.6.1 -r1.85.10.4.6.2
--- pvfs2-ls.c 24 Nov 2010 22:25:03 -0000 1.85.10.4.6.1
+++ pvfs2-ls.c 29 Nov 2010 22:26:00 -0000 1.85.10.4.6.2
@@ -19,7 +19,9 @@
#include <grp.h>
#endif
#include <assert.h>
+#ifndef WIN32
#include <getopt.h>
+#endif
#include "pvfs2.h"
#include "str-utils.h"
@@ -223,8 +225,12 @@ void print_entry_attr(
{
char *formatted_size = NULL;
char *formatted_owner = NULL, *formatted_group = NULL, *formatted_time = NULL;
+#ifdef WIN32
+
+#else
struct group *grp = NULL;
struct passwd *pwd = NULL;
+#endif
char *empty_str = "";
char *owner = empty_str, *group = empty_str;
char *inode = empty_str;
@@ -320,14 +326,23 @@ void print_entry_attr(
{
if (!opts->list_no_owner)
{
+#ifdef WIN32
+ owner = scratch_owner;
+#else
pwd = getpwuid((uid_t)attr->owner);
owner = (pwd ? pwd->pw_name : scratch_owner);
+#endif
}
if (!opts->list_no_group)
{
+#ifdef WIN32
+ group = scratch_group;
+#else
grp = getgrgid((gid_t)attr->group);
group = (grp ? grp->gr_name : scratch_group);
+#endif
+
}
}
@@ -609,6 +624,8 @@ int do_list(
for(i = 0; i < rdplus_response.pvfs_dirent_outcount; i++)
{
+ PVFS_sys_attr *attr;
+
cur_file = rdplus_response.dirent_array[i].d_name;
cur_handle = rdplus_response.dirent_array[i].handle;
@@ -617,7 +634,7 @@ int do_list(
rdplus_response.stat_err_array[i],
opts, entry_buffer);
- PVFS_sys_attr *attr = &rdplus_response.attr_array[i];
+ attr = &rdplus_response.attr_array[i];
if(attr->objtype == PVFS_TYPE_DIRECTORY && opts->list_recursive)
{
int path_len = strlen(start) + strlen(cur_file) + 1;
@@ -712,11 +729,145 @@ int do_list(
*
* returns pointer to options structure on success, NULL on failure
*/
+#ifdef WIN32
+static struct options* parse_args(int argc, char* argv[])
+{
+ int i = 0, ret = 0, option_index = 0;
+ const char *cur_option = NULL;
+ struct options* tmp_opts = NULL;
+
+ static char str_opts[14][16] = {
+ "help",
+ "human-readable",
+ "si",
+ "version",
+ "recursive",
+ "verbose",
+ "numeric-uid-gid",
+ "directory",
+ "no-group",
+ "almost-all",
+ "all",
+ "inode",
+ "size",
+ "all-times"
+ };
+
+ tmp_opts = (struct options*)malloc(sizeof(struct options));
+ if (!tmp_opts)
+ {
+ return(NULL);
+ }
+ memset(tmp_opts, 0, sizeof(struct options));
+ /* RVndGoAaiglt */
+ option_index = 1;
+ while ((option_index < argc) && (argv[option_index][0] == '-'))
+ {
+ cur_option = argv[option_index];
+
+ if ((strcmp(cur_option, "-?") == 0) ||
+ (strcmp(cur_option, "--help") == 0))
+ {
+ usage(argc, argv);
+ exit(0);
+ }
+ else if ((strcmp(cur_option, "--human-readable") == 0) ||
+ (strcmp(cur_option, "-h") == 0))
+ {
+ tmp_opts->list_human_readable = 1;
+ }
+ else if (strcmp(cur_option, "--si") == 0)
+ {
+ tmp_opts->list_use_si_units = 1;
+ break;
+ }
+ else if (strcmp(cur_option, "--version") == 0)
+ {
+ printf("%s\n", PVFS2_VERSION);
+ exit(0);
+ }
+ else if ((strcmp(cur_option, "--recursive") == 0) ||
+ (strcmp(cur_option, "-R") == 0))
+ {
+ tmp_opts->list_recursive = 1;
+ }
+ else if ((strcmp(cur_option, "--verbose") == 0) ||
+ (strcmp(cur_option, "-V") == 0))
+ {
+ tmp_opts->list_verbose = 1;
+ }
+ else if ((strcmp(cur_option, "--numeric-uid-gid") == 0) ||
+ (strcmp(cur_option, "-n") == 0))
+ {
+ tmp_opts->list_long = 1;
+ tmp_opts->list_numeric_uid_gid = 1;
+ }
+ else if ((strcmp(cur_option, "--directory") == 0) ||
+ (strcmp(cur_option, "-d") == 0))
+ {
+ tmp_opts->list_directory = 1;
+ }
+ else if ((strcmp(cur_option, "--no-group") == 0) ||
+ (strcmp(cur_option, "-G") == 0))
+ {
+ tmp_opts->list_long = 1;
+ tmp_opts->list_no_group = 1;
+ }
+ else if ((strcmp(cur_option, "--almost-all") == 0) ||
+ (strcmp(cur_option, "-A") == 0))
+ {
+ tmp_opts->list_almost_all = 1;
+ }
+ else if ((strcmp(cur_option, "--all") == 0) ||
+ (strcmp(cur_option, "-a") == 0))
+ {
+ tmp_opts->list_all = 1;
+ }
+ else if ((strcmp(cur_option, "--inode") == 0) ||
+ (strcmp(cur_option, "-i") == 0))
+ {
+ tmp_opts->list_inode = 1;
+ }
+ else if ((strcmp(cur_option, "--all-times") == 0))
+ {
+ tmp_opts->list_all_times = 1;
+ }
+ else if (strcmp(cur_option, "-l") == 0)
+ {
+ tmp_opts->list_long = 1;
+ }
+ else
+ {
+ usage(argc, argv);
+ exit(EXIT_FAILURE);
+ }
+
+ option_index++;
+ }
+
+ for(i = option_index; i < argc; i++)
+ {
+ if (tmp_opts->num_starts < MAX_NUM_PATHS)
+ {
+ tmp_opts->start[i-option_index] = argv[i];
+ tmp_opts->num_starts++;
+ }
+ else
+ {
+ fprintf(stderr,"Ignoring path %s\n",argv[i]);
+ }
+ }
+
+ return tmp_opts;
+
+}
+#else
static struct options* parse_args(int argc, char* argv[])
{
int i = 0, ret = 0, option_index = 0;
const char *cur_option = NULL;
struct options* tmp_opts = NULL;
+
static struct option long_opts[] =
{
{"help",0,0,0},
@@ -883,6 +1034,7 @@ static struct options* parse_args(int ar
}
return tmp_opts;
}
+#endif
static void usage(int argc, char** argv)
{
More information about the Pvfs2-cvs
mailing list