mirror of
git://git.suckless.org/ubase
synced 2025-04-08 02:01:29 +00:00
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)
|
if (opts & UBASE_MNT_FORCE)
|
||||||
flags |= MNT_FORCE;
|
flags |= MNT_FORCE;
|
||||||
|
if (opts & UBASE_MNT_DETACH)
|
||||||
|
flags |= MNT_DETACH;
|
||||||
return umount2(target, flags);
|
return umount2(target, flags);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "../ubase.h"
|
#include "../ubase.h"
|
||||||
#include "../util.h"
|
#include "../util.h"
|
||||||
@ -11,5 +12,9 @@ do_umount(const char *target, int opts)
|
|||||||
|
|
||||||
if (opts & UBASE_MNT_FORCE)
|
if (opts & UBASE_MNT_FORCE)
|
||||||
flags |= MNT_FORCE;
|
flags |= MNT_FORCE;
|
||||||
|
if (opts & UBASE_MNT_DETACH) {
|
||||||
|
errno = ENOTSUP;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return unmount(target, flags);
|
return unmount(target, flags);
|
||||||
}
|
}
|
||||||
|
3
ubase.h
3
ubase.h
@ -14,7 +14,8 @@ int syslog_read(void *buf, size_t n);
|
|||||||
|
|
||||||
/* umount.c */
|
/* umount.c */
|
||||||
enum {
|
enum {
|
||||||
UBASE_MNT_FORCE = 1 << 0
|
UBASE_MNT_FORCE = 1 << 0,
|
||||||
|
UBASE_MNT_DETACH = 1 << 1
|
||||||
};
|
};
|
||||||
|
|
||||||
int do_umount(const char *target, int opts);
|
int do_umount(const char *target, int opts);
|
||||||
|
11
umount.c
11
umount.c
@ -5,18 +5,21 @@
|
|||||||
static void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
eprintf("usage: %s [-f] target\n", argv0);
|
eprintf("usage: %s [-lf] target\n", argv0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[]) {
|
main(int argc, char *argv[]) {
|
||||||
int i;
|
int i;
|
||||||
int fflag = 0;
|
int flags = 0;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
ARGBEGIN {
|
ARGBEGIN {
|
||||||
case 'f':
|
case 'f':
|
||||||
fflag = UBASE_MNT_FORCE;
|
flags |= UBASE_MNT_FORCE;
|
||||||
|
break;
|
||||||
|
case 'l':
|
||||||
|
flags |= UBASE_MNT_DETACH;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
@ -24,7 +27,7 @@ main(int argc, char *argv[]) {
|
|||||||
if (argc < 1)
|
if (argc < 1)
|
||||||
usage();
|
usage();
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
if (do_umount(argv[i], fflag) < 0)
|
if (do_umount(argv[i], flags) < 0)
|
||||||
eprintf("do_umount:");
|
eprintf("do_umount:");
|
||||||
ret = 1;
|
ret = 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user