Whamcloud - gitweb
b=20200
authordzogin <dzogin>
Sun, 9 Aug 2009 17:16:57 +0000 (17:16 +0000)
committerdzogin <dzogin>
Sun, 9 Aug 2009 17:16:57 +0000 (17:16 +0000)
 i=andrew.perepechko
 i=tianzy
 Description: Enhancement for lfs(1) command to use numeric uid/gid.

lustre/ChangeLog
lustre/doc/lfs.1
lustre/utils/lfs.c

index 3936805..adbb0c6 100644 (file)
@@ -14,6 +14,10 @@ tbd Sun Microsystems, Inc.
          of Lustre filesystem with 4K stack may cause a stack overflow. For
          more information, please refer to bugzilla 17630.
 
+Severity   : enhancement 
+Bugzilla   : 20200
+Description: Enhancement for lfs(1) command to use numeric uid/gid.
+
 Severity   : normal 
 Bugzilla   : 18674
 Description: Do not start bulk transfer, if client tried to reconnect.
index baef846..6df7456 100644 (file)
@@ -13,8 +13,8 @@ lfs \- Lustre utility to create a file with specific striping pattern, find the
         \fB[[!] --ctime|-C [-+]N] [--maxdepth|-D N] [--name|-n pattern]
         \fB[--print|-p] \fB[--print0|-P] [--obd|-O <uuid[s]>]
         \fB[[!] --size|-S [-+]N[kMGTPE]] [--type |-t {bcdflpsD}]
-        \fB[[!] --gid|-g N] [[!] --group|-G <name>]
-        \fB[[!] --uid|-u N] [[!] --user|-U <name>]
+        \fB[[!] --gid|-g|--group|-G <gname>|<gid>]
+        \fB[[!] --uid|-u|--user|-U <uname>|<uid>]
         \fB<dirname|filename>\fR
 .br
 .B lfs osts
@@ -30,7 +30,7 @@ lfs \- Lustre utility to create a file with specific striping pattern, find the
 .br
 .B lfs poollist <filesystem>[.<pool>] | <pathname>
 .br
-.B lfs quota [-v] [-o obd_uuid] [-u <username>|-g <groupname>] <filesystem>
+.B lfs quota [-v] [-o obd_uuid] [<-u|-g> <uname>|<uid>|<gname><gid>] <filesystem>
 .br
 .B lfs quota -t <-u|-g> <filesystem>
 .br
@@ -44,14 +44,14 @@ lfs \- Lustre utility to create a file with specific striping pattern, find the
 .br
 .B lfs quotainv [-ug] [-f] <filesystem>
 .br
-.B lfs setquota <-u|--user|-g|--group> <username|groupname>
+.B lfs setquota <-u|--user|-g|--group> <uname|uid|gname|gid>
              \fB[--block-softlimit <block-softlimit>]
              \fB[--block-hardlimit <block-hardlimit>]
              \fB[--inode-softlimit <inode-softlimit>]
              \fB[--inode-hardlimit <inode-hardlimit>]
              \fB<filesystem>\fR
 .br
-.B lfs setquota <-u|--user|-g|--group> <username|groupname>
+.B lfs setquota <-u|--user|-g|--group> <uname|uid|gname|gid>
              \fB[-b <block-softlimit>] [-B <block-hardlimit>]
              \fB[-i <inode-softlimit>] [-I <inode-hardlimit>]
              \fB<filesystem>\fR
@@ -61,7 +61,7 @@ lfs \- Lustre utility to create a file with specific striping pattern, find the
              \fB[--inode-grace <inode-grace>]
              \fB<filesystem>\fR
 .br
-.B lfs setquota -t [-u|-g]
+.B lfs setquota -t <-u|-g>
              \fB[-b <block-grace>] [-i <inode-grace>]
              \fB<filesystem>\fR
 .br
@@ -136,16 +136,16 @@ To turn filesystem quotas off.  Options specify quota for users (-u) groups (-g)
 .B quotainv [-ug] [-f] <filesystem>
 Clear quota files (administrative quota files if used without -f, operational quota files otherwise), all of their quota entries, for (-u) users or (-g) groups; after quotainv one must use quotacheck before using quotas. DO NOT USE THIS COMMAND UNLESS YOU REALLY KNOW WHAT IT DOES. IT IS MAINLY FOR INTERNAL PURPOSES.
 .TP
-.B setquota  [-u|-g] <name> [--block-softlimit <block-softlimit>] [--block-hardlimit <block-hardlimit>] [--inode-softlimit <inode-softlimit>] [--inode-hardlimit <inode-hardlimit>] <filesystem>
+.B setquota  <-u|-g> <uname>|<uid>|<gname>|<gid> [--block-softlimit <block-softlimit>] [--block-hardlimit <block-hardlimit>] [--inode-softlimit <inode-softlimit>] [--inode-hardlimit <inode-hardlimit>] <filesystem>
 To set filesystem quotas for users or groups. Limits can be specified with -b, -k, -m, -g, -t, -p suffixes which specify units of 1, 2^10, 2^20, 2^30, 2^40 and 2^50 accordingly. Block limits unit is kilobyte (1024) by default and block limits are always kilobyte-grained (even if specified in bytes), see EXAMPLES
 .TP
