coredump: add new %P variable in core_pattern
authorStéphane Graber <stgraber@ubuntu.com>
Wed, 11 Sep 2013 21:24:32 +0000 (14:24 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 11 Sep 2013 22:59:01 +0000 (15:59 -0700)
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>
Documentation/sysctl/kernel.txt
fs/coredump.c

index ab7d16efa96bf78bbfdddc029eb40b82da1e03fe..9d4c1d18ad447e0db3dbbbc9776a29e4c93450c0 100644 (file)
@@ -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
index 72f816d6cad99d4d1f81433e928d42e540295188..9bdeca12ae0e388ecda010964c5209313cb363a9 100644 (file)
@@ -190,6 +190,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);
This page took 0.026735 seconds and 5 git commands to generate.