Commit Graph

117 Commits

Author SHA1 Message Date
Denys Vlasenko
72089cf6b4 config: deindent all help texts
Those two spaces after tab have no effect, and always a nuisance when editing.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-21 09:50:55 +02:00
Denys Vlasenko
4eed2c6c50 Update menuconfig items with approximate applet sizes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-18 22:01:24 +02:00
Denys Vlasenko
a98db793cf Revert "umount: make -d always active, add -D to suppress it"
This reverts commit 86a03bee1d.

Since now our "mount -oloop" creates AUTOCLEARed loopdevs, we no longer
need our umount to destroy loopdevs to match the usual util-linux behaviour.

Now this revert fixes another, opposite bug: "explicit" mount /dev/loopN
and then umount must not drop loopdevs!

User complaint is as follows:

It seems LOOP_CLR_FD called on a loop-*partition* removes the mapping of
the whole *device* - which results in the following:

root@LEDE:/# loop=$(losetup -f)
root@LEDE:/# echo ${loop}
/dev/loop2
root@LEDE:/# losetup ${loop} /IMAGE
root@LEDE:/# ls -l ${loop}*
brw-------  1 root root     7,   2 Mar  6 20:09 /dev/loop2
root@LEDE:/# partprobe ${loop}
root@LEDE:/# ls -l ${loop}*
brw-------  1 root  root    7,   2 Mar  6 20:09 /dev/loop2
brw-------  1 root  root  259,   8 Mar  6 21:59 /dev/loop2p1
brw-------  1 root  root  259,   9 Mar  6 21:59 /dev/loop2p2
brw-------  1 root  root  259,  10 Mar  6 21:59 /dev/loop2p3
brw-------  1 root  root  259,  11 Mar  6 21:59 /dev/loop2p4
brw-------  1 root  root  259,  12 Mar  6 21:59 /dev/loop2p5
brw-------  1 root  root  259,  13 Mar  6 21:59 /dev/loop2p6
brw-------  1 root  root  259,  14 Mar  6 21:59 /dev/loop2p7
brw-------  1 root  root  259,  15 Mar  6 21:59 /dev/loop2p8
root@LEDE:/# mount ${loop}p8 /MOUNT       # mount loop partition
root@LEDE:/# losetup -a | grep $loop      # loop dev mapping still there
/dev/loop2: 0 /mnt/IMAGE
root@LEDE:/# strace umount /MOUNT 2> /log # unmount loop partition
root@LEDE:/# losetup -a | grep ${loop}    # loop device mapping is gone
root@LEDE:/# grep -i loop /log
open("/dev/loop2p7", O_RDONLY|O_LARGEFILE) = 3
ioctl(3, LOOP_CLR_FD)                   = 0
root@LEDE:/#

The strace was done to figure out, if maybe umount wrongly ioctl()'s the
parent device instead of the partition - it doesn't.

I already wasn't a fan of umount implicitly removing the mapping in the
first place (as I usually setup and release loop devices with `losetup`
and scripts needed to call umount differently in order to work and
outside busybox).

