Skip to contentSkip to conversation

grub-mkrescue: remove temporary load_cfg file

PATCH In review Andrey Borzenkov 2 participants 3 messages May 1, 2014 – Sep 22, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 grub-mkrescue: remove temporary load_cfg file

---
 util/grub-mkrescue.c | 2 ++
 1 file changed, 2 insertions(+)
util/grub-mkrescue.c +2 -0
index e719839..c3d9b32 100644
@@ -323,6 +323,7 @@ make_image_fwdisk_abs (enum grub_install_plat plat,
   grub_install_make_image_wrap (source_dirs[plat], "()/boot/grub", output,
 				0, load_cfg, mkimage_target, 0);
   grub_install_pop_module ();
+  grub_util_unlink (load_cfg);
 }
 
 static int
@@ -566,6 +567,7 @@ main (int argc, char *argv[])
 	}
       grub_install_pop_module ();
       grub_install_pop_module ();
+      grub_util_unlink (load_cfg);
     }
 
   /** build multiboot core.img */
Signature · 1 line
tg: (4b8b913..) u/load_cfg (depends on: master)
#1 lore raw

I actually like to have load.cfg around: it helps with debugging in some cases. Do you have a reason to remove it?

Quoted 25 lines · Andrey Borzenkov
---
 util/grub-mkrescue.c | 2 ++
 1 file changed, 2 insertions(+)
util/grub-mkrescue.c +2 -0
index e719839..c3d9b32 100644
@@ -323,6 +323,7 @@ make_image_fwdisk_abs (enum grub_install_plat plat,
   grub_install_make_image_wrap (source_dirs[plat], "()/boot/grub", output,
 				0, load_cfg, mkimage_target, 0);
   grub_install_pop_module ();
+  grub_util_unlink (load_cfg);
 }
 
 static int
@@ -566,6 +567,7 @@ main (int argc, char *argv[])
 	}
       grub_install_pop_module ();
       grub_install_pop_module ();
+      grub_util_unlink (load_cfg);
     }
 
   /** build multiboot core.img */
#2 lore raw

В Sun, 21 Sep 2014 19:08:45 +0200
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:

Quoted 2 lines

I actually like to have load.cfg around: it helps with debugging in some cases. Do you have a reason to remove it?

On general principles that program has to cleanup after itself unless asked otherwise. load_cfg was already removed in one code path there so I considered it a cleanup. Also I have dozens of temporary files with cryptic names created by grub in /tmp, I'd have hard time matching them.

What about patch below? It saves load.cfg in target directory on image. This matches what grub-install does and lets you see load.cfg even if image is copied elsewhere.

util/grub-mkrescue.c +10 -4
index e719839..4121f61 100644
@@ -270,7 +270,9 @@ make_image_abs (enum grub_install_plat plat,
   grub_util_info (N_("enabling %s support ..."),
 		  mkimage_target);
 
-  load_cfg = grub_util_make_temporary_file ();
+  load_cfg = grub_util_path_concat (3, boot_grub,
+				    grub_install_get_platform_name (plat),
+				    "load.cfg");
 
   load_cfg_f = grub_util_fopen (load_cfg, "wb");
   fprintf (load_cfg_f, "search --fs-uuid --set=root %s\n", iso_uuid);
@@ -286,7 +288,7 @@ make_image_abs (enum grub_install_plat plat,
 				mkimage_target, 0);
   grub_install_pop_module ();
   grub_install_pop_module ();
-  grub_util_unlink (load_cfg);
+  free (load_cfg);
 }
 
 static void
@@ -313,7 +315,9 @@ make_image_fwdisk_abs (enum grub_install_plat plat,
   grub_util_info (N_("enabling %s support ..."),
 		  mkimage_target);
 
-  load_cfg = grub_util_make_temporary_file ();
+  load_cfg = grub_util_path_concat (3, boot_grub,
+				    grub_install_get_platform_name (plat),
+				    "load.cfg");
 
   load_cfg_f = grub_util_fopen (load_cfg, "wb");
   write_part (load_cfg_f, source_dirs[plat]);
@@ -323,6 +327,7 @@ make_image_fwdisk_abs (enum grub_install_plat plat,
   grub_install_make_image_wrap (source_dirs[plat], "()/boot/grub", output,
 				0, load_cfg, mkimage_target, 0);
   grub_install_pop_module ();
+  free (load_cfg);
 }
 
 static int
@@ -491,7 +496,7 @@ main (int argc, char *argv[])
       char *load_cfg;
       FILE *load_cfg_f;
       char *output = grub_util_path_concat (3, boot_grub, "i386-pc", "eltorito.img");
-      load_cfg = grub_util_make_temporary_file ();
+      load_cfg = grub_util_path_concat (3, boot_grub, "i386-pc", "load.cfg");
 
       grub_util_info (N_("enabling %s support ..."), "BIOS");
       load_cfg_f = grub_util_fopen (load_cfg, "wb");
@@ -566,6 +571,7 @@ main (int argc, char *argv[])
 	}
       grub_install_pop_module ();
       grub_install_pop_module ();
+      free (load_cfg);
     }
 
   /** build multiboot core.img */