From 23cc21d6f46e79900cf9b7b1bc32c2dda65121be Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Tue, 18 Apr 2017 01:35:54 -0600 Subject: [PATCH] LU-8998 utils: allow "--component-*" to be abbreviated Allow "--component-foo" arguments to be abbreviated to "--comp-foo" to simplify userspace, especially for options like "--comp-flags" that do not have a short option. Test-Parameters: trivial Signed-off-by: Andreas Dilger Change-Id: I8c434dd68c042efefc2df93d0f2d7b9bc33ebbe5 Reviewed-on: https://review.whamcloud.com/26699 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Niu Yawei Reviewed-by: Jinshan Xiong Reviewed-by: Oleg Drokin --- lustre/utils/lfs.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 0eaaf7e..c262cc1 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -1303,10 +1303,14 @@ static int lfs_setstripe(int argc, char **argv) struct option long_opts[] = { /* --block is only valid in migrate mode */ {"block", no_argument, 0, 'b'}, - {"component-add", no_argument, 0, LFS_COMP_ADD_OPT}, - {"component-del", no_argument, 0, LFS_COMP_DEL_OPT}, + {"comp-add", no_argument, 0, LFS_COMP_ADD_OPT}, + {"component-add", no_argument, 0, LFS_COMP_ADD_OPT}, + {"comp-del", no_argument, 0, LFS_COMP_DEL_OPT}, + {"component-del", no_argument, 0, LFS_COMP_DEL_OPT}, + {"comp-flags", required_argument, 0, LFS_COMP_FLAGS_OPT}, {"component-flags", required_argument, 0, LFS_COMP_FLAGS_OPT}, - {"component-set", no_argument, 0, LFS_COMP_SET_OPT}, + {"comp-set", no_argument, 0, LFS_COMP_SET_OPT}, + {"component-set", no_argument, 0, LFS_COMP_SET_OPT}, #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 59, 0) /* This formerly implied "stripe-count", but was explicitly * made "stripe-count" for consistency with other options, @@ -1316,6 +1320,7 @@ static int lfs_setstripe(int argc, char **argv) {"stripe-count", required_argument, 0, 'c'}, {"stripe_count", required_argument, 0, 'c'}, {"delete", no_argument, 0, 'd'}, + {"comp-end", required_argument, 0, 'E'}, {"component-end", required_argument, 0, 'E'}, /* dirstripe {"mdt-hash", required_argument, 0, 'H'}, */ #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 59, 0) @@ -1326,8 +1331,9 @@ static int lfs_setstripe(int argc, char **argv) #endif {"stripe-index", required_argument, 0, 'i'}, {"stripe_index", required_argument, 0, 'i'}, + {"comp-id", required_argument, 0, 'I'}, {"component-id", required_argument, 0, 'I'}, - {"mdt", required_argument, 0, 'm'}, + {"mdt", required_argument, 0, 'm'}, {"mdt-index", required_argument, 0, 'm'}, {"mdt_index", required_argument, 0, 'm'}, /* --non-block is only valid in migrate mode */ @@ -1814,13 +1820,17 @@ static int lfs_find(int argc, char **argv) }; struct option long_opts[] = { {"atime", required_argument, 0, 'A'}, + {"comp-count", required_argument, 0, LFS_COMP_COUNT_OPT}, {"component-count", required_argument, 0, LFS_COMP_COUNT_OPT}, + {"comp-flags", required_argument, 0, LFS_COMP_FLAGS_OPT}, {"component-flags", required_argument, 0, LFS_COMP_FLAGS_OPT}, + {"comp-start", required_argument, 0, LFS_COMP_START_OPT}, {"component-start", required_argument, 0, LFS_COMP_START_OPT}, {"stripe-count", required_argument, 0, 'c'}, {"stripe_count", required_argument, 0, 'c'}, {"ctime", required_argument, 0, 'C'}, {"maxdepth", required_argument, 0, 'D'}, + {"comp-end", required_argument, 0, 'E'}, {"component-end", required_argument, 0, 'E'}, {"gid", required_argument, 0, 'g'}, {"group", required_argument, 0, 'G'}, @@ -2289,8 +2299,11 @@ static int lfs_getstripe_internal(int argc, char **argv, struct find_param *param) { struct option long_opts[] = { + {"comp-count", no_argument, 0, LFS_COMP_COUNT_OPT}, {"component-count", no_argument, 0, LFS_COMP_COUNT_OPT}, + {"comp-flags", required_argument, 0, LFS_COMP_FLAGS_OPT}, {"component-flags", required_argument, 0, LFS_COMP_FLAGS_OPT}, + {"comp-start", required_argument, 0, LFS_COMP_START_OPT}, {"component-start", required_argument, 0, LFS_COMP_START_OPT}, #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 59, 0) /* This formerly implied "stripe-count", but was explicitly @@ -2302,6 +2315,7 @@ static int lfs_getstripe_internal(int argc, char **argv, {"stripe_count", no_argument, 0, 'c'}, {"directory", no_argument, 0, 'd'}, {"default", no_argument, 0, 'D'}, + {"comp-end", required_argument, 0, 'E'}, {"component-end", required_argument, 0, 'E'}, {"fid", no_argument, 0, 'F'}, {"generation", no_argument, 0, 'g'}, @@ -2314,6 +2328,7 @@ static int lfs_getstripe_internal(int argc, char **argv, #endif {"stripe-index", no_argument, 0, 'i'}, {"stripe_index", no_argument, 0, 'i'}, + {"comp-id", required_argument, 0, 'I'}, {"component-id", required_argument, 0, 'I'}, {"layout", no_argument, 0, 'L'}, {"mdt", no_argument, 0, 'm'}, -- 1.8.3.1