aboutsummaryrefslogtreecommitdiff
path: root/libbb/loop.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* libbb/loop: fix compile failure (name collision)Denys Vlasenko2023-01-021-2/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: shrink del_loop()Denys Vlasenko2022-12-131-1/+1
| | | | | | | function old new delta del_loop 52 49 -3 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* loop: restore the correct return vaule of set_loop()Denys Vlasenko2022-12-131-4/+8
| | | | | | It is only used by mount's error path, though... Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* loop: optionally use ioctl(LOOP_CONFIGURE) to set up loopdevsDenys Vlasenko2022-12-131-9/+43
| | | | | | | | | | | | | | | | LOOP_CONFIGURE is added to Linux 5.8 function old new delta NO_LOOP_CONFIGURE (old code): set_loop 784 782 -2 LOOP_CONFIGURE: set_loop 784 653 -131 TRY_LOOP_CONFIGURE: set_loop 784 811 +27 Based on a patch by Xiaoming Ni <nixiaoming@huawei.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* loop: refactor: extract subfunction set_loopdev_params()Xiaoming Ni2022-12-131-39/+51
| | | | | | | | | | Extract subfunction set_loop_info() from set_loop() function old new delta set_loop 760 784 +24 Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* loop: simplify code of LOOP_SET_FD failureXiaoming Ni2022-12-121-7/+3
| | | | | | | | function old new delta set_loop 790 760 -30 Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* loop: refactor: extract subfunction get_next_free_loop()Xiaoming Ni2022-12-121-30/+26
| | | | | | | | | | | | | Extract subfunction get_next_free_loop() from set_loop() Also fix miss free(try) when stat(try) and mknod fail function old new delta set_loop 807 790 -17 Fixes: 3448914e8cc5 ("mount,losetup: use /dev/loop-control is it exists") Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* loop: fix a race when a free loop device is snatchedXiaoming Ni2022-11-151-1/+10
| | | | | | | | | | | When /dev/loop-control exists and *device is empty, the mount may fail if a concurrent mount is running. function old new delta set_loop 809 807 -2 Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* mount: if we race with other loop mount, we forget to close loop devDenys Vlasenko2020-12-171-1/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* mount: fix a race when a free loop device is snatched under us by another mount.Denys Vlasenko2020-12-171-65/+73
| | | | | | | function old new delta set_loop 850 809 -41 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* mount: support the sizelimit and offset option for loop devicesSteffen Trumtrar2020-10-011-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Starting with linux kernel v5.4 squashfs has a more strict parameter checking implemented. Unlike util-linux mount, busybox never supported the sizelimit option but simply forwards it to the kernel. Since v5.4 mounting will fail with squashfs: Unknown parameter 'sizelimit' Support the sizelimit parameter by setting it in the LOOP_SET_STATUS64 structure before handing it to the kernel. While at it also add support for the offset option, which currently will always be set to 0. function old new delta cut_out_ull_opt - 167 +167 singlemount 1230 1266 +36 set_loop 834 862 +28 losetup_main 479 483 +4 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 3/0 up/down: 235/0) Total: 235 bytes Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* mount,losetup: use /dev/loop-control is it existsDenys Vlasenko2019-06-091-6/+36
| | | | | | | | | | | function old new delta get_free_loop - 58 +58 set_loop 597 649 +52 losetup_main 482 476 -6 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/1 up/down: 110/-6) Total: 104 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* testsuite/mount.tests: fix false positiveDenys Vlasenko2018-06-281-0/+4
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* mount: create loop devices with LO_FLAGS_AUTOCLEAR flagDenys Vlasenko2017-03-161-16/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The "autolooped" mount (mount [-oloop] IMAGE /DIR/DIR) always creates AUTOCLEARed loopdevs, so that umounting drops them (and this does not require any code in the umount userspace). This happens since circa linux-2.6.25: commit 96c5865559cee0f9cbc5173f3c949f6ce3525581 Date: Wed Feb 6 01:36:27 2008 -0800 Subject: Allow auto-destruction of loop devices IOW: in this case, umount does not have to use -d to drop the loopdev. The explicit loop mount (mount /dev/loopN /DIR/DIR) does not do this. In this case, umount without -d should not drop loopdev. Unfortunately, bbox umount currently always implies -d, this probably needs fixing. function old new delta set_loop 537 597 +60 singlemount 1101 1138 +37 losetup_main 419 432 +13 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 110/0) Total: 110 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/loop: don't try to re-use existing loop deviceKevin Wallace2015-02-071-10/+1
| | | | | | | | | | | loopinfo.lo_file_name is not enough to uniquely identify a file on a system with multiple mount namespaces. We could conceivably change this to dedup on (lo_rdevice, lo_inode), but, as the comment above the deleted code notes, this whole approach of reusing devices is racy anyway, so it seems better to stop doing it entirely. Signed-off-by: Kevin Wallace <k@igneous.io> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb: if opening /dev/loopN returns ENXIO, don't try N++.Denys Vlasenko2014-01-211-6/+12
| | | | | | | function old new delta set_loop 639 635 -4 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* whitespace cleanup. no code changesDenys Vlasenko2013-01-141-3/+3
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* losetup: implement -r option. Closes 4033.Denys Vlasenko2011-09-121-4/+6
| | | | | | | | | | function old new delta packed_usage 28595 28633 +38 losetup_main 285 290 +5 singlemount 906 908 +2 set_loop 674 672 -2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* *: make GNU licensing statement forms more regularDenys Vlasenko2010-08-161-1/+1
| | | | | | | This change retains "or later" state! No licensing _changes_ here, only form is adjusted (article, space between "GPL" and "v2" and so on). Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* losetup: support /dev/loop10 and higher. closes bug 1627Denys Vlasenko2010-05-191-1/+1
| | | | | | | | function old new delta query_loop 91 95 +4 losetup_main 288 285 -3 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* loop: correct minor device number limitDenys Vlasenko2010-04-141-1/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* mount: add an optional capability to create new /dev/loopN as neededLauri Kasanen2010-04-141-2/+12
| | | | | Signed-off-by: Lauri Kasanen <curaga@operamail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/loop: comment out u32 hackDenys Vlasenko2010-03-181-1/+2
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/loop.c: move #include to its user, improve commentDenys Vlasenko2010-03-081-3/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/loop.c: use common fix_u32.h trickDenys Vlasenko2010-03-061-5/+1
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* libbb/loop.c: style and readability fixes, no code changesDenys Vlasenko2010-03-051-13/+18
| | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* remove some GNUisms. by Dan Fandrich (dan AT coneharvesters.com)Denys Vlasenko2009-09-061-1/+1
| | | | | | | | | | function old new delta logdirs_reopen 1310 1308 -2 read_line_input 4757 4753 -4 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-6) Total: -6 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* Patches to enable FreeBSD buildDenys Vlasenko2009-07-051-16/+23
| | | | | | | | | platform.h: fix wrong check for endianness, fix lchown aliasing to chown on uclibc. Code seems to not be affected in my testing. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* *: introduce and use FAST_FUNC: regparm on i386, otherwise no-onDenis Vlasenko2008-06-271-3/+3
| | | | | | | text data bss dec hex filename 808035 611 6868 815514 c719a busybox_old 804472 611 6868 811951 c63af busybox_unstripped
* mount: print errno on NFS error (again)Denis Vlasenko2007-08-031-3/+4
|
* loop device code: readability improvementDenis Vlasenko2007-04-191-10/+14
|
* strdup -> xstrdupDenis Vlasenko2007-01-191-1/+1
| | | | sed: de-obfuscate piece of code
* correct largefile support, add comments about it.Denis Vlasenko2006-10-081-1/+3
|
* attempt to regularize atoi mess.Denis Vlasenko2006-10-081-24/+36
|
* whitespace cleanupDenis Vlasenko2006-09-171-1/+1
|
* Remove bb_ prefixes from xfuncs.c (and a few other places), consolidateRob Landley2006-08-031-8/+1
| | | | | | | | | | things like xasprintf() into xfuncs.c, remove xprint_file_by_name() (it only had one user), clean up lots of #includes... General cleanup pass. What I've been doing for the last couple days. And it conflicts! I've removed httpd.c from this checkin due to somebody else touching that file. It builds for me. I have to catch a bus. (Now you know why I'm looking forward to Mercurial.)
* Cleaup read() and write() variants, plus a couple of new functions likeRob Landley2006-07-161-0/+1
| | | | xlseek and fdlength() for the new mkswap.
* Replace current verbose GPL stuff in libbb/*.c with one-line GPL boilerplate."Robert P. J. Day"2006-07-101-1/+0
|
* Whitespace. (Vim's auto-indent is kind of annoying at times, like "daytime"Rob Landley2006-06-251-1/+1
| | | | and "nighttime"...)
* Fix a possible race condition if two processes try to claim the same loopRob Landley2006-06-251-3/+4
| | | | | device at the same time. We should only CLR_FD if the set status fails, not if the SET_FD fails.
* Whitespace cleanup and minor tweak (return -ERRNO instead of ERRNO soRob Landley2006-03-181-13/+6
| | | | EPERM doesn't register as a successful read-only mount.
* with 2.4 kernel headers, lo_file_name is char, but with 2.6Eric Andersen2006-01-301-3/+3
| | | | | headers we get a u8 for lo_file_name, so always cast to (char *) when treating it as such.
* just whitespaceTim Riker2006-01-251-3/+3
|
* Close bug 644: loop incrementing twice, skipping ever other device.Rob Landley2006-01-221-1/+1
|
* Trying to losetup a device as a regular user shouldn't result in an endlessRob Landley2005-12-211-2/+3
| | | | loop, and the error messages should display correctly now.
* Fix losetup so that it A) actually works again, B) has much better errorRob Landley2005-11-291-14/+30
| | | | | | | | messages, C) can show the current association (if any) when called with only one argument. Update the documentation a lot too. Remind me to add a test suite for this thing. I think I've figured out how to handle root-only testsuites...
* - don't update copyright years. He might release it, but apparently will haveBernhard Reutner-Fischer2005-10-151-1/+1
| | | | to update the year himself.
* - an empty middle term in ?: violates ISO CBernhard Reutner-Fischer2005-10-151-31/+22
| | | | - use shorter boilerplate and use C89 style comments
* The check for EROFS was wrong. For example, if you try to mount a filesystemRob Landley2005-10-111-4/+3
| | | | | | appended to an executable that's being run (yes, I'm doing this) you get EPERM, but mounting readonly fixes it. Doing the fallback all the time shouldn't hurt, and is one less test.
* Major rewrite of mount, umount, losetup. Untangled lots of code, shrunkRob Landley2005-08-101-92/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | things down a bit, fixed a number of funky corner cases, added support for several new features (things like mount --move, mount --bind, lazy unounts, automatic detection of loop mounts, and so on). Probably broke several other things, but it's fixable. (Bang on it, tell me what doesn't work for you...) Note: you no longer need to say "-o loop". It does that for you when necessary. Still need to add "user mount" support, which involves making mount suid. Not too hard to do under the new infrastructure, just haven't done it yet... The previous code had the following notes, that belong in the version control comments: - * 3/21/1999 Charles P. Wright <cpwright@cpwright.com> - * searches through fstab when -a is passed - * will try mounting stuff with all fses when passed -t auto - * - * 1999-04-17 Dave Cinege...Rewrote -t auto. Fixed ro mtab. - * - * 1999-10-07 Erik Andersen <andersen@codepoet.org>. - * Rewrite of a lot of code. Removed mtab usage (I plan on - * putting it back as a compile-time option some time), - * major adjustments to option parsing, and some serious - * dieting all around. - * - * 1999-11-06 mtab support is back - andersee - * - * 2000-01-12 Ben Collins <bcollins@debian.org>, Borrowed utils-linux's - * mount to add loop support. - * - * 2000-04-30 Dave Cinege <dcinege@psychosis.com> - * Rewrote fstab while loop and lower mount section. Can now do - * single mounts from fstab. Can override fstab options for single - * mount. Common mount_one call for single mounts and 'all'. Fixed - * mtab updating and stale entries. Removed 'remount' default. - *