1
#! /bin/sh /usr/share/dpatch/dpatch-run
2
## losetup_add_option_f.patch by Max Vozeler <xam@debian.org>
4
## DP: Add support for option -f ("find next free loop") which is
5
## DP: supported in util-linux-ng proper. See Bug#495682.
8
diff -urNad trunk~/mount/lomount.c trunk/mount/lomount.c
9
--- trunk~/mount/lomount.c 2008-08-19 20:19:35.000000000 +0200
10
+++ trunk/mount/lomount.c 2008-08-19 20:19:53.000000000 +0200
13
#define SIZE(a) (sizeof(a)/sizeof(a[0]))
17
find_unused_loop_device (void) {
18
/* Just creating a device, say in /tmp, is probably a bad idea -
24
int is_loop_active(const char *dev, const char *backdev)
27
@@ -1081,12 +1081,13 @@
28
%s -F [options] loop_device [file] # setup, read /etc/fstab\n\
29
%s loop_device # give info\n\
30
%s -a # give info of all loops\n\
31
+ %s -f # show next free loop device\n\
32
%s -d loop_device # delete\n\
33
%s -R loop_device # resize\n\
34
options: -e encryption -o offset -s sizelimit -p passwdfd -T -S pseed\n\
35
-H phash -I loinit -K gpgkey -G gpghome -C itercountk -v -r\n\
37
- progname, progname, progname, progname, progname, progname);
38
+ progname, progname, progname, progname, progname, progname, progname);
44
main(int argc, char **argv) {
45
char *partitionName = NULL;
46
- int delete,c,option_a=0,option_F=0,option_R=0,setup_o=0;
47
+ char *device = NULL;
48
+ int delete,find,c,option_a=0,option_F=0,option_R=0,setup_o=0;
53
bindtextdomain(PACKAGE, LOCALEDIR);
59
- while ((c = getopt(argc,argv,"aC:de:FG:H:I:K:o:p:P:rRs:S:Tv")) != -1) {
60
+ while ((c = getopt(argc,argv,"aC:de:fFG:H:I:K:o:p:P:rRs:S:Tv")) != -1) {
62
case 'a': /* show status of all loops */
65
loopEncryptionType = optarg;
68
+ case 'f': /* find free loop */
71
case 'F': /* read loop related options from /etc/fstab */
74
@@ -1336,12 +1341,22 @@
78
- if (option_a + delete + option_R + setup_o > 1) usage();
79
+ if (option_a + delete + option_R + setup_o + find > 1) usage();
82
if (argc != optind) usage();
88
+ device = find_unused_loop_device();
92
+ printf("Loop device is %s\n", device);
93
+ printf("%s\n", device);
97
if (argc != optind+1) usage();
98
diff -urNad trunk~/mount/losetup.8 trunk/mount/losetup.8
99
--- trunk~/mount/losetup.8 2008-08-19 20:19:35.000000000 +0200
100
+++ trunk/mount/losetup.8 2008-08-19 20:19:35.000000000 +0200
111
configuration or corresponding modules have been loaded to kernel.
115
+Find and show next unused loop device.
117
Reads and uses mount options from /etc/fstab that match specified loop
118
device, including offset= sizelimit= encryption= pseed= phash= loinit=