From: Frederick Dilger Date: Fri, 24 Jan 2025 21:25:17 +0000 (-0700) Subject: LU-18660 utils: add long opts for 'lfs project' X-Git-Tag: 2.16.55~18 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F19%2F57919%2F15;p=fs%2Flustre-release.git LU-18660 utils: add long opts for 'lfs project' 'lfs project' is missing long options for all of its commands. -0|--print0 -c|--check -C|--clear -d|--directory -k|--keep -p|--proj-inherit -r|--recursive -s|--set-inherit|--inherit Test-Parameters: trivial Signed-off-by: Frederick Dilger Change-Id: Ib09e120c100c58c2443e3c72d5a921f82282e080 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57919 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Li Dongyang Reviewed-by: Oleg Drokin Reviewed-by: Andreas Dilger --- diff --git a/lustre/doc/lfs-project.1 b/lustre/doc/lfs-project.1 index 243f7a1..9f5f9e9 100644 --- a/lustre/doc/lfs-project.1 +++ b/lustre/doc/lfs-project.1 @@ -1,119 +1,84 @@ -.TH LFS-PROJECT 1 2025-01-24 "Lustre" "Lustre User Utilities" +.TH LFS-PROJECT 1 2025-04-23 "Lustre" "Lustre User Utilities" .SH NAME lfs-project \- Change or list project attribute for specified file or directory. .SH SYNOPSIS .SY "lfs project" -.RB [ -d | -r ] -.IR FILE | DIRECTORY ... -.SY "lfs project" -.RB { -p -.I ID -.RB | -s } -.RB [ -r ] +.RB [ -p | --proj-inherit | --inherit +.IR ID ] +.RB [ -d | --directory ] +.RB [ -r | --recursive ] +.RB [ -s | --set-inherit ] .IR FILE | DIRECTORY ... .SY "lfs project" -.B -c -.RB [ -d | -r -.RB [ -p +.BR -c | --check +.RB [ -0 | --print0 ]] +.RB [ -d | --directory ] +.RB [ -p | --proj-inherit | --inherit .IR ID ] -.RB [ -0 ]] +.RB [ -r | --recursive ] .IR FILE | DIRECTORY ... .SY "lfs project" -.B -C -.RB [ -d | -r ] -.RB [ -k ] +.BR -C | --clear +.RB [ -d | --directory ] +.RB [ -k | --keep ] +.RB [ -r | --recursive ] .IR FILE | DIRECTORY ... .YS .SH DESCRIPTION -.BR "lfs project" -.RB [ -d | -r ] -.IR FILE | DIRECTORY ... +.B lfs project +lists the project ID and flags on +.IR FILE "(s) or " DIRECTORIES . +.SH OPTIONS +.TP +.BR -0 ", " --print0 +Print pathnames returned by -c with a trailing NUL, suitable for use by +.B 'xargs -0 lfs project -p'. .TP -List project ID and flags on file(s) or directories. +.BR -c ", " --check +Check project ID and inherit flag on specified +.IR FILE "(s) or " DIRECTORY . +If +.BR -p | --proj-inherit | --inherit +is not given, then use the project ID on the top-level directory, +otherwise use the specified +.IR ID . +If checking a directory and/or recursively, print only files that do not match +.IR ID . +.TP +.BR -C ", " --clear +Clear inherit attribute and reset project +.I ID +to 0 for +.IR FILE " or " DIRECTORY . +If the +.BR -d | --directory +option is set, then clear only the directory itself. .TP -.B -d +.BR -d ", " --directory Show the directory's own project ID and flags, override -.B -r +.BR -r | --recursive option. .TP -.B -r -Recursively list all descendants'(of the directory) project attribute. -.PP -.BR "lfs project" -.BR { -p -.I ID -.RB | -s } -.RB [ -r ] -.IR FILE | DIRECTORY ... +.BR -k ", " --keep +Keep the project ID unchanged. +Can only be specified with +.BR -C | --clear . .TP -Set project ID and/or inherit flag for specified file(s) or directories. +.BR -p ", " --proj-inherit | --inherit +Set project ID and inherit flag on the +.IR FILE "(s) or " DIRECTORIES. +Set project ID with given value for the specified +.IR FILE " or " DIRECTORY . .TP -.BI -p \ ID -Set project -.I ID -with given value for the specified file or directory +.B -r ", " --recursive +Recursively apply lfs project on all descendants of the +.IR DIRECTORY . .TP -.B -s +.BR -s ", " --set-inherit Set the .B PROJID_INHERIT attribute on directories, so that new files and subdirectories created therein will inherit the project ID and attribute from the parent. -.TP -.B -r -Set project -.I ID -with the directory's project ID for all its descendants (with -.B -p -specified). For descendant directories, also set -inherit flag (if -.B -s -specified). -.PP -.BR "lfs project" -.B -c -.RB [ -d | -r [ -p -.IR ID ] -.RB [ -0 ]] -.IR FILE | DIRECTORY ... -.PP -Check project ID and flags on file(s) or directories, print outliers. -.TP -.B -c -Check project ID and inherit flag on specified file(s) or directory. If -.B -p -is not given, then use the project ID on the top-level directory, -otherwise use the ID specified with -.BR -p . -if checking a directory and or recursively, print only files that do not match. -.TP -.B -0 -Print pathnames returned by -c with a trailing NUL, suitable for use by -.B 'xargs -0 lfs project -p'. -.PP -.BR "lfs project" -.B -C -.RB [ -d | -r ] -.RB [ -k ] -.IR FILE | DIRECTORY ... -.PP -Clear the project inherit flag and ID on the file(s) or directories -.TP -.B -C -Clear inherit attribute and reset project ID to 0 for file or directory. -.TP -.B -d -Clear only the directory itself. -.TP -.B -r -Clear the directory and all its descendants recursively. If neither -.B -d -nor -.B -r -is specified, clear the directory and its -immediate children. -.TP -.B -k -Keep the project ID unchanged. .SH EXAMPLES set directory quota on .BR /mnt/lustre/dir1, diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 3591b92..4c88774 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -555,13 +555,17 @@ command_t cmdlist[] = { " quota -a {-u|-g|-p} [-s START_QID] [-e END_QID] [MOUNT_POINT ...]\n"}, {"project", lfs_project, 0, "Change or list project attribute for specified file or directory.\n" - "usage: project [-d|-r] \n" + "usage: project [-d|--directory] [-r|--recursive] FILE|DIRECTORY...\n" " list project ID and flags on file(s) or directories\n" - " project [-p id] [-s] [-r] \n" + " project [-p|--proj-inherit|--inherit ID] [-s|--set-inherit]\n" + " [-d|--directory] [-r|--recursive] FILE|DIRECTORY...\n" " set project ID and/or inherit flag for specified file(s) or directories\n" - " project -c [-d|-r [-p id] [-0]] \n" + " project -c|--check [-p|--proj-inherit|--inherit ID]\n" + " [-0|--print0] [-d|--directory] [-r|--recursive]\n" + " FILE|DIRECTORY...\n" " check project ID and flags on file(s) or directories, print outliers\n" - " project -C [-d|-r] [-k] \n" + " project -C|--clear [-k|--keep] [-d|--directory]\n" + " [-r|--recursive] FILE|DIRECTORY...\n" " clear the project inherit flag and ID on the file or directory\n" }, #endif @@ -9807,14 +9811,29 @@ static int lfs_project(int argc, char **argv) int ret = 0, err = 0, c, i; struct project_handle_control phc = { 0 }; enum lfs_project_ops_t op; + struct option long_opts[] = { + { .val = '0', .name = "print0", .has_arg = no_argument }, + { .val = 'c', .name = "check", .has_arg = no_argument }, + { .val = 'C', .name = "clear", .has_arg = no_argument }, + { .val = 'd', .name = "directory", .has_arg = no_argument }, + { .val = 'k', .name = "keep", .has_arg = no_argument }, + { .val = 'p', .name = "proj-inherit", .has_arg = required_argument }, + { .val = 'r', .name = "recursive", .has_arg = no_argument }, + { .val = 's', .name = "set-inherit", .has_arg = no_argument }, + { .val = 's', .name = "inherit", .has_arg = no_argument }, + }; phc.newline = true; phc.assign_projid = false; /* default action */ op = LFS_PROJECT_LIST; - while ((c = getopt(argc, argv, "p:cCsdkr0")) != -1) { + while ((c = getopt_long(argc, argv, "0cCdkp:rs", + long_opts, NULL)) != -1) { switch (c) { + case '0': + phc.newline = false; + break; case 'c': if (op != LFS_PROJECT_LIST) { fprintf(stderr, @@ -9835,26 +9854,12 @@ static int lfs_project(int argc, char **argv) op = LFS_PROJECT_CLEAR; break; - case 's': - if (op != LFS_PROJECT_LIST) { - fprintf(stderr, - "%s: cannot specify '-c' '-C' '-s' together\n", - progname); - return CMD_HELP; - } - - phc.set_inherit = true; - op = LFS_PROJECT_SET; - break; case 'd': phc.dironly = true; break; case 'k': phc.keep_projid = true; break; - case 'r': - phc.recursive = true; - break; case 'p': if (str2quotaid(&phc.projid, optarg)) { fprintf(stderr, @@ -9866,8 +9871,19 @@ static int lfs_project(int argc, char **argv) phc.assign_projid = true; break; - case '0': - phc.newline = false; + case 'r': + phc.recursive = true; + break; + case 's': + if (op != LFS_PROJECT_LIST) { + fprintf(stderr, + "%s: cannot specify '-c' '-C' '-s' together\n", + progname); + return CMD_HELP; + } + + phc.set_inherit = true; + op = LFS_PROJECT_SET; break; default: fprintf(stderr, "%s: invalid option '%c'\n",