-.B setquota -t [-u|-g] [--block-grace <block-grace>] [--inode-grace <inode-grace>] <filesystem>
+.B setquota -t <-u|-g> [--block-grace <block-grace>] [--inode-grace <inode-grace>] <filesystem>
 To set filesystem quota grace times for users or groups. Grace time is specified in "XXwXXdXXhXXmXXs" format or as an integer seconds value, see EXAMPLES
 .TP
-.B quota [-v] [-o obd_uuid] [-u|-g] <username|groupname> <filesystem>
-To display disk usage and limits, either for the full filesystem, or for objects on a specific obd. A user or group name can be specified. If both user and group are omitted quotas for current uid/gid are shown. -v provides more verbose (with per-obd statistics) output.
+.B quota [-v] [-o obd_uuid] [ -u|-g <uname|uid|gname|gid> ] <filesystem>
+To display disk usage and limits, either for the full filesystem, or for objects on a specific obd. A user or group name or an ID can be specified. If both user and group are omitted quotas for current uid/gid are shown. -v provides more verbose (with per-obd statistics) output.
 .TP
-.B quota -t [-u|-g] <filesystem>
+.B quota -t <-u|-g> <filesystem>
 To display block and inode grace times for user (-u) or group (-g) quotas
 .TP
 .B help 
