From 64dbae7f6109913dc9292b60fdc34a288bf8b7e5 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Mon, 30 Jun 2008 13:33:42 +0000 Subject: If filtering fstab, only match additional mounts asked for. --- src/rc/fstabinfo.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/rc/fstabinfo.c b/src/rc/fstabinfo.c index 0013c94..d1cd432 100644 --- a/src/rc/fstabinfo.c +++ b/src/rc/fstabinfo.c @@ -163,7 +163,7 @@ int fstabinfo(int argc, char **argv) int opt; int output = OUTPUT_FILE; RC_STRINGLIST *files = rc_stringlist_new(); - RC_STRING *file; + RC_STRING *file, *file_np; bool filtered = false; #ifdef HAVE_GETMNTENT @@ -238,8 +238,18 @@ int fstabinfo(int argc, char **argv) } if (optind < argc) { - while (optind < argc) - rc_stringlist_add(files, argv[optind++]); + if (files) { + TAILQ_FOREACH_SAFE(file, files, entries, file_np) { + for (i = optind; i < argc; i++) + if (strcmp(argv[i], file->value) == 0) + break; + if (i >= argc) + rc_stringlist_delete(files, file->value); + } + } else { + while (optind < argc) + rc_stringlist_add(files, argv[optind++]); + } } else if (! filtered) { START_ENT; while ((ent = GET_ENT)) @@ -250,6 +260,11 @@ int fstabinfo(int argc, char **argv) eerrorx("%s: emtpy fstab", argv[0]); } + if (!files || !TAILQ_FIRST(files)) { + rc_stringlist_free(files); + return (EXIT_FAILURE); + } + /* Ensure we always display something */ START_ENT; TAILQ_FOREACH(file, files, entries) { -- cgit v1.2.3