Currently if I want to map an encrypted filesystem that resides in a file rather than a partition, I have to specify which /dev/loopX device the mapping should use. Suppose I have 10 such files, but only use them one at a time. I'd still need to have 10 loop devices (default is 8). There is no reason to statically allocate those, because losetup can automatically use the next available one. I submit a patch to dm-crypt-start.sh which, when "source" is unspecified but "loop_file" is specified, maps the file to the next available loop device (-f option to losetup), gets the device's name, and proceeds as if that device was specified as "source". I submit a patch to dm-crypt-stop.sh which, instead of grepping all the sources, checking which ones are loop devices, and unmapping them, looks for loop_files, finds out which are currently mapped to loop devices (-j option to losetup), and unmaps those devices. Also the example conf file is changed to add a comment about this feature. The patched files are static files in the portage tree. This change is backwards compatible with configurations that do specify "source" and more user friendly. In cases of many mappings some of which are not always used, the difference is substantial. Reproducible: Always Please apply.
Created attachment 202208 [details, diff] the patch
Created attachment 202211 [details, diff] fixed names of files in patch The patch itself was right, but I named the files wrong. Oops.
should be all set now in the tree; thanks for the report! Commit message: Allow loopbacks to be allocated dynamically from a free one http://sources.gentoo.org/sys-fs/cryptsetup/files/1.0.6-dmcrypt.confd?r1=1.7&r2=1.8 http://sources.gentoo.org/sys-fs/cryptsetup/files/1.5.1-dmcrypt.rc?r1=1.8&r2=1.9