Add umount(8)

No manpage yet.
This commit is contained in:
sin 2013-08-07 09:52:10 +01:00
parent 7efb360b3c
commit d4c1710911
5 changed files with 71 additions and 1 deletions

View File

@ -7,12 +7,14 @@ HDR = util.h arg.h ubase.h
LIB = \
$(OS)/grabmntinfo.o \
$(OS)/syslog.o \
$(OS)/umount.o \
util/eprintf.o \
util/estrtol.o
SRC = \
df.c \
dmesg.c
dmesg.c \
umount.c
OBJ = $(SRC:.c=.o) $(LIB)
BIN = $(SRC:.c=)

14
linux/umount.c Normal file
View File

@ -0,0 +1,14 @@
#include <sys/mount.h>
#include <stdio.h>
#include "../ubase.h"
#include "../util.h"
int
do_umount(const char *target, int opts)
{
int flags = 0;
if (opts & UBASE_MNT_FORCE)
flags |= MNT_FORCE;
return umount2(target, flags);
}

15
openbsd/umount.c Normal file
View File

@ -0,0 +1,15 @@
#include <sys/param.h>
#include <sys/mount.h>
#include <stdio.h>
#include "../ubase.h"
#include "../util.h"
int
do_umount(const char *target, int opts)
{
int flags = 0;
if (opts & UBASE_MNT_FORCE)
flags |= MNT_FORCE;
return unmount(target, flags);
}

View File

@ -11,3 +11,10 @@ int grabmntinfo(struct mntinfo **minfo);
/* syslog.c */
int syslog_size(void);
int syslog_read(void *buf, size_t n);
/* umount.c */
enum {
UBASE_MNT_FORCE = 1 << 0
};
int do_umount(const char *target, int opts);

32
umount.c Normal file
View File

@ -0,0 +1,32 @@
#include <stdio.h>
#include "ubase.h"
#include "util.h"
static void
usage(void)
{
eprintf("usage: %s [-f] target\n", argv0);
}
int
main(int argc, char *argv[]) {
int i;
int fflag = 0;
int ret = 0;
ARGBEGIN {
case 'f':
fflag = UBASE_MNT_FORCE;
break;
default:
usage();
} ARGEND;
if (argc < 1)
usage();
for (i = 0; i < argc; i++) {
if (do_umount(argv[i], fflag) < 0)
eprintf("do_umount:");
ret = 1;
}
return ret;
}