ubase

suckless linux base utils
git clone git://git.2f30.org/ubase.git
Log | Files | Refs | README | LICENSE

commit 9fbe1e6e6647d308804531a52de36e8fb546fc09
parent d4c1710911198be8837afa781777731534b14a42
Author: sin <sin@2f30.org>
Date:   Wed Aug  7 10:33:19 +0100

Implement -l support for umount

This operation is not supported on OpenBSD so just
set errno to ENOTSUP.

Diffstat:
linux/umount.c | 2++
openbsd/umount.c | 5+++++
ubase.h | 3++-
umount.c | 11+++++++----
4 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/linux/umount.c b/linux/umount.c @@ -10,5 +10,7 @@ do_umount(const char *target, int opts) if (opts & UBASE_MNT_FORCE) flags |= MNT_FORCE; + if (opts & UBASE_MNT_DETACH) + flags |= MNT_DETACH; return umount2(target, flags); } diff --git a/openbsd/umount.c b/openbsd/umount.c @@ -1,5 +1,6 @@ #include <sys/param.h> #include <sys/mount.h> +#include <errno.h> #include <stdio.h> #include "../ubase.h" #include "../util.h" @@ -11,5 +12,9 @@ do_umount(const char *target, int opts) if (opts & UBASE_MNT_FORCE) flags |= MNT_FORCE; + if (opts & UBASE_MNT_DETACH) { + errno = ENOTSUP; + return -1; + } return unmount(target, flags); } diff --git a/ubase.h b/ubase.h @@ -14,7 +14,8 @@ int syslog_read(void *buf, size_t n); /* umount.c */ enum { - UBASE_MNT_FORCE = 1 << 0 + UBASE_MNT_FORCE = 1 << 0, + UBASE_MNT_DETACH = 1 << 1 }; int do_umount(const char *target, int opts); diff --git a/umount.c b/umount.c @@ -5,18 +5,21 @@ static void usage(void) { - eprintf("usage: %s [-f] target\n", argv0); + eprintf("usage: %s [-lf] target\n", argv0); } int main(int argc, char *argv[]) { int i; - int fflag = 0; + int flags = 0; int ret = 0; ARGBEGIN { case 'f': - fflag = UBASE_MNT_FORCE; + flags |= UBASE_MNT_FORCE; + break; + case 'l': + flags |= UBASE_MNT_DETACH; break; default: usage(); @@ -24,7 +27,7 @@ main(int argc, char *argv[]) { if (argc < 1) usage(); for (i = 0; i < argc; i++) { - if (do_umount(argv[i], fflag) < 0) + if (do_umount(argv[i], flags) < 0) eprintf("do_umount:"); ret = 1; }