From 6db768f0461de00bd2209941e5b94bb98dda1139 Mon Sep 17 00:00:00 2001 From: Juergen Beisert Date: Wed, 22 Dec 2010 14:48:07 +0100 Subject: Change 'linux16' command to use getopt() Signed-off-by: Juergen Beisert --- commands/linux16.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'commands/linux16.c') diff --git a/commands/linux16.c b/commands/linux16.c index 5f412e29d3..87245d4d2c 100644 --- a/commands/linux16.c +++ b/commands/linux16.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -153,18 +154,25 @@ struct linux_kernel_header { static int do_linux16(struct command *cmdtp, int argc, char *argv[]) { struct linux_kernel_header *lh = NULL; - int rc; + int rc, opt; unsigned setup_sects; unsigned real_mode_size; size_t image_size; const char *cmdline = getenv("bootargs"); + const char *kernel_file; - if (argc < 2) { - perror("linux16"); + while((opt = getopt(argc, argv, "")) > 0) { + switch(opt) { + } + } + + if (optind == argc) { + printf("No kernel filename given\n"); return 1; } + kernel_file = argv[optind]; - lh = read_file(argv[1], &image_size); + lh = read_file(kernel_file, &image_size); if (lh == NULL) { printf("Cannot read file '%s'\n", argv[1]); return 1; -- cgit v1.2.3