Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid
[linux-2.6-microblaze.git] / fs / coredump.c
index 7237f07..76e7c10 100644 (file)
@@ -153,10 +153,10 @@ int cn_esc_printf(struct core_name *cn, const char *fmt, ...)
        return ret;
 }
 
-static int cn_print_exe_file(struct core_name *cn)
+static int cn_print_exe_file(struct core_name *cn, bool name_only)
 {
        struct file *exe_file;
-       char *pathbuf, *path;
+       char *pathbuf, *path, *ptr;
        int ret;
 
        exe_file = get_mm_exe_file(current->mm);
@@ -175,6 +175,11 @@ static int cn_print_exe_file(struct core_name *cn)
                goto free_buf;
        }
 
+       if (name_only) {
+               ptr = strrchr(path, '/');
+               if (ptr)
+                       path = ptr + 1;
+       }
        ret = cn_esc_printf(cn, "%s", path);
 
 free_buf:
@@ -301,12 +306,16 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm,
                                              utsname()->nodename);
                                up_read(&uts_sem);
                                break;
-                       /* executable */
+                       /* executable, could be changed by prctl PR_SET_NAME etc */
                        case 'e':
                                err = cn_esc_printf(cn, "%s", current->comm);
                                break;
+                       /* file name of executable */
+                       case 'f':
+                               err = cn_print_exe_file(cn, true);
+                               break;
                        case 'E':
-                               err = cn_print_exe_file(cn);
+                               err = cn_print_exe_file(cn, false);
                                break;
                        /* core limit size */
                        case 'c':