[PATCH] Print more error messages
Ákos Uzonyi
uzonyi.akos at gmail.com
Thu Aug 20 17:54:34 UTC 2020
On Thu, 20 Aug 2020 at 18:57, Dmitry V. Levin <ldv at altlinux.org> wrote:
> On Thu, Aug 20, 2020 at 06:39:30PM +0200, Ákos Uzonyi wrote:
> > ---
> >
> > Could you please run the dup-y test again with this patch applied?
> > Hopefully we'll see where the problem comes from.
> >
> > pidns.c | 15 ++++++++++++---
> > 1 file changed, 12 insertions(+), 3 deletions(-)
> >
> > diff --git a/pidns.c b/pidns.c
> > index 9d8695da..7e7d8212 100644
> > --- a/pidns.c
> > +++ b/pidns.c
> > @@ -168,14 +168,18 @@ get_ns_hierarchy(int proc_pid, unsigned int *ns_buf, size_t ns_buf_size)
> > xsprintf(path, "/proc/%s/ns/pid", pid_to_str(proc_pid));
> >
> > int fd = open_file(path, O_RDONLY);
> > - if (fd < 0)
> > + if (fd < 0) {
> > + perror_func_msg("opening %s", path);
> > return 0;
> > + }
>
> There are quite a few of these, e.g.
> get_ns_hierarchy: opening /proc/1/ns/pid: Permission denied
> but they are harmless.
I was thinking about keeping these messages in the final version, but
I think we don't need these permission denied errors, so it seems
better not to keep them.
> > @@ -248,6 +254,9 @@ get_id_list(int proc_pid, int *id_buf, enum pid_type type)
> > }
> > }
> >
> > + if (!p)
> > + error_func_msg("no line found starting with %s", ns_str);
>
> Yes, that was it, it prints "no line found starting with NSpid:".
> On that system I also see the following:
> $ grep -c ^NS /proc/self/status
> 0
Nice, thanks.
Then I think we should modify this line a bit in is_proc_ours:
- cached_val = get_id_list(0, NULL, PT_TID) == 1;
+ cached_val = get_id_list(0, NULL, PT_TID) <= 1;
So in case get_id_list returns 0, we consider /proc to be ours, as
this most probably means there is no PID namespace support in the
kernel.
More information about the Strace-devel
mailing list