diff options
Diffstat (limited to 'mincore.c')
-rw-r--r-- | mincore.c | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -1,5 +1,11 @@ #include "compat-util.h" +static int usage(const char * argv0) +{ + fprintf(stderr, "Usage: %s [-o offset] [-l length] FILE...\n", argv0); + return 1; +} + static void mincore_stats(const char *path, off_t offset, off_t len) { char *map; @@ -70,7 +76,7 @@ int main(int argc, char * const argv[]) int argi = 1; int opt; - while ((opt = getopt(argc, argv, "o:l:")) != -1) { + while ((opt = getopt(argc, argv, "o:l:h")) != -1) { char *err; argi += 2; @@ -90,13 +96,13 @@ int main(int argc, char * const argv[]) } break; default: - fprintf(stderr, - "Usage: %s [-o offset] " - "[-l length] <files>\n", argv[0]); - return 1; + return usage(argv[0]); } } + if (argi >= argc) + return usage(argv[0]); + for (; argi < argc; ++argi) mincore_stats(argv[argi], offset, len); return 0; |