grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: Andrei Borzenkov <arvidjaar@gmail.com>
To: grub-devel@gnu.org
Subject: Re: [PATCH] grub-mkrescue: remove temporary load_cfg file
Date: Mon, 22 Sep 2014 22:32:07 +0400	[thread overview]
Message-ID: <20140922223207.49730bcc@opensuse.site> (raw)
In-Reply-To: <541F061D.9090409@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2847 bytes --]

В Sun, 21 Sep 2014 19:08:45 +0200
Vladimir 'φ-coder/phcoder' Serbinenko <phcoder@gmail.com> пишет:

> 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.

diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c
index e719839..4121f61 100644
--- a/util/grub-mkrescue.c
+++ b/util/grub-mkrescue.c
@@ -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 */

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

      reply	other threads:[~2014-09-22 18:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-01 16:16 [PATCH] grub-mkrescue: remove temporary load_cfg file Andrey Borzenkov
2014-09-21 17:08 ` Vladimir 'φ-coder/phcoder' Serbinenko
2014-09-22 18:32   ` Andrei Borzenkov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140922223207.49730bcc@opensuse.site \
    --to=arvidjaar@gmail.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).