[PATCH 1/7] PID namespace translation support

Dmitry V. Levin ldv at altlinux.org
Thu Jul 16 18:24:29 UTC 2020


On Sun, Jul 12, 2020 at 09:46:30PM +0200, Ákos Uzonyi wrote:
> * defs.h (pidns_translation): New variable.
> (tcb): Add pid_ns, pid_ns_inited fields

Trailing dot is missing here.

> (RVAL_MASK): Change value from 013 to 017.
> (RVAL_TID, RVAL_SID, RVAL_TGID, RVAL_PGID): New definitions.
> (pid_type): New enum.
> (pidns_init, translate_pid, printpid, printpid_translation):
> New function definitions.
> * pidns.c: New file.
> * trie.c: New file.
> * trie.h: New file.
> * Makefile.am (libstrace_a_SOURCES): Add trie.c, pidns.c.
> * strace.c (pidns_translation): New variable.
> (init): Add -Y and --pidns-translation option.

I'm not sure -Y is versatile enough.  Do we really need a short option
for this feature when --pidns-translation abbreviates so well?

[...]
> --- a/NEWS
> +++ b/NEWS
> @@ -14,6 +14,7 @@ Noteworthy changes in release ?.? (????-??-??)
>      KEYCTL_*, KVM_*, LOOP_*, NDA_*, RTC_*, TCA_*, STATX_*, and *_MAGIC
>      constants.
>    * Updated lists of ioctl commands from Linux 5.8.
> +  * Added -Y opition for PID namespace translation

Trailing dot is missing here.
Consider advertising --pidns-translation instead of -Y.

[...]
> +static int
> +get_pid_max(void)
> +{
> +	static int pid_max = -1;
> +
> +	if (pid_max < 0) {
> +		pid_max = INT_MAX;
> +
> +		FILE *f = fopen("/proc/sys/kernel/pid_max", "r");
> +		if (!f)
> +			perror_msg("opening /proc/sys/kernel/pid_max");
> +		else
> +			fscanf(f, "%d", &pid_max);
> +	}
> +
> +	return pid_max;
> +}

Consider using read_int_from_file function.


-- 
ldv


More information about the Strace-devel mailing list