From 10026118a2497703b5433eff1494ab1fa3409723 Mon Sep 17 00:00:00 2001 From: Laurent Vivier Date: Sun, 6 May 2007 23:03:55 +0000 Subject: [PATCH] hide map files --- tools/emile.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/tools/emile.c b/tools/emile.c index 555c63d..d55dc97 100644 --- a/tools/emile.c +++ b/tools/emile.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "libemile.h" @@ -664,29 +665,41 @@ int main(int argc, char **argv) printf("Bootblock backup successfully done.\n"); } - if (!emile_is_url(kernel_path)) + if (kernel_path && !emile_is_url(kernel_path)) { - kernel_map_path = (char*)malloc(strlen(kernel_path) + 5); + char *a = strdup(kernel_path); + char *b = strdup(kernel_path); + char *base = basename(a); + char *dir = dirname(b); + kernel_map_path = (char*)malloc(strlen(kernel_path) + 6); if (kernel_map_path == NULL) { fprintf(stderr, "ERROR: cannot allocate memory\n"); return 15; } - sprintf(kernel_map_path, "%s.map", kernel_path); + sprintf(kernel_map_path, "%s/.%s.map", dir, base); + free(a); + free(b); } else kernel_map_path = kernel_path; - if (!emile_is_url(initrd_path)) + if (initrd_path && !emile_is_url(initrd_path)) { - initrd_map_path = (char*)malloc(strlen(initrd_path) + 5); + char *a = strdup(initrd_path); + char *b = strdup(initrd_path); + char *base = basename(a); + char *dir = dirname(b); + initrd_map_path = (char*)malloc(strlen(initrd_path) + 6); if (initrd_map_path == NULL) { fprintf(stderr, "ERROR: cannot allocate memory\n"); return 15; } - sprintf(initrd_map_path, "%s.map", initrd_path); + sprintf(initrd_map_path, "%s/.%s.map", dir, base); + free(a); + free(b); } else initrd_map_path = initrd_path;