mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Document unmount(1).
This commit is contained in:
parent
b5240163b6
commit
27677f2f9a
3 changed files with 42 additions and 34 deletions
|
@ -84,6 +84,7 @@ chroot \
|
|||
unmount \
|
||||
|
||||
MANPAGES8=\
|
||||
unmount.8 \
|
||||
|
||||
all: $(BINARIES) $(SBINS)
|
||||
|
||||
|
@ -97,8 +98,8 @@ install: all
|
|||
install $(SBINS) $(DESTDIR)$(SBINDIR)
|
||||
mkdir -p $(DESTDIR)$(MANDIR)/man1
|
||||
cp $(MANPAGES1) $(DESTDIR)$(MANDIR)/man1
|
||||
#mkdir -p $(DESTDIR)$(MANDIR)/man8
|
||||
#cp $(MANPAGES8) $(DESTDIR)$(MANDIR)/man8
|
||||
mkdir -p $(DESTDIR)$(MANDIR)/man8
|
||||
cp $(MANPAGES8) $(DESTDIR)$(MANDIR)/man8
|
||||
|
||||
%: %.c
|
||||
$(CC) -std=gnu11 $(CFLAGS) $(CPPFLAGS) $< -o $@
|
||||
|
|
35
utils/unmount.8
Normal file
35
utils/unmount.8
Normal file
|
@ -0,0 +1,35 @@
|
|||
.Dd October 11, 2016
|
||||
.Dt UNMOUNT 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm unmount
|
||||
.Nd unmount filesystems
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl fl
|
||||
.Ar directory ...
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
unmounts the specified paths. The mountpoint is removed so that it cannot be
|
||||
opened further, and
|
||||
.Nm
|
||||
waits until no files on the filesystem are open, after which the filesystem is
|
||||
shut off cleanly.
|
||||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width "12345678"
|
||||
.It Fl f, Fl \-force
|
||||
Shut off the filesystem immediately, further operations to any open files will
|
||||
fail. The filesystem will be consistent, but processes may be stopped in the
|
||||
middle of file operations.
|
||||
.It Fl l, Fl \-lazy
|
||||
Do not wait for the filesystem to be unused, and shut off the filesystem in
|
||||
the background. It is not safe to shut down the computer directly after using
|
||||
this option.
|
||||
.El
|
||||
.Sh EXIT STATUS
|
||||
.Nm
|
||||
will exit 0 on success and non-zero otherwise.
|
||||
.Sh SEE ALSO
|
||||
.Xr unmount 2 ,
|
||||
.Xr extfs 8
|
|
@ -19,8 +19,7 @@
|
|||
|
||||
#include <sys/mount.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <error.h>
|
||||
#include <err.h>
|
||||
#include <locale.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
@ -40,22 +39,6 @@ static void compact_arguments(int* argc, char*** argv)
|
|||
}
|
||||
}
|
||||
|
||||
static void help(FILE* fp, const char* argv0)
|
||||
{
|
||||
fprintf(fp, "Usage: %s [OPTION]... DIRECTORY...\n", argv0);
|
||||
fprintf(fp, "Unmounts filesystems mounted at directories..\n");
|
||||
fprintf(fp, "\n");
|
||||
fprintf(fp, "Mandatory arguments to long options are mandatory for short options too.\n");
|
||||
fprintf(fp, " -f, --force unmount even though still in use\n");
|
||||
fprintf(fp, " -l, --lazy remove mountpoint but delay unmounting until no longer used");
|
||||
|
||||
}
|
||||
|
||||
static void version(FILE* fp, const char* argv0)
|
||||
{
|
||||
fprintf(fp, "%s (Sortix) %s\n", argv0, VERSIONSTR);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
setlocale(LC_ALL, "");
|
||||
|
@ -63,7 +46,6 @@ int main(int argc, char* argv[])
|
|||
bool force = false;
|
||||
bool lazy = false;
|
||||
|
||||
const char* argv0 = argv[0];
|
||||
for ( int i = 1; i < argc; i++ )
|
||||
{
|
||||
const char* arg = argv[i];
|
||||
|
@ -80,25 +62,15 @@ int main(int argc, char* argv[])
|
|||
case 'f': force = true; break;
|
||||
case 'l': lazy = true; break;
|
||||
default:
|
||||
fprintf(stderr, "%s: unknown option -- '%c'\n", argv0, c);
|
||||
help(stderr, argv0);
|
||||
exit(1);
|
||||
errx(1, "unknown option -- '%c'", c);
|
||||
}
|
||||
}
|
||||
else if ( !strcmp(arg, "--help") )
|
||||
help(stdout, argv0), exit(0);
|
||||
else if ( !strcmp(arg, "--version") )
|
||||
version(stdout, argv0), exit(0);
|
||||
else if ( !strcmp(arg, "--force") )
|
||||
force = true;
|
||||
else if ( !strcmp(arg, "--lazy") )
|
||||
lazy = true;
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s: unknown option: %s\n", argv0, arg);
|
||||
help(stderr, argv0);
|
||||
exit(1);
|
||||
}
|
||||
errx(1, "unknown option: %s", arg);
|
||||
}
|
||||
|
||||
compact_arguments(&argc, &argv);
|
||||
|
@ -113,7 +85,7 @@ int main(int argc, char* argv[])
|
|||
{
|
||||
const char* path = argv[i];
|
||||
if ( unmount(path, flags) < 0 )
|
||||
error(1, errno, "`%s'", path);
|
||||
err(1, "%s", path);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue