From c0905e9136605817f830129d504ccc4884d111d4 Mon Sep 17 00:00:00 2001 From: dzogin Date: Fri, 4 Sep 2009 17:59:26 +0000 Subject: [PATCH] Branch HEAD b=20200 i=andrew.perepechko i=tianzy ---------------------------------------------------------------------- Modified Files: lustre/ChangeLog lustre/doc/lfs.1 lustre/utils/lfs.c =================================================================== Severity : enhancement Bugzilla : 20200 Description: Enhancement for lfs(1) command to use numeric uid/gid. =================================================================== --- lustre/ChangeLog | 4 +++ lustre/doc/lfs.1 | 20 +++++++-------- lustre/utils/lfs.c | 74 +++++++++++++++++++++++++----------------------------- 3 files changed, 48 insertions(+), 50 deletions(-) diff --git a/lustre/ChangeLog b/lustre/ChangeLog index 8af4b8c..9dd3773 100644 --- a/lustre/ChangeLog +++ b/lustre/ChangeLog @@ -13,6 +13,10 @@ tbd Sun Microsystems, Inc. removed cwd "./" (refer to Bugzilla 14399). * File join has been disabled in this release, refer to Bugzilla 16929. +Severity : enhancement +Bugzilla : 20200 +Description: Enhancement for lfs(1) command to use numeric uid/gid. + Severity : normal Bugzilla : 14951 Description: Improved cleanup procedure for conf-sanity test_46a. diff --git a/lustre/doc/lfs.1 b/lustre/doc/lfs.1 index 577db69..fa74417 100644 --- a/lustre/doc/lfs.1 +++ b/lustre/doc/lfs.1 @@ -17,8 +17,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 ] \fB[[!] --size|-S [-+]N[kMGTPE]] [--type |-t {bcdflpsD}] - \fB[[!] --gid|-g N] [[!] --group|-G ] - \fB[[!] --uid|-u N] [[!] --user|-U ] + \fB[[!] --gid|-g|--group|-G |] + \fB[[!] --uid|-u|--user|-U |] \fB\fR .br .B lfs osts @@ -34,7 +34,7 @@ lfs \- Lustre utility to create a file with specific striping pattern, find the .br .B lfs poollist [.] | .br -.B lfs quota [-v] [-o obd_uuid|-I ost_idx|-i mdt_idx] [-u |-g ] +.B lfs quota [-v] [-o obd_uuid|-I ost_idx|-i mdt_idx] [-u | -u |-g | -g ] .br .B lfs quota -t <-u|-g> .br @@ -48,14 +48,14 @@ lfs \- Lustre utility to create a file with specific striping pattern, find the .br .B lfs quotainv [-ug] [-f] .br -.B lfs setquota <-u|--user|-g|--group> +.B lfs setquota <-u|--user|-g|--group> \fB[--block-softlimit ] \fB[--block-hardlimit ] \fB[--inode-softlimit ] \fB[--inode-hardlimit ] \fB\fR .br -.B lfs setquota <-u|--user|-g|--group> +.B lfs setquota <-u|--user|-g|--group> \fB[-b ] [-B ] \fB[-i ] [-I ] \fB\fR @@ -65,7 +65,7 @@ lfs \- Lustre utility to create a file with specific striping pattern, find the \fB[--inode-grace ] \fB\fR .br -.B lfs setquota -t [-u|-g] +.B lfs setquota -t <-u|-g> \fB[-b ] [-i ] \fB\fR .br @@ -134,10 +134,10 @@ Delete the default striping on the specified directory. .B poollist [.] | List the pools in \fBfilesystem\fR or \fBpathname\fR, or the OSTs in \fBfilesystem.pool\fR .TP -.B quota [-v] [-o obd_uuid|-i mdt_idx|-I ost_idx] [-u|-g] -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|-i mdt_idx|-I ost_idx] [-u|-g |||] +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] +.B quota -t <-u|-g> To display block and inode grace times for user (-u) or group (-g) quotas .TP .B quotachown @@ -155,7 +155,7 @@ To turn filesystem quotas off. Options specify quota for users (-u) groups (-g) .B quotainv [-ug] [-f] 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] [--block-softlimit ] [--block-hardlimit ] [--inode-softlimit ] [--inode-hardlimit ] +.B setquota <-u|-g> ||| [--block-softlimit ] [--block-hardlimit ] [--inode-softlimit ] [--inode-hardlimit ] 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 ] [--inode-grace ] diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 7d4e929..c5ba917 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -143,8 +143,8 @@ command_t cmdlist[] = { " [[!] --atime|-A [+-]N] [[!] --mtime|-M [+-]N] [[!] --ctime|-C [+-]N]\n" " [--maxdepth|-D N] [[!] --name|-n ] [--print0|-P]\n" " [--print|-p] [--obd|-O ] [[!] --size|-s [+-]N[bkMGTP]]\n" - " [[!] --type|-t ] [[!] --gid|-g N] [[!] --group|-G ]\n" - " [[!] --uid|-u N] [[!] --user|-U ]\n" + " [[!] --type|-t ] [[!] --gid|-g|--group|-G |]\n" + " [[!] --uid|-u|--user|-U |]\n" " [[!] --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" @@ -180,14 +180,16 @@ command_t cmdlist[] = { {"quotaoff", lfs_quotaoff, 0, "Turn filesystem quotas off.\n" "usage: quotaoff [ -ug ] "}, {"setquota", lfs_setquota, 0, "Set filesystem quotas.\n" - "usage: setquota [ -u | -g ] -b -B -i -I \n" - " setquota -t [ -u | -g ] \n" - " setquota [ -u | --user | -g | --group ] \n" + "usage: setquota <-u|-g> |||\n" + " -b -B \n" + " -i -I \n" + " setquota -t <-u|-g> \n" + " setquota <-u|--user|-g|--group> |||\n" " [--block-softlimit ]\n" " [--block-hardlimit ]\n" " [--inode-softlimit ]\n" " [--inode-hardlimit ] \n" - " setquota [-t] [ -u | --user | -g | --group ]\n" + " setquota [-t] <-u|--user|-g|--group>\n" " [--block-grace ]\n" " [--inode-grace ] \n" " -b can be used instead of --block-softlimit/--block-grace\n" @@ -195,7 +197,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 [-v] [-o obd_uuid|-i mdt_idx|-I ost_idx] [{-u|-g }|-t] "}, + "usage: quota [-v] [-o obd_uuid|-i mdt_idx|-I ost_idx]\n" + " [<-u|-g> |||] \n" + " quota [-o obd_uuid|-i mdt_idx|-I ost_idx] -t <-u|-g> "}, {"quotainv", lfs_quotainv, 0, "Invalidate quota data.\n" "usage: quotainv [-u|-g] "}, #endif @@ -611,45 +615,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(¶m.gid, optarg, GROUP); - if (ret != 0) { + ret = name2id(¶m.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(¶m.uid, optarg, USER); - if (ret != 0) { + ret = name2id(¶m.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; @@ -1744,6 +1730,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); @@ -1768,9 +1755,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': @@ -2070,6 +2060,7 @@ static int lfs_quota(int argc, char **argv) char *obd_type = (char *)qctl.obd_type; char *obd_uuid = (char *)qctl.obd_uuid.uuid; int rc, rc1 = 0, rc2 = 0, rc3 = 0, verbose = 0, pass = 0; + char *endptr; __u32 valid = QC_GENERAL, idx = 0; optind = 0; @@ -2145,9 +2136,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"); -- 1.8.3.1