[PATCH v4 1/7] PID namespace translation support

Dmitry V. Levin ldv at altlinux.org
Thu Jul 30 14:28:05 UTC 2020


On Mon, Jul 27, 2020 at 08:54:04PM +0200, Ákos Uzonyi wrote:
[...]
> diff --git a/Makefile.am b/Makefile.am
> index f5447811..15fcd9a6 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -135,6 +135,7 @@ libstrace_a_SOURCES =	\
>  	getcpu.c	\
>  	getcwd.c	\
>  	getpagesize.c \
> +	getpid.c	\
>  	getrandom.c	\
>  	hdio.c		\
>  	hostname.c	\

getpid.c is not here yet, it's added by a subsequent commit.

[...]
> diff --git a/defs.h b/defs.h
> index 21f8775d..4df21700 100644
> --- a/defs.h
> +++ b/defs.h
> @@ -280,6 +280,9 @@ struct tcb {
>  	struct timespec etime;	/* Syscall entry time (CLOCK_MONOTONIC) */
>  	struct timespec delay_expiration_time; /* When does the delay end */
>  
> +	uint64_t pid_ns;
> +	bool pid_ns_inited;
> +
>  	struct mmap_cache_t *mmap_cache;
>  
>  	/*

Hmm, this adds a hole between pid_ns and mmap_cache fields on 64-bit systems.

I wonder whether we need pid_ns_inited field at all.  If I read the kernel
correctly, pid_ns is assigned from struct ns_common.inum of type unsigned int.

> diff --git a/strace.1.in b/strace.1.in
> index 3b21caec..09b7d4ad 100644
> --- a/strace.1.in
> +++ b/strace.1.in
> @@ -1075,6 +1075,12 @@ Print all available information associated with file descritors:
>  protocol-specific information associated with socket file descriptors,
>  block/character device number associated with device file descriptors,
>  and PIDs asociated with pidfd file descriptors.
> +.TP
> +.B \-Y
> +.TQ
> +.BR \-\-pidns\-translation
> +If strace and tracee are in different PID namespaces, print PIDs in
> +strace's namespace also.
>  .SS Statistics
>  .TP 12
>  .B \-c

This looks like a leftover from earlier iterations before we decided
not to introduce -Y option.


-- 
ldv


More information about the Strace-devel mailing list