Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 252053
b: refs/heads/master
c: 57cc083
h: refs/heads/master
i:
  252051: 0172e5c
v: v3
  • Loading branch information
Jiri Slaby authored and Linus Torvalds committed May 27, 2011
1 parent a6fb09a commit f6f950f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3864601387cf4196371e3c1897fdffa5228296f9
refs/heads/master: 57cc083ad9e1bfeeb4a0ee831e7bb008c8865bf0
3 changes: 2 additions & 1 deletion trunk/Documentation/sysctl/kernel.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ core_pattern is used to specify a core dumpfile pattern name.
%s signal number
%t UNIX time of dump
%h hostname
%e executable filename
%e executable filename (may be shortened)
%E executable path
%<OTHER> both are dropped
. If the first character of the pattern is a '|', the kernel will treat
the rest of the pattern as a command to run. The core dump will be
Expand Down
38 changes: 38 additions & 0 deletions trunk/fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1623,6 +1623,41 @@ static int cn_printf(struct core_name *cn, const char *fmt, ...)
return ret;
}

static int cn_print_exe_file(struct core_name *cn)
{
struct file *exe_file;
char *pathbuf, *path, *p;
int ret;

exe_file = get_mm_exe_file(current->mm);
if (!exe_file)
return cn_printf(cn, "(unknown)");

pathbuf = kmalloc(PATH_MAX, GFP_TEMPORARY);
if (!pathbuf) {
ret = -ENOMEM;
goto put_exe_file;
}

path = d_path(&exe_file->f_path, pathbuf, PATH_MAX);
if (IS_ERR(path)) {
ret = PTR_ERR(path);
goto free_buf;
}

for (p = path; *p; p++)
if (*p == '/')
*p = '!';

ret = cn_printf(cn, "%s", path);

free_buf:
kfree(pathbuf);
put_exe_file:
fput(exe_file);
return ret;
}

/* format_corename will inspect the pattern parameter, and output a
* name into corename, which must have space for at least
* CORENAME_MAX_SIZE bytes plus one byte for the zero terminator.
Expand Down Expand Up @@ -1694,6 +1729,9 @@ static int format_corename(struct core_name *cn, long signr)
case 'e':
err = cn_printf(cn, "%s", current->comm);
break;
case 'E':
err = cn_print_exe_file(cn);
break;
/* core limit size */
case 'c':
err = cn_printf(cn, "%lu",
Expand Down

0 comments on commit f6f950f

Please sign in to comment.