summaryrefslogtreecommitdiffstats
path: root/usr/utils/umount.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 17:06:04 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 17:06:04 +0000
commit2f0649f6fe411d7e07c8d56cf8ea56db53536da8 (patch)
tree778611fb52176dce1ad06c68e87b2cb348ca0f7b /usr/utils/umount.c
parentInitial commit. (diff)
downloadklibc-2f0649f6fe411d7e07c8d56cf8ea56db53536da8.tar.xz
klibc-2f0649f6fe411d7e07c8d56cf8ea56db53536da8.zip
Adding upstream version 2.0.13.upstream/2.0.13upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'usr/utils/umount.c')
-rw-r--r--usr/utils/umount.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/usr/utils/umount.c b/usr/utils/umount.c
new file mode 100644
index 0000000..41275f7
--- /dev/null
+++ b/usr/utils/umount.c
@@ -0,0 +1,51 @@
+/*
+ * by rmk
+ */
+#include <sys/mount.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+char *progname;
+
+int main(int argc, char *argv[])
+{
+ int c, flag = 0;
+
+ progname = argv[0];
+
+ do {
+ c = getopt(argc, argv, "fli");
+ if (c == EOF)
+ break;
+ switch (c) {
+ case 'f':
+ flag |= MNT_FORCE;
+ break;
+ case 'l':
+ flag |= MNT_DETACH;
+ break;
+ case 'i':
+ /* ignore for now; no support for umount helpers */
+ break;
+ case '?':
+ fprintf(stderr, "%s: invalid option -%c\n",
+ progname, optopt);
+ exit(1);
+ }
+ } while (1);
+
+ if (optind + 1 != argc) {
+ fprintf(stderr, "Usage: %s [-f] [-l] [-i] mntpoint\n",
+ progname);
+ return 1;
+ }
+
+ if (umount2(argv[optind], flag) == -1) {
+ perror("umount2");
+ return 255;
+ }
+
+ return 0;
+}