diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2017-04-29 18:08:07 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2017-04-29 18:08:07 -0400 |
commit | facf34bd2ffc16eb2a5e770d9be3d8010b4add42 (patch) | |
tree | edabd39358d60e55489c0195a461323937431cba /parse.c | |
parent | 068205d5e5186ab3fb0403d129572bc90a65bd23 (diff) | |
download | bfs-facf34bd2ffc16eb2a5e770d9be3d8010b4add42.tar.xz |
Don't parse the mount table until it's needed
Diffstat (limited to 'parse.c')
-rw-r--r-- | parse.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -1057,9 +1057,13 @@ fail: * Parse -fstype TYPE. */ static struct expr *parse_fstype(struct parser_state *state, int arg1, int arg2) { - if (!state->cmdline->mtab) { - cfprintf(state->cmdline->cerr, "%{er}error: %s: Couldn't parse the mount table.%{rs}\n", state->argv[0]); - return NULL; + struct cmdline *cmdline = state->cmdline; + if (!cmdline->mtab) { + cmdline->mtab = parse_bfs_mtab(); + if (!cmdline->mtab) { + cfprintf(cmdline->cerr, "%{er}error: Couldn't parse the mount table: %s.%{rs}\n\n", strerror(errno)); + return NULL; + } } return parse_unary_test(state, eval_fstype); @@ -2840,11 +2844,6 @@ struct cmdline *parse_cmdline(int argc, char *argv[]) { goto fail; } - cmdline->mtab = parse_bfs_mtab(); - if (!cmdline->mtab) { - cfprintf(cmdline->cerr, "%{wr}warning: Couldn't parse the mount table: %s.%{rs}\n\n", strerror(errno)); - } - struct parser_state state = { .cmdline = cmdline, .argv = argv + 1, |