summaryrefslogtreecommitdiffstats
path: root/mount
diff options
context:
space:
mode:
authorKarel Zak2007-06-27 17:32:51 +0200
committerKarel Zak2007-06-27 17:32:51 +0200
commitd99f0140f71cbdce7aae8128e7400bc1cf22fe53 (patch)
treed4fb964e3a3f38ba1f15f1ddf9cb8daf526fbbe5 /mount
parentmount: loop device race condition (diff)
downloadkernel-qcow2-util-linux-d99f0140f71cbdce7aae8128e7400bc1cf22fe53.tar.gz
kernel-qcow2-util-linux-d99f0140f71cbdce7aae8128e7400bc1cf22fe53.tar.xz
kernel-qcow2-util-linux-d99f0140f71cbdce7aae8128e7400bc1cf22fe53.zip
losetup: add long options and fix man page
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'mount')
-rw-r--r--mount/lomount.c40
-rw-r--r--mount/losetup.845
2 files changed, 52 insertions, 33 deletions
diff --git a/mount/lomount.c b/mount/lomount.c
index 2989717e4..f8fd0e28d 100644
--- a/mount/lomount.c
+++ b/mount/lomount.c
@@ -446,16 +446,23 @@ char *progname;
static void
usage(void) {
- fprintf(stderr, _("usage:\n"
- " %1$s loop_device # give info\n"
- " %1$s -d loop_device # delete\n"
- " %1$s -f # find unused\n"
- " %1$s -a # list all used\n"
- " %1$s -r # read-only loop\n"
- " %1$s [-e encryption] [-o offset] [-r] {-f [-s] |loop_device} file # setup\n"),
+ fprintf(stderr, _("\nUsage:\n"
+ " %1$s loop_device # give info\n"
+ " %1$s -a | --all # list all used\n"
+ " %1$s -d | --detach loop_device # delete\n"
+ " %1$s -f | --find # find unused\n"
+ " %1$s [ options ] {-f|--find|loop_device} file # setup\n"
+ "\nOptions:\n"
+ " -e | --encryption <type> enable data encryption with specified <name/num>\n"
+ " -h | --help this help\n"
+ " -o | --offset <num> start at offset <num> into file\n"
+ " -p | --pass-fd <num> read passphrase from file descriptor <num>\n"
+ " -r | --read-only setup read-only loop device\n"
+ " -s | --show print device name (with -f <file>)\n"
+ " -v | --verbose verbose mode\n\n"),
progname);
exit(1);
-}
+ }
char *
xstrdup (const char *s) {
@@ -484,6 +491,7 @@ error (const char *fmt, ...) {
fprintf (stderr, "\n");
}
+
int
main(int argc, char **argv) {
char *p, *offset, *encryption, *passfd, *device, *file;
@@ -493,6 +501,19 @@ main(int argc, char **argv) {
int ro = 0;
int pfd = -1;
unsigned long long off;
+ struct option longopts[] = {
+ { "all", 0, 0, 'a' },
+ { "detach", 0, 0, 'd' },
+ { "encryption", 1, 0, 'e' },
+ { "find", 0, 0, 'f' },
+ { "help", 0, 0, 'h' },
+ { "offset", 1, 0, 'o' },
+ { "pass-fd", 1, 0, 'p' },
+ { "read-only", 0, 0, 'r' },
+ { "show", 0, 0, 's' },
+ { "verbose", 0, 0, 'v' },
+ { NULL, 0, 0, 0 }
+ };
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
@@ -506,7 +527,8 @@ main(int argc, char **argv) {
if ((p = strrchr(progname, '/')) != NULL)
progname = p+1;
- while ((c = getopt(argc, argv, "ade:E:fo:p:vrs")) != -1) {
+ while ((c = getopt_long(argc, argv, "ade:E:fho:p:rsv",
+ longopts, NULL)) != -1) {
switch (c) {
case 'a':
all = 1;
diff --git a/mount/losetup.8 b/mount/losetup.8
index 5b44a4d8a..9bbc7a42b 100644
--- a/mount/losetup.8
+++ b/mount/losetup.8
@@ -61,41 +61,38 @@ has to make sure that the Linux kernel knows about the encryption with that
number, probably by patching the kernel. Standard numbers that are
always present are 0 (no encryption) and 1 (XOR encryption).
When the cryptoloop module is loaded (or compiled in), it uses number 18.
-This cryptoloop module wil take the name of an arbitrary encryption type
+This cryptoloop module will take the name of an arbitrary encryption type
and finds the module that knows how to perform that encryption.
-(Thus, either one uses a number different from 18 with the
-.B \-E
-option, or one uses a name with the
-.B \-e
-option.)
.SH OPTIONS
-.IP \fB\-a\fP
-Show status of all loop devices.
-.IP \fB\-d\fP
-Detach the file or device associated with the specified loop device.
-.IP "\fB\-E \fIencryption_type\fP"
-Enable data encryption with specified number.
-.IP "\fB\-e \fIencryption_name\fP"
-Enable data encryption with specified name.
-.IP "\fB\-f\fP"
-Find the first unused loop device. If a
+.IP "\fB\-a, \-\-all\fP"
+show status of all loop devices
+.IP "\fB\-d, \-\-detach\fP"
+detach the file or device associated with the specified loop device
+.IP "\fB\-e, \-E, \-\-encryption \fIencryption_type\fP"
+enable data encryption with specified name or number
+.IP "\fB\-f, \-\-find\fP"
+find the first unused loop device. If a
.I file
argument is present, use this device. Otherwise, print its name.
-.IP "\fB\-o \fIoffset\fP"
+.IP "\fB\-h, \-\-help\fP"
+print help
+.IP "\fB\-o, \-\-offset \fIoffset\fP"
The data start is moved \fIoffset\fP bytes into the specified file or
device.
-.IP "\fB\-p \fInum\fP"
+.IP "\fB\-p, \-\-pass-fd \fInum\fP"
Read the passphrase from file descriptor with number
.I num
-instead of from the terminal.
-.IP \fB\-r\fP
-Setup read-only loop device.
-.IP \fB\-s\fP
-Print device name if the
+instead of from the terminal
+.IP "\fB\-r, \-\-read-only\fP"
+setup read-only loop device
+.IP "\fB\-s, \-\-show\fP"
+print device name if the
.I -f
option and a
.I file
-argument are present.
+argument are present
+.IP "\fB\-v, \-\-verbose\fP"
+verbose mode
.SH RETURN VALUE
.B losetup