From: LaMont Jones Date: Wed, 16 Apr 2008 04:59:28 +0000 (-0600) Subject: Merge commit 'origin/master' X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=769434fc28227d4f83ca6da9d7271b734811fd1c;p=util-linux Merge commit 'origin/master' Conflicts: mount/lomount.c mount/lomount.h mount/mount.c --- 769434fc28227d4f83ca6da9d7271b734811fd1c diff --cc mount/lomount.c index 04b0f279,c3ac68a7..e6b7f247 --- a/mount/lomount.c +++ b/mount/lomount.c @@@ -610,7 -609,7 +610,8 @@@ digits_only(const char *s) int set_loop(const char *device, const char *file, unsigned long long offset, - const char *encryption, int pfd, int *options, int keysz, int hash_pass) { - unsigned long long sizelimit, const char *encryption, int pfd, int *options) { ++ unsigned long long sizelimit, const char *encryption, int pfd, int *options, ++ int keysz, int hash_pass) { struct loop_info64 loopinfo64; int fd, ffd, mode, i; char *pass; @@@ -863,8 -796,9 +865,9 @@@ mutter(void) } int - set_loop (const char *device, const char *file, unsigned long long offset, - const char *encryption, int pfd, int *options, int keysz, int hash_pass) { + set_loop(const char *device, const char *file, unsigned long long offset, - unsigned long long sizelimit, const char *encryption, int pfd, int *loopro, - int keysz, int hash_pass) { ++ unsigned long long sizelimit, const char *encryption, int pfd, int *options, ++ int keysz, int hash_pass) { mutter(); return 1; } @@@ -903,43 -839,32 +908,44 @@@ usage(void) " -e | --encryption enable data encryption with specified \n" " -h | --help this help\n" " -o | --offset start at offset into file\n" + " --sizelimit loop limited to only bytes of the file\n" " -p | --pass-fd read passphrase from file descriptor \n" " -r | --read-only setup read-only loop device\n" - " -s | --show print device name (with -f )\n" + " --show print device name (with -f )\n" + " -N | --nohashpass Do not hash the given password (Debian hashes)\n" + " -k | --keybits specify number of bits in the hashed key given\n" + " to the cipher. Some ciphers support several key\n" + " sizes and might be more efficient with a smaller\n" + " key size. Key sizes < 128 are generally not\n" + " recommended\n" - " -v | --verbose verbose mode\n\n"), - progname); + " -v | --verbose verbose mode\n\n")); exit(1); } int main(int argc, char **argv) { - char *p, *offset, *encryption, *passfd, *device, *file, *assoc; + char *p, *offset, *sizelimit, *encryption, *passfd, *device, *file, *assoc; + char *keysize; int delete, find, c, all; int res = 0; int showdev = 0; int ro = 0; int pfd = -1; + int keysz = 0; + int hash_pass = 1; - unsigned long long off; + unsigned long long off, slimit; struct option longopts[] = { { "all", 0, 0, 'a' }, { "detach", 0, 0, 'd' }, { "encryption", 1, 0, 'e' }, { "find", 0, 0, 'f' }, { "help", 0, 0, 'h' }, + { "keybits", 1, 0, 'k' }, + { "nopasshash", 0, 0, 'N' }, + { "nohashpass", 0, 0, 'N' }, { "associated", 1, 0, 'j' }, { "offset", 1, 0, 'o' }, + { "sizelimit", 1, 0, 128 }, { "pass-fd", 1, 0, 'p' }, { "read-only", 0, 0, 'r' }, { "show", 0, 0, 's' }, @@@ -953,9 -878,8 +959,9 @@@ delete = find = all = 0; off = 0; - offset = encryption = passfd = NULL; + slimit = 0; - assoc = offset = sizelimit = encryption = passfd = NULL; + assoc = offset = encryption = passfd = NULL; + keysize = NULL; progname = argv[0]; if ((p = strrchr(progname, '/')) != NULL) @@@ -1058,10 -985,8 +1072,10 @@@ else { if (passfd && sscanf(passfd, "%d", &pfd) != 1) usage(); + if (keysize && sscanf(keysize,"%d",&keysz) != 1) + usage(); do { - res = set_loop(device, file, off, encryption, pfd, &ro, keysz, hash_pass); - res = set_loop(device, file, off, slimit, encryption, pfd, &ro); ++ res = set_loop(device, file, off, slimit, encryption, pfd, &ro, keysz, hash_pass); if (res == 2 && find) { if (verbose) printf("stolen loop=%s...trying again\n", diff --cc mount/lomount.h index 95f13988,f332a70d..7d548b5a --- a/mount/lomount.h +++ b/mount/lomount.h @@@ -1,5 -1,5 +1,5 @@@ - extern int set_loop(const char *, const char *, unsigned long long, + extern int set_loop(const char *, const char *, unsigned long long, unsigned long long, - const char *, int, int *); + const char *, int, int *, int, int); extern int del_loop(const char *); extern int is_loop_device(const char *); extern char * find_unused_loop_device(void); diff --cc mount/mount.8 index ac0eeef7,bb6b3f10..10a39dfd --- a/mount/mount.8 +++ b/mount/mount.8 @@@ -2015,14 -2007,10 +2015,14 @@@ to correspond to the fil and then mount this device on .IR /mnt . - This type of mount knows about three options, namely - .BR loop ", " offset " and " encryption , + This type of mount knows about four options, namely + .BR loop ", " offset ", " sizelimit " and " encryption , that are really options to .BR \%losetup (8). +If the mount requires a passphrase, you will be prompted for one unless +you specify a file descriptor to read from instead with the +.BR \-\-pass-fd +option. (These options can be used in addition to those specific to the filesystem type.) diff --cc mount/mount.c index 182f36b6,bed792d2..62b89068 --- a/mount/mount.c +++ b/mount/mount.c @@@ -191,9 -182,8 +191,9 @@@ static const struct opt_map opt_map[] static int opt_nofail = 0; - static const char *opt_loopdev, *opt_vfstype, *opt_offset, *opt_encryption, - *opt_speed, *opt_comment, *opt_uhelper; + static const char *opt_loopdev, *opt_vfstype, *opt_offset, *opt_sizelimit, + *opt_encryption, *opt_speed, *opt_comment, *opt_uhelper; +static const char *opt_keybits, *opt_nohashpass; static int mounted (const char *spec0, const char *node0); static int check_special_mountprog(const char *spec, const char *node, @@@ -207,9 -197,8 +207,10 @@@ static struct string_opt_map { "loop=", 0, &opt_loopdev }, { "vfs=", 1, &opt_vfstype }, { "offset=", 0, &opt_offset }, + { "sizelimit=", 0, &opt_sizelimit }, { "encryption=", 0, &opt_encryption }, + { "keybits=", 0, &opt_keybits }, + { "nohashpass", 0, &opt_nohashpass }, { "speed=", 0, &opt_speed }, { "comment=", 1, &opt_comment }, { "uhelper=", 0, &opt_uhelper }, @@@ -909,7 -898,7 +910,7 @@@ loop_check(const char **spec, const cha *type = opt_vfstype; } - *loop = ((*flags & MS_LOOP) || *loopdev || opt_offset || opt_encryption || opt_keybits); - *loop = ((*flags & MS_LOOP) || *loopdev || opt_offset || opt_sizelimit || opt_encryption); ++ *loop = ((*flags & MS_LOOP) || *loopdev || opt_offset || opt_sizelimit || opt_encryption || opt_keybits); *loopfile = *spec; if (*loop) { @@@ -938,12 -928,9 +940,12 @@@ return EX_SYSERR; /* no more loop devices */ if (verbose) printf(_("mount: going to use the loop device %s\n"), *loopdev); - + if (!keysz && opt_keybits) + keysz = strtoul(opt_keybits, NULL, 0); + if (opt_nohashpass) + hash_pass=0; - if ((res = set_loop(*loopdev, *loopfile, offset, + if ((res = set_loop(*loopdev, *loopfile, offset, sizelimit, - opt_encryption, pfd, &loop_opts))) { + opt_encryption, pfd, &loop_opts, keysz, hash_pass))) { if (res == 2) { /* loop dev has been grabbed by some other process, try again, if not given explicitly */