diff options
author | Lauri Kasanen <curaga@operamail.com> | 2010-04-14 12:31:26 -0700 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-04-14 12:31:26 -0700 |
commit | 375a8ef5ea38ea10134c125c75a12bbf9d5ba7bd (patch) | |
tree | 1bd21b3e2ed9e15f92e5d0bdb03b276cac6f7a74 | |
parent | 0ecc11659285337c0430f1b7004eb3b2901a93d3 (diff) | |
download | busybox-w32-375a8ef5ea38ea10134c125c75a12bbf9d5ba7bd.tar.gz busybox-w32-375a8ef5ea38ea10134c125c75a12bbf9d5ba7bd.tar.bz2 busybox-w32-375a8ef5ea38ea10134c125c75a12bbf9d5ba7bd.zip |
mount: add an optional capability to create new /dev/loopN as needed
Signed-off-by: Lauri Kasanen <curaga@operamail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | libbb/loop.c | 14 | ||||
-rw-r--r-- | scripts/defconfig | 1 | ||||
-rw-r--r-- | util-linux/Config.in | 12 |
3 files changed, 25 insertions, 2 deletions
diff --git a/libbb/loop.c b/libbb/loop.c index abf05dc4f..204fcc982 100644 --- a/libbb/loop.c +++ b/libbb/loop.c | |||
@@ -104,14 +104,24 @@ int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offse | |||
104 | 104 | ||
105 | /* Find a loop device. */ | 105 | /* Find a loop device. */ |
106 | try = *device ? *device : dev; | 106 | try = *device ? *device : dev; |
107 | for (i = 0; rc; i++) { | 107 | for (i = 0; rc && i < 256; i++) { |
108 | sprintf(dev, LOOP_FORMAT, i); | 108 | sprintf(dev, LOOP_FORMAT, i); |
109 | 109 | ||
110 | /* Ran out of block devices, return failure. */ | 110 | IF_FEATURE_MOUNT_LOOP_CREATE(errno = 0;) |
111 | if (stat(try, &statbuf) != 0 || !S_ISBLK(statbuf.st_mode)) { | 111 | if (stat(try, &statbuf) != 0 || !S_ISBLK(statbuf.st_mode)) { |
112 | if (ENABLE_FEATURE_MOUNT_LOOP_CREATE | ||
113 | && errno == ENOENT | ||
114 | && try == dev | ||
115 | ) { | ||
116 | /* Node doesn't exist, try to create it. */ | ||
117 | if (mknod(dev, S_IFBLK|0644, makedev(7, i)) == 0) | ||
118 | goto try_to_open; | ||
119 | } | ||
120 | /* Ran out of block devices, return failure. */ | ||
112 | rc = -ENOENT; | 121 | rc = -ENOENT; |
113 | break; | 122 | break; |
114 | } | 123 | } |
124 | try_to_open: | ||
115 | /* Open the sucker and check its loopiness. */ | 125 | /* Open the sucker and check its loopiness. */ |
116 | dfd = open(try, mode); | 126 | dfd = open(try, mode); |
117 | if (dfd < 0 && errno == EROFS) { | 127 | if (dfd < 0 && errno == EROFS) { |
diff --git a/scripts/defconfig b/scripts/defconfig index d13f5b1b4..0a748febc 100644 --- a/scripts/defconfig +++ b/scripts/defconfig | |||
@@ -574,6 +574,7 @@ CONFIG_FEATURE_UMOUNT_ALL=y | |||
574 | # Common options for mount/umount | 574 | # Common options for mount/umount |
575 | # | 575 | # |
576 | CONFIG_FEATURE_MOUNT_LOOP=y | 576 | CONFIG_FEATURE_MOUNT_LOOP=y |
577 | # CONFIG_FEATURE_MOUNT_LOOP_CREATE is not set | ||
577 | # CONFIG_FEATURE_MTAB_SUPPORT is not set | 578 | # CONFIG_FEATURE_MTAB_SUPPORT is not set |
578 | 579 | ||
579 | # | 580 | # |
diff --git a/util-linux/Config.in b/util-linux/Config.in index acd74a2c6..a59cc1ddf 100644 --- a/util-linux/Config.in +++ b/util-linux/Config.in | |||
@@ -901,6 +901,18 @@ config FEATURE_MOUNT_LOOP | |||
901 | specify an offset or cryptographic options to the loopback device. | 901 | specify an offset or cryptographic options to the loopback device. |
902 | (If you don't want umount to free the loop device, use "umount -D".) | 902 | (If you don't want umount to free the loop device, use "umount -D".) |
903 | 903 | ||
904 | config FEATURE_MOUNT_LOOP_CREATE | ||
905 | bool "Create new loopback devices if needed" | ||
906 | default n | ||
907 | depends on FEATURE_MOUNT_LOOP | ||
908 | help | ||
909 | Linux kernels >= 2.6.24 support unlimited loopback devices. They are | ||
910 | allocated for use when trying to use a loop device. The loop device | ||
911 | must however exist. | ||
912 | |||
913 | This feature lets mount to try to create next /dev/loopN device | ||
914 | if it does not find a free one. | ||
915 | |||
904 | config FEATURE_MTAB_SUPPORT | 916 | config FEATURE_MTAB_SUPPORT |
905 | bool "Support for the old /etc/mtab file" | 917 | bool "Support for the old /etc/mtab file" |
906 | default n | 918 | default n |