minor/medium cleanups
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Tue, 13 Jan 2004 14:15:53 +0000 (14:15 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Tue, 13 Jan 2004 14:15:53 +0000 (14:15 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@562 94cd875c-1c1d-0410-91d2-eb244daf1a30

util-vserver/src/chxid.c
util-vserver/src/fstool.c
util-vserver/src/fstool.h
util-vserver/src/lsxid.c
util-vserver/src/setattr.c
util-vserver/src/showattr.c

index e2b6fa8..1af6c53 100644 (file)
@@ -103,15 +103,17 @@ handleFile(char const *name, char const * display_name,
 }
 
 void
-checkParams(struct Arguments const UNUSED *args, int argc)
+fixupParams(struct Arguments UNUSED *args, int argc)
 {
   if (optind==argc) {
     WRITE_MSG(2, "No filename given; use '--help' for more information\n");
     exit(1);
   }
 
-  if (args->ctx==VC_NOCTX) {
-    WRITE_MSG(2, "No valid context given; use '--help' for more information\n");
+  if (args->ctx_str==0) {
+    WRITE_MSG(2, "No context given; use '--help' for more information\n");
     exit(1);
   }
+
+  args->ctx = resolveCtx(args->ctx_str);
 }
index 780997f..006d3aa 100644 (file)
@@ -161,30 +161,6 @@ processFile(char const *path)
     return handleFile(path, path, &st);
 }
 
-static xid_t
-resolveCtx(char const *str)
-{
-  xid_t                res;
-  
-  if (*str==':') ++str;
-  else {
-    char       *end_ptr;
-    long       result = strtol(str, &end_ptr, 0);
-
-    if (end_ptr>str && *end_ptr==0) return result;
-  }
-
-  res = vc_getVserverCtx(str, vcCFG_AUTO, true, 0);
-  if (res==VC_NOCTX) {
-    WRITE_MSG(2, "Can not find a vserver with name '");
-    WRITE_STR(2, str);
-    WRITE_MSG(2, "', or vserver does not have a static context\n");
-    exit(1);
-  }
-
-  return res;
-}
-
 int main(int argc, char *argv[])
 {
   uint64_t             err_cnt = 0;
@@ -220,7 +196,7 @@ int main(int argc, char *argv[])
       case 'n'                 :  args.do_mapping     = false; break;
       case 's'                 :  args.do_set         = true;  break;
       case 'u'                 :  args.do_unset       = true;  break;
-      case 'c'                 :  args.ctx            = resolveCtx(optarg); break;
+      case 'c'                 :  args.ctx_str        = optarg; break;
       default          :
        WRITE_MSG(2, "Try '");
        WRITE_STR(2, argv[0]);
@@ -230,7 +206,7 @@ int main(int argc, char *argv[])
     }
   }
 
-  checkParams(&args, argc);
+  fixupParams(&args, argc);
 
   if (optind==argc)
     err_cnt  = processFile(".");
index 73a7f21..8bc396a 100644 (file)
 struct stat;
 
 struct Arguments {
-    bool       do_recurse;
-    bool       do_display_dot;
-    bool       do_display_dir;
-    bool       do_mapping;
-    bool       immutable;
-    bool       immulink;
-    xid_t      ctx;
-    bool       is_legacy;
-    bool       do_set;
-    bool       do_unset;
+    bool               do_recurse;
+    bool               do_display_dot;
+    bool               do_display_dir;
+    bool               do_mapping;
+    bool               immutable;
+    bool               immulink;
+    char const *       ctx_str;
+    xid_t              ctx;
+    bool               is_legacy;
+    bool               do_set;
+    bool               do_unset;
 };
 
 extern struct option const             CMDLINE_OPTIONS[];
@@ -48,9 +49,10 @@ extern char const                    CMDLINE_OPTIONS_SHORT[];
 extern struct Arguments const *                global_args;
 
 bool   checkForRace(int fd, char const * name, struct stat const *exp_st);
-void   checkParams(struct Arguments const *, int argc);
+void   fixupParams(struct Arguments *, int argc);
 bool   handleFile(char const *d_name, char const *full_name, struct stat const *);
 void   showHelp(int fd, char const *cmd, int res);
 void   showVersion();
+xid_t  resolveCtx(char const *str);
 
 #endif //  H_UTIL_VSERVER_SRC_FSTOOL_H
index d6bd531..cc7cd18 100644 (file)
@@ -72,7 +72,7 @@ showVersion()
 }
 
 void
-checkParams(struct Arguments const UNUSED * args, int UNUSED argc)
+fixupParams(struct Arguments UNUSED * args, int UNUSED argc)
 {
 }
 
index 4d4ba91..74de450 100644 (file)
@@ -75,7 +75,7 @@ showVersion()
 }
 
 void
-checkParams(struct Arguments const * args, int argc)
+fixupParams(struct Arguments * args, int argc)
 {
   if (optind==argc) {
     WRITE_MSG(2, "No filename given; use '--help' for more information\n");
index 01a9f52..cf68304 100644 (file)
@@ -73,7 +73,7 @@ showVersion()
 }
 
 void
-checkParams(struct Arguments const UNUSED * args, int UNUSED argc)
+fixupParams(struct Arguments UNUSED * args, int UNUSED argc)
 {
 }