]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Uncompressed checksum support.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 5 Sep 2010 14:48:54 +0000 (16:48 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 5 Sep 2010 14:48:54 +0000 (16:48 +0200)
* grub-core/commands/hashsum.c (options): Add option --uncompress.
(check_list): New parameter uncompress.
(grub_cmd_hashsum): Handle --uncompress.

ChangeLog
grub-core/commands/hashsum.c

index 2f4dd8f15d7a2a0c1a8d29389aa04ded24e42dee..682787021824b5e58e7b1edc89e2364248535aac 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-09-05  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       Uncompressed checksum support.
+
+       * grub-core/commands/hashsum.c (options): Add option --uncompress.
+       (check_list): New parameter uncompress.
+       (grub_cmd_hashsum): Handle --uncompress.
+
 2010-09-05  Vladimir Serbinenko  <phcoder@gmail.com>
 
        Reintroduce testload.
index 54f487cc7ffa84339fe2c12ff7152f462a562755..6f65b4ab3d3f38569c2ad0d8f207d1ae9d938ddb 100644 (file)
@@ -32,6 +32,7 @@ static const struct grub_arg_option options[] = {
   {"prefix", 'p', 0, N_("Base directory for hash list."), N_("DIRECTORY"),
    ARG_TYPE_STRING},
   {"keep-going", 'k', 0, N_("Don't stop after first error."), 0, 0},
+  {"uncompress", 'u', 0, N_("Uncompress file before checksumming."), 0, 0},
   {0, 0, 0, 0, 0, 0}
 };
 
@@ -80,7 +81,7 @@ hash_file (grub_file_t file, const gcry_md_spec_t *hash, void *result)
 
 static grub_err_t
 check_list (const gcry_md_spec_t *hash, const char *hashfilename,
-           const char *prefix, int keep)
+           const char *prefix, int keep, int uncompress)
 {
   grub_file_t hashlist, file;
   char *buf = NULL;
@@ -115,13 +116,15 @@ check_list (const gcry_md_spec_t *hash, const char *hashfilename,
          filename = grub_xasprintf ("%s/%s", prefix, p);
          if (!filename)
            return grub_errno;
-         grub_file_filter_disable_compression ();
+         if (!uncompress)
+           grub_file_filter_disable_compression ();
          file = grub_file_open (filename);
          grub_free (filename);
        }
       else
        {
-         grub_file_filter_disable_compression ();
+         if (!uncompress)
+           grub_file_filter_disable_compression ();
          file = grub_file_open (p);
        }
       if (!file)
@@ -178,6 +181,7 @@ grub_cmd_hashsum (struct grub_extcmd_context *ctxt,
   const gcry_md_spec_t *hash;
   unsigned i;
   int keep = state[3].set;
+  int uncompress = state[4].set;
   unsigned unread = 0;
 
   for (i = 0; i < ARRAY_SIZE (aliases); i++)
@@ -201,7 +205,7 @@ grub_cmd_hashsum (struct grub_extcmd_context *ctxt,
       if (argc != 0)
        return grub_error (GRUB_ERR_BAD_ARGUMENT,
                           "--check is incompatible with file list");
-      return check_list (hash, state[1].arg, prefix, keep);
+      return check_list (hash, state[1].arg, prefix, keep, uncompress);
     }
 
   for (i = 0; i < (unsigned) argc; i++)
@@ -210,7 +214,8 @@ grub_cmd_hashsum (struct grub_extcmd_context *ctxt,
       grub_file_t file;
       grub_err_t err;
       unsigned j;
-      grub_file_filter_disable_compression ();
+      if (!uncompress)
+       grub_file_filter_disable_compression ();
       file = grub_file_open (args[i]);
       if (!file)
        {