From: Sidong Yang <realwakka@gmail.com>
To: Nikolay Borisov <nborisov@suse.com>,
Graham Cobb <g.btrfs@cobb.uk.net>,
linux-btrfs <linux-btrfs@vger.kernel.org>,
David Sterba <dsterba@suse.com>
Cc: Sidong Yang <realwakka@gmail.com>
Subject: [PATCH v3] btrfs-progs: filesystem: du: skip file that permission denied
Date: Mon, 22 Nov 2021 15:54:11 +0000 [thread overview]
Message-ID: <20211122155411.10626-1-realwakka@gmail.com> (raw)
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 prints error message just like
/bin/du does and it continues if it can.
Signed-off-by: Sidong Yang <realwakka@gmail.com>
---
v3:
- prints error message like /bin/du does
---
cmds/filesystem-du.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/cmds/filesystem-du.c b/cmds/filesystem-du.c
index 5865335d..7ea2da85 100644
--- a/cmds/filesystem-du.c
+++ b/cmds/filesystem-du.c
@@ -403,14 +403,14 @@ 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) {
- ret = 0;
- continue;
- } else if (ret) {
+ if (ret) {
errno = -ret;
- fprintf(stderr,
- "failed to walk dir/file: %s : %m\n",
- entry->d_name);
+ fprintf(stderr, "cannot access: '%s:' %m\n",
+ entry->d_name);
+ if (ret == -ENOTTY || ret == -EACCES) {
+ ret = 0;
+ continue;
+ }
break;
}
--
2.25.1
next reply other threads:[~2021-11-22 15:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-22 15:54 Sidong Yang [this message]
2021-11-30 17:43 ` [PATCH v3] btrfs-progs: filesystem: du: skip file that permission denied David Sterba
2021-12-05 15:13 ` 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=20211122155411.10626-1-realwakka@gmail.com \
--to=realwakka@gmail.com \
--cc=dsterba@suse.com \
--cc=g.btrfs@cobb.uk.net \
--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