Thread (3 messages) 3 messages, 2 authors, 2021-11-21

Re: [RFC PATCH] btrfs-progs: filesystem: du: skip file that permission denied

From: Nikolay Borisov <hidden>
Date: 2021-11-21 09:01:05


On 21.11.21 г. 9:47, Sidong Yang wrote:
quoted hunk ↗ jump to hunk
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 <redacted>
---
 cmds/filesystem-du.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/cmds/filesystem-du.c b/cmds/filesystem-du.c
index 5865335d..64a1f7f5 100644
--- a/cmds/filesystem-du.c
+++ b/cmds/filesystem-du.c
@@ -406,6 +406,9 @@ static int du_walk_dir(struct du_dir_ctxt *ctxt, struct rb_root *shared_extents)
 				if (ret == -ENOTTY) {
 					ret = 0;
 					continue;
+				} else if (ret == -EACCES) {
This can be added to the above condition with || ret == -EACCESS. Avoids
code duplication.
+					ret = 0;
+					continue;
 				} else if (ret) {
 					errno = -ret;
 					fprintf(stderr,
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help