btrfs-progs: filesystem: du: skip file that permission denied
RFC PATCH 1/1 btrfs-progs: filesystem: du: skip file that permission denied
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.
--- cmds/filesystem-du.c | 3 +++ 1 file changed, 3 insertions(+)
cmds/filesystem-du.c +3 -0
@@ -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 ) { + ret =0 ; +continue ; }else if (ret) { errno = -ret; fprintf(stderr,
Signature · 1 line
2.25.1
Quoted 15 lines · 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 recovers ret value when permission denied.
Signed-off-by Sidong Yang <[email protected]>--- cmds/filesystem-du.c | 3 +++ 1 file changed, 3 insertions(+)cmds/filesystem-du.c +0
-0
cmds/filesystem-du.c static int du_walk_dir(struct du_dir_ctxt *ctxt, struct rb_root *shared_extents) · line 409
Quoted 4 lines
cmds/filesystem-du.c +1
-0@@ -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.
Quoted 6 lines
cmds/filesystem-du.c +2
-0+ ret =0 ; +continue ; }else if (ret) { errno = -ret; fprintf(stderr,
Quoted 13 lines · Nikolay Borisov
Quoted 10 lines · 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 recovers ret value when permission denied.
Signed-off-by Sidong Yang <[email protected]>--- cmds/filesystem-du.c | 3 +++ 1 file changed, 3 insertions(+)
Quoted 12 lines
cmds/filesystem-du.c static int du_walk_dir(struct du_dir_ctxt *ctxt, struct rb_root *shared_extents) · line 409
Quoted 9 lines
cmds/filesystem-du.c +1
-0@@ -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.
Thanks! It would be better.
Quoted 7 lines
Quoted 7 lines
cmds/filesystem-du.c +2
-0+ ret =0 ; +continue ; }else if (ret) { errno = -ret; fprintf(stderr,