All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] loopback: Support transparent decompression of backing file
@ 2022-08-26  4:08 Glenn Washburn
  2022-09-29 15:58 ` Daniel Kiper
  0 siblings, 1 reply; 2+ messages in thread
From: Glenn Washburn @ 2022-08-26  4:08 UTC (permalink / raw)
  To: grub-devel, Daniel Kiper; +Cc: Glenn Washburn, Li Gen

A new option is added to the loopback command, -D or --decompress, which
when specified transparently decompresses the backing file. This allows
compressed images to be used as if they were uncompressed.

Add documentation to support this change.

Suggested-by: Li Gen <ligenlive@gmail.com>
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
 docs/grub.texi            |  5 ++++-
 grub-core/disk/loopback.c | 10 +++++++---
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/docs/grub.texi b/docs/grub.texi
index 9ce3a1b488..a463f9e354 100644
--- a/docs/grub.texi
+++ b/docs/grub.texi
@@ -4938,7 +4938,7 @@ suffix @samp{.pf2} appended. @xref{Theme file format,,Fonts}.
 @node loopback
 @subsection loopback
 
-@deffn Command loopback [@option{-d}] device file
+@deffn Command loopback [@option{-d}] [@option{-D}] device file
 Make the device named @var{device} correspond to the contents of the
 filesystem image in @var{file}.  For example:
 
@@ -4947,6 +4947,9 @@ loopback loop0 /path/to/image
 ls (loop0)/
 @end example
 
+Specifying the @option{-D} option allows the loopback file to be tranparently
+decompressed if there is an appropriate decompressor loaded.
+
 With the @option{-d} option, delete a device previously created using this
 command.
 @end deffn
diff --git a/grub-core/disk/loopback.c b/grub-core/disk/loopback.c
index 41bebd14fe..2cfc53a916 100644
--- a/grub-core/disk/loopback.c
+++ b/grub-core/disk/loopback.c
@@ -43,6 +43,7 @@ static const struct grub_arg_option options[] =
     /* TRANSLATORS: The disk is simply removed from the list of available ones,
        not wiped, avoid to scare user.  */
     {"delete", 'd', 0, N_("Delete the specified loopback drive."), 0, 0},
+    {"decompress", 'D', 0, N_("Transparently decompress backing file."), 0, 0},
     {0, 0, 0, 0, 0, 0}
   };
 
@@ -79,6 +80,7 @@ grub_cmd_loopback (grub_extcmd_context_t ctxt, int argc, char **args)
 {
   struct grub_arg_list *state = ctxt->state;
   grub_file_t file;
+  enum grub_file_type type = GRUB_FILE_TYPE_LOOPBACK;
   struct grub_loopback *newdev;
   grub_err_t ret;
 
@@ -89,6 +91,9 @@ grub_cmd_loopback (grub_extcmd_context_t ctxt, int argc, char **args)
   if (state[0].set)
       return delete_loopback (args[0]);
 
+  if (!state[1].set)
+    type |= GRUB_FILE_TYPE_NO_DECOMPRESS;
+
   if (argc < 2)
     return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
 
@@ -97,8 +102,7 @@ grub_cmd_loopback (grub_extcmd_context_t ctxt, int argc, char **args)
     if (grub_strcmp (newdev->devname, args[0]) == 0)
       return grub_error (GRUB_ERR_BAD_ARGUMENT, "device name already exists");
 
-  file = grub_file_open (args[1], GRUB_FILE_TYPE_LOOPBACK
-			 | GRUB_FILE_TYPE_NO_DECOMPRESS);
+  file = grub_file_open (args[1], type);
   if (! file)
     return grub_errno;
 
@@ -226,7 +230,7 @@ static grub_extcmd_t cmd;
 GRUB_MOD_INIT(loopback)
 {
   cmd = grub_register_extcmd ("loopback", grub_cmd_loopback, 0,
-			      N_("[-d] DEVICENAME FILE."),
+			      N_("[-d] [-D] DEVICENAME FILE."),
 			      /* TRANSLATORS: The file itself is not destroyed
 				 or transformed into drive.  */
 			      N_("Make a virtual drive from a file."), options);
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] loopback: Support transparent decompression of backing file
  2022-08-26  4:08 [PATCH] loopback: Support transparent decompression of backing file Glenn Washburn
@ 2022-09-29 15:58 ` Daniel Kiper
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Kiper @ 2022-09-29 15:58 UTC (permalink / raw)
  To: Glenn Washburn; +Cc: grub-devel, Li Gen

On Thu, Aug 25, 2022 at 11:08:57PM -0500, Glenn Washburn wrote:
> A new option is added to the loopback command, -D or --decompress, which
> when specified transparently decompresses the backing file. This allows
> compressed images to be used as if they were uncompressed.
>
> Add documentation to support this change.
>
> Suggested-by: Li Gen <ligenlive@gmail.com>
> Signed-off-by: Glenn Washburn <development@efficientek.com>

Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

Daniel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-29 15:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-26  4:08 [PATCH] loopback: Support transparent decompression of backing file Glenn Washburn
2022-09-29 15:58 ` Daniel Kiper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.