diff options
author | Shachar Shemesh | 2008-04-15 12:57:35 +0200 |
---|---|---|
committer | Karel Zak | 2008-04-15 12:57:35 +0200 |
commit | 7bcefc7f03aa5e2c346c92e0c9b780f51c716dee (patch) | |
tree | 54cc422b8b164c4fd4d915fa4d1a7c5987b80ddf /mount/lomount.c | |
parent | mkswap: when writing the signature page, handle EINTR returns (diff) | |
download | kernel-qcow2-util-linux-7bcefc7f03aa5e2c346c92e0c9b780f51c716dee.tar.gz kernel-qcow2-util-linux-7bcefc7f03aa5e2c346c92e0c9b780f51c716dee.tar.xz kernel-qcow2-util-linux-7bcefc7f03aa5e2c346c92e0c9b780f51c716dee.zip |
losetup: add --sizelimit option
[kzak@redhat.com: split the original patch to small patches]
Signed-off-by: Shachar Shemesh <shachar@debian.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'mount/lomount.c')
-rw-r--r-- | mount/lomount.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/mount/lomount.c b/mount/lomount.c index ac379c0db..953fe86b1 100644 --- a/mount/lomount.c +++ b/mount/lomount.c @@ -609,7 +609,7 @@ 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) { + unsigned long long sizelimit, const char *encryption, int pfd, int *options) { struct loop_info64 loopinfo64; int fd, ffd, mode, i; char *pass; @@ -657,6 +657,7 @@ set_loop(const char *device, const char *file, unsigned long long offset, } loopinfo64.lo_offset = offset; + loopinfo64.lo_sizelimit = sizelimit; #ifdef MCL_FUTURE /* @@ -758,8 +759,8 @@ set_loop(const char *device, const char *file, unsigned long long offset, close (fd); if (verbose > 1) - printf(_("set_loop(%s,%s,%llu): success\n"), - device, filename, offset); + printf(_("set_loop(%s,%s,%llu,%llu): success\n"), + device, filename, offset, sizelimit); if (file != filename) free(filename); return 0; @@ -795,8 +796,9 @@ mutter(void) { } int -set_loop (const char *device, const char *file, unsigned long long offset, - const char *encryption, int *loopro) { +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) { mutter(); return 1; } @@ -835,6 +837,7 @@ usage(void) { " -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" + " --sizelimit <num> loop limited to only <num> bytes of the 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" @@ -845,13 +848,13 @@ usage(void) { int main(int argc, char **argv) { - char *p, *offset, *encryption, *passfd, *device, *file, *assoc; + char *p, *offset, *sizelimit, *encryption, *passfd, *device, *file, *assoc; int delete, find, c, all; int res = 0; int showdev = 0; int ro = 0; int pfd = -1; - unsigned long long off; + unsigned long long off, slimit; struct option longopts[] = { { "all", 0, 0, 'a' }, { "detach", 0, 0, 'd' }, @@ -860,6 +863,7 @@ main(int argc, char **argv) { { "help", 0, 0, 'h' }, { "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' }, @@ -873,7 +877,8 @@ main(int argc, char **argv) { delete = find = all = 0; off = 0; - assoc = offset = encryption = passfd = NULL; + slimit = 0; + assoc = offset = sizelimit = encryption = passfd = NULL; progname = argv[0]; if ((p = strrchr(progname, '/')) != NULL) @@ -913,6 +918,11 @@ main(int argc, char **argv) { case 'v': verbose = 1; break; + + case 128: /* --sizelimit */ + sizelimit = optarg; + break; + default: usage(); } @@ -921,7 +931,7 @@ main(int argc, char **argv) { if (argc == 1) { usage(); } else if (delete) { - if (argc != optind+1 || encryption || offset || + if (argc != optind+1 || encryption || offset || sizelimit || find || all || showdev || assoc || ro) usage(); } else if (find) { @@ -941,6 +951,9 @@ main(int argc, char **argv) { if (offset && sscanf(offset, "%llu", &off) != 1) usage(); + if (sizelimit && sscanf(sizelimit, "%llu", &slimit) != 1) + usage(); + if (all) return show_used_loop_devices(); else if (assoc) @@ -972,7 +985,7 @@ main(int argc, char **argv) { if (passfd && sscanf(passfd, "%d", &pfd) != 1) usage(); do { - res = set_loop(device, file, off, encryption, pfd, &ro); + res = set_loop(device, file, off, slimit, encryption, pfd, &ro); if (res == 2 && find) { if (verbose) printf("stolen loop=%s...trying again\n", |