* util/grub-fstest.c (cmd_cat): New function.
(fstest): Handle CMD_CAT. (options): Add cat. (argp_parser): Handle cat.
This commit is contained in:
parent
24c9143ae3
commit
3ca2b46645
2 changed files with 45 additions and 6 deletions
|
@ -1,3 +1,10 @@
|
|||
2011-05-17 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* util/grub-fstest.c (cmd_cat): New function.
|
||||
(fstest): Handle CMD_CAT.
|
||||
(options): Add cat.
|
||||
(argp_parser): Handle cat.
|
||||
|
||||
2011-05-17 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* Makefile.util.def (grub-bin2h): Don't install.
|
||||
|
|
|
@ -54,12 +54,15 @@ execute_command (char *name, int n, char **args)
|
|||
return (cmd->func) (cmd, n, args);
|
||||
}
|
||||
|
||||
#define CMD_LS 1
|
||||
#define CMD_CP 2
|
||||
#define CMD_CMP 3
|
||||
#define CMD_HEX 4
|
||||
#define CMD_CRC 6
|
||||
#define CMD_BLOCKLIST 7
|
||||
enum {
|
||||
CMD_LS = 1,
|
||||
CMD_CP,
|
||||
CMD_CAT,
|
||||
CMD_CMP,
|
||||
CMD_HEX,
|
||||
CMD_CRC,
|
||||
CMD_BLOCKLIST
|
||||
};
|
||||
|
||||
#define BUF_SIZE 32256
|
||||
|
||||
|
@ -182,6 +185,26 @@ cmd_cp (char *src, char *dest)
|
|||
fclose (ff);
|
||||
}
|
||||
|
||||
static void
|
||||
cmd_cat (char *src)
|
||||
{
|
||||
auto int cat_hook (grub_off_t ofs, char *buf, int len);
|
||||
int cat_hook (grub_off_t ofs, char *buf, int len)
|
||||
{
|
||||
(void) ofs;
|
||||
|
||||
if ((int) fwrite (buf, 1, len, stdout) != len)
|
||||
{
|
||||
grub_util_error (_("write error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
read_file (src, cat_hook);
|
||||
}
|
||||
|
||||
static void
|
||||
cmd_cmp (char *src, char *dest)
|
||||
{
|
||||
|
@ -321,6 +344,9 @@ fstest (int n, char **args)
|
|||
case CMD_CP:
|
||||
cmd_cp (args[0], args[1]);
|
||||
break;
|
||||
case CMD_CAT:
|
||||
cmd_cat (args[0]);
|
||||
break;
|
||||
case CMD_CMP:
|
||||
cmd_cmp (args[0], args[1]);
|
||||
break;
|
||||
|
@ -356,6 +382,7 @@ static struct argp_option options[] = {
|
|||
{0, 0, 0 , OPTION_DOC, N_("Commands:"), 1},
|
||||
{N_("ls PATH"), 0, 0 , OPTION_DOC, N_("List files in PATH."), 1},
|
||||
{N_("cp FILE LOCAL"), 0, 0, OPTION_DOC, N_("Copy FILE to local file LOCAL."), 1},
|
||||
{N_("cat FILE"), 0, 0 , OPTION_DOC, N_("Copy FILE to standard output."), 1},
|
||||
{N_("cmp FILE LOCAL"), 0, 0, OPTION_DOC, N_("Compare FILE with local file LOCAL."), 1},
|
||||
{N_("hex FILE"), 0, 0 , OPTION_DOC, N_("Hex dump FILE."), 1},
|
||||
{N_("crc FILE"), 0, 0 , OPTION_DOC, N_("Get crc32 checksum of FILE."), 1},
|
||||
|
@ -468,6 +495,11 @@ argp_parser (int key, char *arg, struct argp_state *state)
|
|||
cmd = CMD_CP;
|
||||
nparm = 2;
|
||||
}
|
||||
else if (!grub_strcmp (arg, "cat"))
|
||||
{
|
||||
cmd = CMD_CAT;
|
||||
nparm = 1;
|
||||
}
|
||||
else if (!grub_strcmp (arg, "cmp"))
|
||||
{
|
||||
cmd = CMD_CMP;
|
||||
|
|
Loading…
Reference in a new issue