Skip to contentSkip to conversation

coredump: Add new %P variable in core_pattern

PATCH Superseded Stéphane Graber 2 participants 2 messages Apr 24, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 coredump: Add new %P variable in core_pattern

This adds 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).

Cc Alexander Viro <[email protected]>
Cc Eric W. Biederman <[email protected]>
Cc Serge Hallyn <[email protected]>
---
 Documentation/sysctl/kernel.txt | 1 +
 fs/coredump.c                   | 5 +++++
 2 files changed, 6 insertions(+)
Documentation/sysctl/kernel.txt +1 -0
index ccd4258..833026d 100644
@@ -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
fs/coredump.c +5 -0
index c647965..528c6fc 100644
@@ -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);
Signature · 1 line
1.8.1.2
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Stéphane Graber

This adds 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).

Quoted 4 lines
Cc Alexander Viro <[email protected]>
Cc Eric W. Biederman <[email protected]>
Cc Serge Hallyn <[email protected]>

Thanks, Stéphane.

Quoted 37 lines
---
 Documentation/sysctl/kernel.txt | 1 +
 fs/coredump.c                   | 5 +++++
 2 files changed, 6 insertions(+)
Documentation/sysctl/kernel.txt +1 -0
index ccd4258..833026d 100644
@@ -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
fs/coredump.c +5 -0
index c647965..528c6fc 100644
@@ -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);
Signature · 1 line
1.8.1.2