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) {
fprintf (stderr, "\n");
}
+
int
main(int argc, char **argv) {
char *p, *offset, *encryption, *passfd, *device, *file;
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);
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;
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