public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Sidong Yang <realwakka@gmail.com>
To: Nikolay Borisov <nborisov@suse.com>
Cc: linux-btrfs <linux-btrfs@vger.kernel.org>,
	David Sterba <dsterba@suse.com>
Subject: Re: [PATCH v2] btrfs-progs: filesystem: du: skip file that permission denied
Date: Mon, 22 Nov 2021 08:32:40 +0000	[thread overview]
Message-ID: <20211122083240.GB8836@realwakka> (raw)
In-Reply-To: <09d229c6-ae30-4453-c9d4-39109f032b99@suse.com>

On Mon, Nov 22, 2021 at 09:20:00AM +0200, Nikolay Borisov wrote:
> 
> 
> On 21.11.21 г. 17:15, Sidong Yang wrote:
> > This patch handles issue #421. Filesystem du command fails and exit
> > when it access file that has permission denied. But it can continue the
> > command except the files. This patch recovers ret value when permission
> > denied.
> > 
> > Signed-off-by: Sidong Yang <realwakka@gmail.com>
> 
> 
> The code itself is fine so :
> 
> 
> Reviewed-by: Nikolay Borisov <nborisov@suse.com>
> 
> 
> OTOH when I looked at the code rather than just the patch I can't help
> but wonder shouldn't we actually structure this the way you initially
> proposed but also add a debug output along the lines of "skipping
> file/dir XXXX due to permission denied", otherwise users might not be
> able to account for some space and they can possibly wonder that
> something is wrong with btrfs fi du command.

You mean that it would be better that print some debug message than
skipping silently. I agree. So I would add this code in condition.

fprintf(stderr, "skipping file/dir: %s : %m\n", entry->d_name);

I think it's okay that it prints when ENOTTY occurs. Is this code what
you meant?
> 
> 
> > ---
> >  cmds/filesystem-du.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/cmds/filesystem-du.c b/cmds/filesystem-du.c
> > index 5865335d..fb7753ca 100644
> > --- a/cmds/filesystem-du.c
> > +++ b/cmds/filesystem-du.c
> > @@ -403,7 +403,7 @@ static int du_walk_dir(struct du_dir_ctxt *ctxt, struct rb_root *shared_extents)
> >  						  dirfd(dirstream),
> >  						  shared_extents, &tot, &shr,
> >  						  0);
> > -				if (ret == -ENOTTY) {
> > +				if (ret == -ENOTTY || ret == -EACCES) {
> >  					ret = 0;
> >  					continue;
> >  				} else if (ret) {
> > 

  reply	other threads:[~2021-11-22  8:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-21 15:15 [PATCH v2] btrfs-progs: filesystem: du: skip file that permission denied Sidong Yang
2021-11-22  7:20 ` Nikolay Borisov
2021-11-22  8:32   ` Sidong Yang [this message]
2021-11-22  9:32     ` Nikolay Borisov
2021-11-22  9:53       ` Graham Cobb
2021-11-22 10:57         ` Nikolay Borisov
2021-11-22 15:10           ` Sidong Yang
2021-11-22 15:20             ` Nikolay Borisov
2021-11-22 15:51               ` Sidong Yang

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=20211122083240.GB8836@realwakka \
    --to=realwakka@gmail.com \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@suse.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