However taking above (kernel-)behaviour into account - umount calling
ioctl(LOOP_CLR_FD) unconditionally potentially causes some nasty side
effects

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-03-16 17:51:06 +01:00
Denys Vlasenko
35b54a3c24 libbb: match_fstype() is unreadable in the extreme, fixing it
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-30 00:45:05 +01:00
Denys Vlasenko
dd898c9f33 Convert all util-linux/* applets to "new style" applet definitions
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-11-23 11:46:32 +01:00
Denys Vlasenko
9de2e5a222 *: hopefully all setup_common_bufsiz() are in place
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-21 18:38:51 +02:00
Denys Vlasenko
e6a2f4cc5a libbb: make bb_common_bufsiz1 1 kbyte, add capability to use bss tail for it
The config item is FEATURE_USE_BSS_TAIL. When it is off (default):

function                                             old     new   delta
read_config                                          210     228     +18
doCommands                                          2279    2294     +15
ipneigh_list_or_flush                                763     772      +9
ipaddr_list_or_flush                                1256    1261      +5
display_process_list                                1301    1306      +5
conspy_main                                         1378    1383      +5
do_lzo_compress                                      352     355      +3
do_lzo_decompress                                    565     567      +2
push                                                  46      44      -2
inetd_main                                          2136    2134      -2
uevent_main                                          421     418      -3
addLines                                              97      92      -5
bb_common_bufsiz1                                   8193    1024   -7169
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 8/5 up/down: 62/-7181)        Total: -7119 bytes
   text	   data	    bss	    dec	    hex	filename
 829850	   4086	   9080	 843016	  cdd08	busybox_old
 829901	   4086	   1904	 835891	  cc133	busybox_unstripped

FEATURE_USE_BSS_TAIL=y:

read_config                                          210     228     +18
doCommands                                          2279    2294     +15
ipneigh_list_or_flush                                763     772      +9
ipaddr_list_or_flush                                1256    1261      +5
display_process_list                                1301    1306      +5
conspy_main                                         1378    1383      +5
do_lzo_compress                                      352     355      +3
do_lzo_decompress                                    565     567      +2
inetd_main                                          2136    2134      -2
bb_common_bufsiz1                                   8193       -   -8193
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 8/1 up/down: 62/-8195)        Total: -8133 bytes
   text	   data	    bss	    dec	    hex	filename
 829850	   4086	   9080	 843016	  cdd08	busybox_old
 829911	   4086	    880	 834877	  cbd3d	busybox_unstripped

FIXME: setup_common_bufsiz() calls are missing.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-21 17:39:11 +02:00
Denys Vlasenko
31c984dd69 umount: build fix for older glibc
Based on a patch by Veli-Pekka Peltola <veli-pekka.peltola@ray.fi>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-03-28 22:23:33 +02:00
Denys Vlasenko
ab3964db4e libbb: introduce kernel-style BUILD_BUG_ON()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-13 14:50:20 +02:00
Denys Vlasenko
c919d561ad umount: always use umount2 syscall with specified flags
Make umount -f more compatible with util-linux 2.22.2.

Before:
  * 'umount -f': calls umount syscall,
        if it fails calls umount2 with 'MNT_FORCE'
  * 'mount -f -l': calls umount syscall,
        if it fails calls umount2 with 'MNT_LAZY'. 'MNT_FORCE' dropped
After:
  * 'umount -f': calls umount2 syscall with 'MNT_FORCE'
  * 'mount -f -l': calls umount2 syscall with 'MNT_LAZY' and 'MNT_FORCE'

function                                             old     new   delta
umount                                                45       -     -45
umount_main                                          610     555     -55

Signed-off-by: Anton Bondarenko <anton.bondarenko@axis.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-01 18:50:06 +02:00
Denys Vlasenko
86a03bee1d umount: make -d always active, add -D to suppress it
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-17 13:07:28 +02:00
Denys Vlasenko
66426760be *: remove "Options:" string from help texts
function                                             old     new   delta
packed_usage                                       28706   28623     -83

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-05 03:58:28 +02:00
Pere Orga
5bc8c005a8 move remaining help text from include/usage.src.h
Signed-off-by: Pere Orga <gotrunks@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-04-11 03:29:49 +02:00
Rob Landley
2658888c78 umount: cleanup and code shrink
Signed-off-by: Rob Landley <rob@landley.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-11-01 00:43:34 +01:00
Denys Vlasenko
ba04337e1f umount: I forgot to change another PATH_MAX to 4096
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-10-24 13:28:45 +02:00
Denys Vlasenko
07b1c6ecc0 umount: do not (ab)use PATH_MAX as mntent buffer size
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-10-24 03:00:57 +02:00
Denys Vlasenko
0ef64bdb40 *: make GNU licensing statement forms more regular
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>
2010-08-16 20:14:46 +02:00
Jérémie Koenig
fbedacfc8c Hurd compat fixes. Mostly dealing with absent PATH_MAX
Signed-off-by: Jérémie Koenig <jk@jk.fr.eu.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-26 19:08:53 +01:00
Denys Vlasenko
da49f58524 move libc related stuff out of platform.h
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-08 02:58:38 +02:00
Denis Vlasenko
7aaedcf21e mount: support "-O option"; stop trying to mount swap partitions
function                                             old     new   delta
mount_main                                           975    1152    +177
umount_main                                          640     636      -4
packed_usage                                       25666   25662      -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 177/-8)            Total: 169 bytes
2009-03-14 22:57:20 +00:00
Denis Vlasenko
9604e1b8fc modprobe: emit "can't open 'modules.dep': (errno)" instead of "module not found"
*: s/can't open %s/can't open '%s'/, it's better to use same string.

function                                             old     new   delta
do_modprobe                                          588     601     +13
config_file_action                                   339     345      +6
modprobe_main                                        565     570      +5
unable_to_open                                        14      16      +2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 26/0)               Total: 26 bytes
   text    data     bss     dec     hex filename
 816800     476    7892  825168   c9750 busybox_old
 816812     476    7892  825180   c975c busybox_unstripped
2009-03-03 18:47:56 +00:00
Bernhard Reutner-Fischer
a53de7f7c2 - fix spelling 2008-07-21 13:46:54 +00:00
Denis Vlasenko
a60f84ebf0 *: rename ATTRIBUTE_XXX to just XXX. 2008-07-05 09:18:54 +00:00
Denis Vlasenko
a0e17f7df6 [u]mount: add/update dietlibc build fix 2008-05-26 01:19:53 +00:00
Denis Vlasenko
c93b162248 patch: shrink by Pascal Bellard <pascal.bellard AT ads-lu.com> (-80 bytes)
*: removal of #include <getopt.h>
2008-03-23 22:55:25 +00:00
Denis Vlasenko
68404f13d4 *: add -Wunused-parameter; fix resulting breakage
function                                             old     new   delta
procps_scan                                         1265    1298     +33
aliascmd                                             278     283      +5
parse_file_cmd                                       116     120      +4
dname_enc                                            373     377      +4
setcmd                                                90      93      +3
execcmd                                               57      60      +3
count_lines                                           72      74      +2
process_command_subs                                 340     339      -1
test_main                                            409     407      -2
mknod_main                                           179     177      -2
handle_incoming_and_exit                            2653    2651      -2
argstr                                              1312    1310      -2
shiftcmd                                             131     128      -3
exitcmd                                               46      43      -3
dotcmd                                               297     294      -3
breakcmd                                              86      83      -3
evalpipe                                             353     349      -4
evalcommand                                         1180    1176      -4
evalcmd                                              109     105      -4
send_tree                                            374     369      -5
mkfifo_main                                           82      77      -5
evalsubshell                                         152     147      -5
typecmd                                               75      69      -6
letcmd                                                61      55      -6
add_cmd                                             1190    1183      -7
main                                                 891     883      -8
ash_main                                            1415    1407      -8
parse_stream                                        1377    1367     -10
alloc_procps_scan                                     55       -     -55
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 7/21 up/down: 54/-148)          Total: -94 bytes
   text    data     bss     dec     hex filename
 797195     658    7428  805281   c49a1 busybox_old
 797101     658    7428  805187   c4943 busybox_unstripped
2008-03-17 09:00:54 +00:00
Denis Vlasenko
b2e578a1f2 umount: instead of non-standard -D, use -d with opposite meaning
(closes bug 1604)
umount: do not try to free loop device or erase mtab if remounted ro
umount: do not complain several times about the same mountpoint

function                                             old     new   delta
umount_main                                          646     638      -8
packed_usage                                       23662   23652     -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-18)             Total: -18 bytes
2008-02-14 12:00:21 +00:00
Denis Vlasenko
ef36c04ccf umount: fix fallout from stack reduction change 2007-12-24 12:11:57 +00:00
Denis Vlasenko
5cc6459c46 umount: stop using excessive aounts of stack. Surprisingly,
code shrank a lot too

function                                             old     new   delta
umount_main                                          751     640    -111
2007-11-10 01:45:03 +00:00
Denis Vlasenko
b4f608d8e0 readlink: realpath requires PATH_MAX, bb_common_bufsiz1 can be too small
umount: don't actually need char[2 * PATH_MAX] for realpath
2007-11-10 01:31:19 +00:00
Denis Vlasenko
9b49a5ed85 add -fvisibility=hidden to CC flags, mark XXX_main functions
EXTERNALLY_VISIBLE. 5% size reduction of libbusybox.so
2007-10-11 10:05:36 +00:00
Denis Vlasenko
fdf9060aa3 umount: support (by ignoring) -i; style fixes 2007-09-06 16:57:05 +00:00
Denis Vlasenko
fe7cd642b0 don't pass argc in getopt32, it's superfluous
(add/remove: 0/0 grow/shrink: 12/131 up/down: 91/-727) Total: -636 bytes
   text    data     bss     dec     hex filename
 773469    1058   11092  785619   bfcd3 busybox_old
 772644    1058   11092  784794   bf99a busybox_unstripped
2007-08-18 15:32:12 +00:00
Denis Vlasenko
b6adbf1be2 usage.c: remove reference to busybox.h
*: s/include "busybox.h"/include "libbb.h"
2007-05-26 19:00:18 +00:00
Denis Vlasenko
bf295dd5b6 [u]mount: extend -t option (Roy Marples <uberlord@gentoo.org>) 2007-04-05 21:57:47 +00:00
Denis Vlasenko
06af216528 suppress warnings about easch <applet>_main() having
no preceding prototype
2007-02-03 17:28:39 +00:00
Denis Vlasenko
1119972f91 umount: umount -a shouldn't stop on first failure 2006-11-12 17:23:45 +00:00
Denis Vlasenko
67b23e6043 getopt_ulflags -> getopt32.
It is impossible to formulate sane ABI based on
size of ulong because it can be 32-bit or 64-bit.
Basically it means that you cannot portably use
more that 32 option chars in one call anyway...
Make it explicit.
2006-10-03 21:00:06 +00:00
Rob Landley
e9a7a6212b Change license statements (and clean up headers) on some of the files that
Erik or I are primary copyright holders on.
2006-09-22 02:52:41 +00:00
Denis Vlasenko
9213a9e0f2 whitespace cleanup 2006-09-17 16:28:10 +00:00
Denis Vlasenko
af9854b81a umount: do not try to close FILE* which is NULL. 2006-09-14 16:40:46 +00:00
Rob Landley
4470b74e29 The kernel can't handle umount /dev/hdc, we have to do it through mtab,
except that we still have to work when there is no mtab.

Oh, and while we're at it, take advantage of the fact that modern processors
avoid branches via conditional assignment where possible.  ("x = a ? b : c;"
turns into "x = c; if (a) x = b;" because that way there's no branch to
potentially mispredict and thus never a bubble in the pipeline.  The if(a)
turns into an assembly test followed by a conditional assignment (rather
than a conditional jump).)  So since the compiler is going to do that _anyway_,
we might as well take advantage of it to produce a slightly smaller binary.

So there.
2006-08-17 19:07:20 +00:00
Rob Landley
7478804b78 Fix umount so loop device disassociation hopefully doesn't screw up errno on
a failed mount.  And while I'm at it, legacy mdev removal was only being done
in the _failure_ case?  That can't be right.  Plus minor header cleanups
and an option parsing tweak.
2006-08-03 17:54:45 +00:00
Rob Landley
d921b2ecc0 Remove bb_ prefixes from xfuncs.c (and a few other places), consolidate
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.)
2006-08-03 15:41:12 +00:00
Rob Landley
22d26fc6ae Patch from Yann Morin to put BLKGETSIZE64 in platform.h had rather a lot of
fallout due to the #include <sys/mount.h>.  Removed that #include from various
applets and fixed up those that were unhappy when that #include was made
because they'd block copied stuff out of it.  (Sigh.)
2006-06-15 15:49:36 +00:00
Rob Landley
5a57821565 Bug fix: umount wasn't detaching loop devices unless mtab support was enabled.
Made some whitespace cleanups while I was there.
2006-03-17 03:30:05 +00:00
Rob Landley
dfba741457 Robert P. Day removed 8 gazillion occurrences of "extern" on function
definitions.  (That should only be on prototypes.)
2006-03-06 20:47:33 +00:00
Rob Landley
cc6d8d30ec Fix umount so it works if there's no /etc/mtab or /proc/mounts, make
umount -a into a CONFIG_FEATURE (why not?), and zap the now obsolete
defconfig file (which was supposed to be part of the previous checkin).
2006-02-08 20:06:57 +00:00
"Vladimir N. Oleynik"
54cb5c6af3 better check usage with options, correct show problem error message, indent 2005-10-10 12:17:33 +00:00
Rob Landley
16722554bf Tito switched option parsing over to switch umount over to bb_getopt_ulflags(). 2005-09-24 22:41:08 +00:00