aboutsummaryrefslogtreecommitdiff
path: root/src/rc/fstabinfo.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-06-30 13:33:42 +0000
committerRoy Marples <roy@marples.name>2008-06-30 13:33:42 +0000
commit64dbae7f6109913dc9292b60fdc34a288bf8b7e5 (patch)
treed03af937af265d191934d1efd7224ddf2da801ce /src/rc/fstabinfo.c
parent11e4059b055c56fac0305bddd1f34476b832c832 (diff)
If filtering fstab, only match additional mounts asked for.
Diffstat (limited to 'src/rc/fstabinfo.c')
-rw-r--r--src/rc/fstabinfo.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/rc/fstabinfo.c b/src/rc/fstabinfo.c
index 0013c941..d1cd4323 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) {