Uncompressed checksum support.
* grub-core/commands/hashsum.c (options): Add option --uncompress. (check_list): New parameter uncompress. (grub_cmd_hashsum): Handle --uncompress.
This commit is contained in:
parent
9aadb3d146
commit
5124ae6d4f
2 changed files with 18 additions and 5 deletions
|
@ -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>
|
2010-09-05 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
Reintroduce testload.
|
Reintroduce testload.
|
||||||
|
|
|
@ -32,6 +32,7 @@ static const struct grub_arg_option options[] = {
|
||||||
{"prefix", 'p', 0, N_("Base directory for hash list."), N_("DIRECTORY"),
|
{"prefix", 'p', 0, N_("Base directory for hash list."), N_("DIRECTORY"),
|
||||||
ARG_TYPE_STRING},
|
ARG_TYPE_STRING},
|
||||||
{"keep-going", 'k', 0, N_("Don't stop after first error."), 0, 0},
|
{"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}
|
{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
|
static grub_err_t
|
||||||
check_list (const gcry_md_spec_t *hash, const char *hashfilename,
|
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;
|
grub_file_t hashlist, file;
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
|
@ -115,12 +116,14 @@ check_list (const gcry_md_spec_t *hash, const char *hashfilename,
|
||||||
filename = grub_xasprintf ("%s/%s", prefix, p);
|
filename = grub_xasprintf ("%s/%s", prefix, p);
|
||||||
if (!filename)
|
if (!filename)
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
|
if (!uncompress)
|
||||||
grub_file_filter_disable_compression ();
|
grub_file_filter_disable_compression ();
|
||||||
file = grub_file_open (filename);
|
file = grub_file_open (filename);
|
||||||
grub_free (filename);
|
grub_free (filename);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (!uncompress)
|
||||||
grub_file_filter_disable_compression ();
|
grub_file_filter_disable_compression ();
|
||||||
file = grub_file_open (p);
|
file = grub_file_open (p);
|
||||||
}
|
}
|
||||||
|
@ -178,6 +181,7 @@ grub_cmd_hashsum (struct grub_extcmd_context *ctxt,
|
||||||
const gcry_md_spec_t *hash;
|
const gcry_md_spec_t *hash;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
int keep = state[3].set;
|
int keep = state[3].set;
|
||||||
|
int uncompress = state[4].set;
|
||||||
unsigned unread = 0;
|
unsigned unread = 0;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE (aliases); i++)
|
for (i = 0; i < ARRAY_SIZE (aliases); i++)
|
||||||
|
@ -201,7 +205,7 @@ grub_cmd_hashsum (struct grub_extcmd_context *ctxt,
|
||||||
if (argc != 0)
|
if (argc != 0)
|
||||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||||
"--check is incompatible with file list");
|
"--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++)
|
for (i = 0; i < (unsigned) argc; i++)
|
||||||
|
@ -210,6 +214,7 @@ grub_cmd_hashsum (struct grub_extcmd_context *ctxt,
|
||||||
grub_file_t file;
|
grub_file_t file;
|
||||||
grub_err_t err;
|
grub_err_t err;
|
||||||
unsigned j;
|
unsigned j;
|
||||||
|
if (!uncompress)
|
||||||
grub_file_filter_disable_compression ();
|
grub_file_filter_disable_compression ();
|
||||||
file = grub_file_open (args[i]);
|
file = grub_file_open (args[i]);
|
||||||
if (!file)
|
if (!file)
|
||||||
|
|
Loading…
Reference in a new issue