diff options
author | Andrei Vagin <avagin@gmail.com> | 2020-04-11 08:40:31 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-04-21 09:08:15 +0200 |
commit | 0543416b0dc60df972ec47859450c80c7949145f (patch) | |
tree | a4f5ff139c49f5c24592cd228bdbc328259c3a62 /kernel | |
parent | f26cb6f6ded5af397b3a5c6e2782f7bcfbe786d6 (diff) | |
download | linux-stable-0543416b0dc60df972ec47859450c80c7949145f.tar.gz linux-stable-0543416b0dc60df972ec47859450c80c7949145f.tar.bz2 linux-stable-0543416b0dc60df972ec47859450c80c7949145f.zip |
proc, time/namespace: Show clock symbolic names in /proc/pid/timens_offsets
commit 94d440d618467806009c8edc70b094d64e12ee5a upstream.
Michael Kerrisk suggested to replace numeric clock IDs with symbolic names.
Now the content of these files looks like this:
$ cat /proc/774/timens_offsets
monotonic 864000 0
boottime 1728000 0
For setting offsets, both representations of clocks (numeric and symbolic)
can be used.
As for compatibility, it is acceptable to change things as long as
userspace doesn't care. The format of timens_offsets files is very new and
there are no userspace tools yet which rely on this format.
But three projects crun, util-linux and criu rely on the interface of
setting time offsets and this is why it's required to continue supporting
the numeric clock IDs on write.
Fixes: 04a8682a71be ("fs/proc: Introduce /proc/pid/timens_offsets")
Suggested-by: Michael Kerrisk <mtk.manpages@gmail.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Michael Kerrisk <mtk.manpages@gmail.com>
Acked-by: Michael Kerrisk <mtk.manpages@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: Dmitry Safonov <0x7f454c46@gmail.com>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/20200411154031.642557-1-avagin@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/time/namespace.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/kernel/time/namespace.c b/kernel/time/namespace.c index 6477c6d0e1a6..f4560b4931df 100644 --- a/kernel/time/namespace.c +++ b/kernel/time/namespace.c @@ -337,7 +337,20 @@ static struct user_namespace *timens_owner(struct ns_common *ns) static void show_offset(struct seq_file *m, int clockid, struct timespec64 *ts) { - seq_printf(m, "%d %lld %ld\n", clockid, ts->tv_sec, ts->tv_nsec); + char *clock; + + switch (clockid) { + case CLOCK_BOOTTIME: + clock = "boottime"; + break; + case CLOCK_MONOTONIC: + clock = "monotonic"; + break; + default: + clock = "unknown"; + break; + } + seq_printf(m, "%-10s %10lld %9ld\n", clock, ts->tv_sec, ts->tv_nsec); } void proc_timens_show_offsets(struct task_struct *p, struct seq_file *m) |