index e4d5130..4ce9b56 100644 (file)
@@ -131,8 +131,8 @@ command_t cmdlist[] = {
          "     [[!] --atime|-A [+-]N] [[!] --mtime|-M [+-]N] [[!] --ctime|-C [+-]N]\n"
          "     [--maxdepth|-D N] [[!] --name|-n <pattern>] [--print0|-P]\n"
          "     [--print|-p] [--obd|-O <uuid[s]>] [[!] --size|-s [+-]N[bkMGTP]]\n"
-         "     [[!] --type|-t <filetype>] [[!] --gid|-g N] [[!] --group|-G <name>]\n"
-         "     [[!] --uid|-u N] [[!] --user|-U <name>]\n"
+         "     [[!] --type|-t <filetype>] [[!] --gid|-g|--group|-G <gid>|<gname>]\n"
+         "     [[!] --uid|-u|--user|-U <uid>|<uname>]\n"
          "     [[!] --pool <pool>]\n"
          "\t !: used before an option indicates 'NOT' the requested attribute\n"
          "\t -: used before an value indicates 'AT MOST' the requested value\n"
@@ -168,14 +168,17 @@ command_t cmdlist[] = {
         {"quotaoff", lfs_quotaoff, 0, "Turn filesystem quotas off.\n"
          "usage: quotaoff [ -ug ] <filesystem>"},
         {"setquota", lfs_setquota, 0, "Set filesystem quotas.\n"
-         "usage: setquota [ -u | -g ] <name> <block-softlimit> <block-hardlimit> <inode-softlimit> <inode-hardlimit> <filesystem>\n"
-         "       setquota -t [ -u | -g ] <block-grace> <inode-grace> <filesystem>\n"
-         "       setquota [ -u | --user | -g | --group ] <name>\n"
+         "usage: setquota <-u|-g> <uname>|<uid>|<gname>|<gid>\n"
+         "                <block-softlimit> <block-hardlimit>\n"
+         "                <inode-softlimit> <inode-hardlimit>\n"
+         "                <filesystem>\n"
+         "       setquota <-u|--user|-g|--group> <uname>|<uid>|<gname>|<gid>\n"
          "                [--block-softlimit <block-softlimit>]\n"
          "                [--block-hardlimit <block-hardlimit>]\n"
          "                [--inode-softlimit <inode-softlimit>]\n"
          "                [--inode-hardlimit <inode-hardlimit>] <filesystem>\n"
-         "       setquota [-t] [ -u | --user | -g | --group ]\n"
+         "       setquota -t <-u|-g> <block-grace> <inode-grace> <filesystem>\n"
+         "       setquota -t <-u|--user|-g|--group>\n"
          "                [--block-grace <block-grace>]\n"
          "                [--inode-grace <inode-grace>] <filesystem>\n"
          "       -b can be used instead of --block-softlimit/--block-grace\n"
@@ -183,7 +186,9 @@ command_t cmdlist[] = {
          "       -i can be used instead of --inode-softlimit/--inode-grace\n"
          "       -I can be used instead of --inode-hardlimit"},
         {"quota", lfs_quota, 0, "Display disk usage and limits.\n"
-         "usage: quota [ -o obd_uuid ] [{-u|-g  <name>}|-t] <filesystem>"},
+         "usage: quota [-v] [ -o obd_uuid ] [<-u|-g> <uname>|<uid>|<gname>|<gid>]\n"
+         "                <filesystem>\n"
+         "       quota [ -o obd_uuid ] -t <-u|-g> <filesystem>"},
         {"quotainv", lfs_quotainv, 0, "Invalidate quota data.\n"
          "usage: quotainv [-u|-g] <filesystem>"},
 #endif
@@ -562,45 +567,27 @@ static int lfs_find(int argc, char **argv)
                         param.maxdepth = strtol(optarg, 0, 0);
                         break;
                 case 'g':
-                        new_fashion = 1;
-                        param.gid = strtol(optarg, &endptr, 10);
-                        if (optarg == endptr) {
-                                fprintf(stderr, "Bad gid: %s\n", optarg);
-                                return CMD_HELP;
-                        }
-                        param.exclude_gid = !!neg_opt;
-                        param.check_gid = 1;
-                        break;
                 case 'G':
                         new_fashion = 1;
-                        param.gid = strtol(optarg, &endptr, 10);
-                        if (optarg == endptr) {
-                                ret = name2id(&param.gid, optarg, GROUP);
-                                if (ret != 0) {
+                        ret = name2id(&param.gid, optarg, GROUP);
+                        if (ret) {
+                                param.gid = strtoul(optarg, &endptr, 10);
+                                if (*endptr != '\0') {
                                         fprintf(stderr, "Group/GID: %s cannot "
                                                 "be found.\n", optarg);
                                         return -1;
                                 }
-                        }
+                        }           
                         param.exclude_gid = !!neg_opt;
                         param.check_gid = 1;
                         break;
                 case 'u':
-                        new_fashion = 1;
-                        param.uid = strtol(optarg, &endptr, 10);
-                        if (optarg == endptr) {
-                                fprintf(stderr, "Bad uid: %s\n", optarg);
-                                return CMD_HELP;
-                        }
-                        param.exclude_uid = !!neg_opt;
-                        param.check_uid = 1;
-                        break;
                 case 'U':
                         new_fashion = 1;
-                        param.uid = strtol(optarg, &endptr, 10);
-                        if (optarg == endptr) {
-                                ret = name2id(&param.uid, optarg, USER);
-                                if (ret != 0) {
+                        ret = name2id(&param.uid, optarg, USER);
+                        if (ret) {
+                                param.uid = strtoul(optarg, &endptr, 10);
+                                if (*endptr != '\0') {
                                         fprintf(stderr, "User/UID: %s cannot "
                                                 "be found.\n", optarg);
                                         return -1;
@@ -1731,6 +1718,7 @@ int lfs_setquota(int argc, char **argv)
                 {0, 0, 0, 0}
         };
         unsigned limit_mask = 0;
+        char *endptr;
 
         if (has_times_option(argc, argv))
                 return lfs_setquota_times(argc, argv);
@@ -1785,9 +1773,12 @@ int lfs_setquota(int argc, char **argv)
                         rc = name2id(&qctl.qc_id, optarg,
                                      (qctl.qc_type == USRQUOTA) ? USER : GROUP);
                         if (rc) {
-                                fprintf(stderr, "error: unknown id %s\n",
-                                        optarg);
-                                return CMD_HELP;
+                                qctl.qc_id = strtoul(optarg, &endptr, 10);
+                                if (*endptr != '\0') {
+                                        fprintf(stderr, "error: can't find id "
+                                                "for name %s\n", optarg); 
+                                        return CMD_HELP;
+                                }
                         }
                         break;
                 case 'b':
@@ -2117,6 +2108,7 @@ static int lfs_quota(int argc, char **argv)
         char *obd_uuid = (char *)qctl.obd_uuid.uuid;
         int rc, rc1 = 0, rc2 = 0, rc3 = 0, verbose = 0;
         int pass = 0;
+        char *endptr;
 
         optind = 0;
         while ((c = getopt(argc, argv, "ugto:v")) != -1) {
@@ -2180,9 +2172,12 @@ ug_output:
                 rc = name2id(&qctl.qc_id, name,
                              (qctl.qc_type == USRQUOTA) ? USER : GROUP);
                 if (rc) {
-                        fprintf(stderr,"error: can't find id for name %s: %s\n",
-                                name, strerror(errno));
-                        return CMD_HELP;
+                        qctl.qc_id = strtoul(name, &endptr, 10);
+                        if (*endptr != '\0') {
+                                fprintf(stderr, "error: can't find id for name "
+                                        "%s\n", name);
+                                return CMD_HELP;
+                        }
                 }
         } else if (optind + 1 != argc || qctl.qc_type == UGQUOTA) {
                 fprintf(stderr, "error: missing quota info argument(s)\n");