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;
}
loopinfo64.lo_offset = offset;
+ loopinfo64.lo_sizelimit = sizelimit;
#ifdef MCL_FUTURE
/*
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;
}
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;
}
" -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"
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' },
{ "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' },
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)
case 'v':
verbose = 1;
break;
+
+ case 128: /* --sizelimit */
+ sizelimit = optarg;
+ break;
+
default:
usage();
}
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) {
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)
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",