public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Donald <ddouwsma@bigpond.net.au>
To: "Arkadiusz Miśkiewicz" <arekm@maven.pl>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 1/2] [QUOTA]: xfs_quota project takes -d option to limit directory depth
Date: Thu, 29 Jan 2009 17:22:17 +1100	[thread overview]
Message-ID: <49814B19.2000907@bigpond.net.au> (raw)
In-Reply-To: <1233151015-10496-1-git-send-email-arekm@maven.pl>

Arkadiusz Miśkiewicz wrote:
> xfs_quota project directory depth processing can now be limited
> to certain depth. For example: xfs_quota -x -c "project -d 2 -s 10"
> limits recursion to level 2.

Nice improvements. Could you also update the man page for xfs_quota with for both changes?

Don


> Signed-off-by: Arkadiusz Miśkiewicz <arekm@maven.pl>
> ---
>  quota/project.c |   34 +++++++++++++++++++++++++++-------
>  1 files changed, 27 insertions(+), 7 deletions(-)
> 
> diff --git a/quota/project.c b/quota/project.c
> index b4171e5..6635487 100644
> --- a/quota/project.c
> +++ b/quota/project.c
> @@ -23,6 +23,7 @@
>  
>  static cmdinfo_t project_cmd;
>  static prid_t prid;
> +static int recurse_depth = -1;
>  
>  enum {
>  	CHECK_PROJECT	= 0x1,
> @@ -75,6 +76,10 @@ project_help(void)
>  " which do not have the project ID of the rest of the tree, or if the inode\n"
>  " flag is not set.\n"
>  "\n"
> +" The -d <depth> option allows to descend at most <depth> levels of directories\n"
> +" below the command line arguments. -d 0 means only apply the actions\n"
> +" to the top level of the projects. -d -1 means no recursion limit (default).\n"
> +"\n"
>  " The /etc/projid and /etc/projects file formats are simple, and described\n"
>  " on the xfs_quota man page.\n"
>  "\n"));
> @@ -90,6 +95,9 @@ check_project(
>  	struct fsxattr		fsx;
>  	int			fd;
>  
> +	if (recurse_depth >= 0 && data->level > recurse_depth)
> +		return -1;
> +
>  	if (flag == FTW_NS ){
>  		exitcode = 1;
>  		fprintf(stderr, _("%s: cannot stat file %s\n"), progname, path);
> @@ -132,6 +140,9 @@ clear_project(
>  	struct fsxattr		fsx;
>  	int			fd;
>  
> +	if (recurse_depth >= 0 && data->level > recurse_depth)
> +		return -1;
> +
>  	if (flag == FTW_NS ){
>  		exitcode = 1;
>  		fprintf(stderr, _("%s: cannot stat file %s\n"), progname, path);
> @@ -176,6 +187,9 @@ setup_project(
>  	struct fsxattr		fsx;
>  	int			fd;
>  
> +	if (recurse_depth >= 0 && data->level > recurse_depth)
> +		return -1;
> +
>  	if (flag == FTW_NS ){
>  		exitcode = 1;
>  		fprintf(stderr, _("%s: cannot stat file %s\n"), progname, path);
> @@ -219,15 +233,15 @@ project_operations(
>  	switch (type) {
>  	case CHECK_PROJECT:
>  		printf(_("Checking project %s (path %s)...\n"), project, dir);
> -		nftw(dir, check_project, 100, FTW_PHYS|FTW_MOUNT|FTW_DEPTH);
> +		nftw(dir, check_project, 100, FTW_PHYS|FTW_MOUNT);
>  		break;
>  	case SETUP_PROJECT:
>  		printf(_("Setting up project %s (path %s)...\n"), project, dir);
> -		nftw(dir, setup_project, 100, FTW_PHYS|FTW_MOUNT|FTW_DEPTH);
> +		nftw(dir, setup_project, 100, FTW_PHYS|FTW_MOUNT);
>  		break;
>  	case CLEAR_PROJECT:
>  		printf(_("Clearing project %s (path %s)...\n"), project, dir);
> -		nftw(dir, clear_project, 100, FTW_PHYS|FTW_MOUNT|FTW_DEPTH);
> +		nftw(dir, clear_project, 100, FTW_PHYS|FTW_MOUNT);
>  		break;
>  	}
>  }
> @@ -249,8 +263,9 @@ project(
>  		count++;
>  	}
>  
> -	printf(_("Processed %d %s paths for project %s\n"),
> -		 count, projects_file, project);
> +	printf(_("Processed %d %s paths for project %s with recursion depth %s (%d)\n"),
> +		 count, projects_file, project,
> +		 recurse_depth < 0 ? "infinite" : "limited", recurse_depth);
>  }
>  
>  static int
> @@ -260,11 +275,16 @@ project_f(
>  {
>  	int		c, type = 0;
>  
> -	while ((c = getopt(argc, argv, "csC")) != EOF) {
> +	while ((c = getopt(argc, argv, "cd:sC")) != EOF) {
>  		switch (c) {
>  		case 'c':
>  			type = CHECK_PROJECT;
>  			break;
> +		case 'd':
> +			recurse_depth = atoi(optarg);
> +			if (recurse_depth < 0)
> +				recurse_depth = -1;
> +			break;
>  		case 's':
>  			type = SETUP_PROJECT;
>  			break;
> @@ -311,7 +331,7 @@ project_init(void)
>  	project_cmd.name = _("project");
>  	project_cmd.altname = _("tree");
>  	project_cmd.cfunc = project_f;
> -	project_cmd.args = _("[-c|-s|-C] project ...");
> +	project_cmd.args = _("[-c|-s|-C|-d <depth>] project ...");
>  	project_cmd.argmin = 1;
>  	project_cmd.argmax = -1;
>  	project_cmd.oneline = _("check, setup or clear project quota trees");

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  parent reply	other threads:[~2009-01-29  9:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-28 13:56 [PATCH 1/2] [QUOTA]: xfs_quota project takes -d option to limit directory depth Arkadiusz Miśkiewicz
2009-01-28 13:56 ` [PATCH 2/2] [QUOTA]: Add support for passing project paths on cmdline Arkadiusz Miśkiewicz
2009-01-29  6:22 ` Donald [this message]
2009-01-29  7:51   ` [PATCH] [MAN]: Document new project quota options (-d and -p) Arkadiusz Miśkiewicz
2009-01-29 22:00 ` [PATCH 1/2] [QUOTA]: xfs_quota project takes -d option to limit directory depth Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49814B19.2000907@bigpond.net.au \
    --to=ddouwsma@bigpond.net.au \
    --cc=arekm@maven.pl \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox