author | Olivier Brunel
<jjk@jjacky.com> 2015-02-21 13:47:02 UTC |
committer | Olivier Brunel
<jjk@jjacky.com> 2015-04-04 12:47:34 UTC |
parent | e52e63df7d3aa2b6480e2ddb2c2622eb8e62d23a |
doc/aa-umount.pod | +37 | -0 |
package/modes | +1 | -0 |
package/targets.mak | +5 | -3 |
src/utils/aa-umount.c | +72 | -0 |
src/utils/deps-exe/aa-umount | +2 | -0 |
diff --git a/doc/aa-umount.pod b/doc/aa-umount.pod new file mode 100644 index 0000000..846ef71 --- /dev/null +++ b/doc/aa-umount.pod @@ -0,0 +1,37 @@ +=head1 NAME + +aa-umount - Unmount a filesystem + +=head1 SYNOPSIS + +B<aa-umount> [B<-f> | B<-l>] I<MOUNTPOINT> + +=head1 OPTIONS + +=over + +=item B<-f, --force> + +Force unmount even if busy (only for NFS moutns). This can cause data loss. + +=item B<-h, --help> + +Show help screen and exit. + +=item B<-l, --lazy> + +Perform a lazy unmount: make the mount point unavailable for new accesses, and +actually perform the unmount when the mount point ceases to be busy. + +=item B<-V, --version> + +Show version information and exit. + +=back + +=head1 DESCRIPTION + +B<aa-umount>(1) unmounts the specified mount point. It isn't possible to unmount +a filesystem if it is busy, e.g. there are still open files. This could even be +caused by B<aa-umount>(1) itself; It is possible to avoid this using the +B<--lazy> option. diff --git a/package/modes b/package/modes index da1e761..a126d1b 100644 --- a/package/modes +++ b/package/modes @@ -6,3 +6,4 @@ aa-mount 0755 aa-pivot 0755 aa-start 0755 aa-stop 0755 +aa-umount 0755 diff --git a/package/targets.mak b/package/targets.mak index 31a2df9..06f758e 100644 --- a/package/targets.mak +++ b/package/targets.mak @@ -8,18 +8,20 @@ aa-chroot \ aa-echo \ aa-kill \ aa-mount \ -aa-pivot +aa-pivot \ +aa-umount DOC_TARGETS := \ anopa.1 \ aa-chroot.1 \ aa-echo.1 \ aa-enable.1 \ +aa-kill.1 \ +aa-mount.1 \ aa-pivot.1 \ aa-start.1 \ aa-stop.1 \ -aa-kill.1 \ -aa-mount.1 +aa-umount.1 ifdef DO_ALLSTATIC LIBANOPA := libanopa.a diff --git a/src/utils/aa-umount.c b/src/utils/aa-umount.c new file mode 100644 index 0000000..9e9fd27 --- /dev/null +++ b/src/utils/aa-umount.c @@ -0,0 +1,72 @@ + +#include <getopt.h> +#include <sys/mount.h> +#include <skalibs/strerr2.h> +#include <anopa/common.h> + +#ifndef NULL +#define NULL (void *) 0 +#endif + +static void +dieusage (int rc) +{ + aa_die_usage (rc, "[OPTIONS...] MOUNTPOINT", + " -f, --force Force unmount even if busy (NFS only)\n" + " -l, --lazy Perform lazy unmounting\n" + " -h, --help Show this help screen and exit\n" + " -V, --version Show version information and exit\n" + ); +} + +int +main (int argc, char * const argv[]) +{ + PROG = "aa-umount"; + int flags = 0; + + for (;;) + { + struct option longopts[] = { + { "force", no_argument, NULL, 'f' }, + { "help", no_argument, NULL, 'h' }, + { "lazy", no_argument, NULL, 'l' }, + { "version", no_argument, NULL, 'V' }, + { NULL, 0, 0, 0 } + }; + int c; + + c = getopt_long (argc, argv, "fhlV", longopts, NULL); + if (c == -1) + break; + switch (c) + { + case 'f': + flags = MNT_FORCE; + break; + + case 'h': + dieusage (0); + + case 'l': + flags = MNT_DETACH; + break; + + case 'V': + aa_die_version (); + + default: + dieusage (1); + } + } + argc -= optind; + argv += optind; + + if (argc != 1) + dieusage (1); + + if (umount2 (argv[0], flags) < 0) + strerr_diefu2sys (3, "unmount ", argv[0]); + + return 0; +} diff --git a/src/utils/deps-exe/aa-umount b/src/utils/deps-exe/aa-umount new file mode 100644 index 0000000..30987b4 --- /dev/null +++ b/src/utils/deps-exe/aa-umount @@ -0,0 +1,2 @@ +${LIBANOPA} +-lskarnet