public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] btrfs-progs: filesystem: du: skip file that permission denied
@ 2021-11-22 15:54 Sidong Yang
  2021-11-30 17:43 ` David Sterba
  0 siblings, 1 reply; 3+ messages in thread
From: Sidong Yang @ 2021-11-22 15:54 UTC (permalink / raw)
  To: Nikolay Borisov, Graham Cobb, linux-btrfs, David Sterba; +Cc: Sidong Yang

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-12-05 15:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-22 15:54 [PATCH v3] btrfs-progs: filesystem: du: skip file that permission denied Sidong Yang
2021-11-30 17:43 ` David Sterba
2021-12-05 15:13   ` Sidong Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox