summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStéphane Graber <stgraber@ubuntu.com>2013-09-11 14:24:32 -0700
committerLee Campbell <leecam@google.com>2015-10-12 13:26:11 -0700
commitbe333f960142233ce87d6794753ddab552357dec (patch)
tree6e3dc0e1c11338eba42f861d1f94904028b7cc8b
parentff16b6254f760ec940d069874265cd83474ad41a (diff)
downloadintel-be333f960142233ce87d6794753ddab552357dec.tar.gz
coredump: add new %P variable in core_pattern
Add a new %P variable to be used in core_pattern. This variable contains the global PID (PID in the init namespace) as %p contains the PID in the current namespace which isn't always what we want. The main use for this is to make it easier to handle crashes that happened within a container. With that new variables it's possible to have the crashes dumped into the container or forwarded to the host with the right PID (from the host's point of view). Signed-off-by: Stéphane Graber <stgraber@ubuntu.com> Reported-by: Hans Feldt <hans.feldt@ericsson.com> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Eric W. Biederman <ebiederm@xmission.com> Cc: Andy Whitcroft <apw@canonical.com> Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> (cherry picked from commit 240ba92d4a528d7bc3fd08ad52081e108382809c) Change-Id: I7b2530f271ed9c96b67cdb77777f8ad64f856a88
-rw-r--r--Documentation/sysctl/kernel.txt1
-rw-r--r--fs/coredump.c5
2 files changed, 6 insertions, 0 deletions
diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt
index 8d90c42e5db..9b9d019885a 100644
--- a/Documentation/sysctl/kernel.txt
+++ b/Documentation/sysctl/kernel.txt
@@ -182,6 +182,7 @@ core_pattern is used to specify a core dumpfile pattern name.
%<NUL> '%' is dropped
%% output one '%'
%p pid
+ %P global pid (init PID namespace)
%u uid
%g gid
%d dump mode, matches PR_SET_DUMPABLE and
diff --git a/fs/coredump.c b/fs/coredump.c
index 1d402ce5b72..c9625799580 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -186,6 +186,11 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
err = cn_printf(cn, "%d",
task_tgid_vnr(current));
break;
+ /* global pid */
+ case 'P':
+ err = cn_printf(cn, "%d",
+ task_tgid_nr(current));
+ break;
/* uid */
case 'u':
err = cn_printf(cn, "%d", cred->uid);