From facf34bd2ffc16eb2a5e770d9be3d8010b4add42 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sat, 29 Apr 2017 18:08:07 -0400 Subject: Don't parse the mount table until it's needed --- parse.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'parse.c') diff --git a/parse.c b/parse.c index dde22bd..6be2e97 100644 --- a/parse.c +++ b/parse.c @@ -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, -- cgit v1.2.3