Thread (28 messages) 28 messages, 5 authors, 2019-11-13

Re: [PATCH] pidfd: add NSpid entries to fdinfo

flat view

From: Jann Horn <jannh@google.com>
Date: 2019-10-14 15:10:32
Also in: lkml

On Mon, Oct 14, 2019 at 12:32 PM Christian Brauner
[off-list ref] wrote:
On Mon, Oct 14, 2019 at 11:43:01AM +0200, Christian Kellner wrote:
quoted
On Sat, 2019-10-12 at 12:21 +0200, Christian Brauner wrote:
quoted
I tried to think of cases where the first entry of Pid is not
identical
to the first entry of NSpid but I came up with none. Maybe you do,
Jann?
Yeah, I don't think that can be the case. By looking at the source of
'pid_nr_ns(pid, ns)' a non-zero return means that a) 'pid' valid, ie.
non-null and b) 'ns' is in the pid namespace hierarchy of 'pid' (at
pid->level, i.e. "pid->numbers[ns->level].ns == ns").
Agreed.
You could probably do:

#ifdef CONFIG_PID_NS
seq_put_decimal_ull(m, "\nNSpid:\t", nr);
for (i = ns->level + 1; i <= pid->level && nr; i++)
        seq_put_decimal_ull(m, "\t", pid->numbers[i].nr);
#endif
Personally, I dislike hiding the precondition for running the loop in
the loop statement like that. While it makes the code more concise, it
somewhat obfuscates the high-level logic at a first glance.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help