mirror of git://git.suckless.org/ubase
Implement -l support for umount
This operation is not supported on OpenBSD so just set errno to ENOTSUP.
This commit is contained in:
parent
d4c1710911
commit
9fbe1e6e66
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
3
ubase.h
3
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);
|
||||
|
|
11
umount.c
11
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue