* [RFC PATCH] btrfs-progs: filesystem: du: skip file that permission denied
@ 2021-11-21 7:47 Sidong Yang
2021-11-21 9:01 ` Nikolay Borisov
0 siblings, 1 reply; 3+ messages in thread
From: Sidong Yang @ 2021-11-21 7:47 UTC (permalink / raw)
To: linux-btrfs; +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 recovers ret value when permission
denied.
Signed-off-by: Sidong Yang <realwakka@gmail.com>
---
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) {
+ ret = 0;
+ continue;
} else if (ret) {
errno = -ret;
fprintf(stderr,
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [RFC PATCH] btrfs-progs: filesystem: du: skip file that permission denied
2021-11-21 7:47 [RFC PATCH] btrfs-progs: filesystem: du: skip file that permission denied Sidong Yang
@ 2021-11-21 9:01 ` Nikolay Borisov
2021-11-21 14:53 ` Sidong Yang
0 siblings, 1 reply; 3+ messages in thread
From: Nikolay Borisov @ 2021-11-21 9:01 UTC (permalink / raw)
To: Sidong Yang, linux-btrfs
On 21.11.21 г. 9:47, 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>
> ---
> 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,
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [RFC PATCH] btrfs-progs: filesystem: du: skip file that permission denied
2021-11-21 9:01 ` Nikolay Borisov
@ 2021-11-21 14:53 ` Sidong Yang
0 siblings, 0 replies; 3+ messages in thread
From: Sidong Yang @ 2021-11-21 14:53 UTC (permalink / raw)
To: Nikolay Borisov; +Cc: linux-btrfs
On Sun, Nov 21, 2021 at 11:01:02AM +0200, Nikolay Borisov wrote:
>
>
> On 21.11.21 г. 9:47, 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>
> > ---
> > 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.
Thanks! It would be better.
>
> > + ret = 0;
> > + continue;
> > } else if (ret) {
> > errno = -ret;
> > fprintf(stderr,
> >
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-11-21 14:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-21 7:47 [RFC PATCH] btrfs-progs: filesystem: du: skip file that permission denied Sidong Yang
2021-11-21 9:01 ` Nikolay Borisov
2021-11-21 14:53 ` Sidong Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox