From a9ae3955fef76b76f4acccff1dc0e985538e7c61 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 9 Jun 2011 22:43:51 +0200 Subject: [PATCH] libmount: minor changes in sample program Signed-off-by: Karel Zak --- libmount/samples/mount.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/libmount/samples/mount.c b/libmount/samples/mount.c index 086391e90c..21a7edbf81 100644 --- a/libmount/samples/mount.c +++ b/libmount/samples/mount.c @@ -144,6 +144,12 @@ done: return rc; } +static int mount_all(struct libmnt_context *cxt) +{ + warnx(_("mount -a is not implemented yet")); + return EXIT_FAILURE; +} + static void __attribute__((__noreturn__)) usage(FILE *out) { fprintf(out, _("Usage:\n" @@ -261,7 +267,6 @@ int main(int argc, char **argv) switch(c) { case 'a': all = 1; - err(EX_FAIL, "-a not implemented yet"); /* TODO */ break; case 'c': mnt_context_disable_canonicalize(cxt, TRUE); @@ -379,13 +384,25 @@ int main(int argc, char **argv) else if (types) mnt_context_set_fstype(cxt, types); - if (argc == 0 && source) { - /* mount -L|-U */ + if (all) { + /* + * A) Mount all + */ + rc = mount_all(cxt); + mnt_free_context(cxt); + return rc; + + } else if (argc == 0 && source) { + /* + * B) mount -L|-U + */ mnt_context_set_source(cxt, source); } else if (argc == 1) { - /* mount [-L|-U] - * mount */ + /* + * C) mount [-L|-U] + * mount + */ if (source) { if (mnt_context_is_restricted(cxt)) exit_non_root(NULL); @@ -394,7 +411,9 @@ int main(int argc, char **argv) mnt_context_set_target(cxt, argv[0]); } else if (argc == 2 && !source) { - /* mount */ + /* + * D) mount + */ if (mnt_context_is_restricted(cxt)) exit_non_root(NULL); mnt_context_set_source(cxt, argv[0]); -- 2.47.2