aboutsummaryrefslogtreecommitdiff
path: root/util-linux/mdev.c
AgeCommit message (Collapse)Author
2019-06-03libbb: move netlink socket binding to the utility functionDenys Vlasenko
function old new delta create_and_bind_to_netlink - 134 +134 ifplugd_main 1117 1052 -65 uevent_main 399 306 -93 mdev_main 314 215 -99 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/3 up/down: 134/-257) Total: -123 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-03mdev: add support to run as daemonJan Klötzke
Adds the -d option to run mdev in daemon mode handling hotplug events from the kernel like udev. If the system generates many hotplug events this mode of operation will consume less resources than registering mdev as hotplug helper or using the uevent applet. function old new delta daemon_loop - 152 +152 initial_scan - 127 +127 open_mdev_log - 85 +85 mdev_main 255 314 +59 packed_usage 33284 33316 +32 process_action 1051 992 -59 ------------------------------------------------------------------------------ (add/remove: 3/0 grow/shrink: 2/1 up/down: 455/-59) Total: 396 bytes Signed-off-by: Jan Klötzke <jan@kloetzke.net> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-03mdev: use option parser helperJan Klötzke
function old new delta process_action - 1051 +1051 mdev_main 1324 255 -1069 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/1 up/down: 1051/-1069) Total: -18 bytes Signed-off-by: Jan Klötzke <jan@kloetzke.net> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-06-03mdev: move action processing into separate functionsJan Klötzke
This purely moves code from main() to separate functions for better extensibility. Signed-off-by: Jan Klötzke <jan@kloetzke.net> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-28config: update size informationDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-12-08mdev: suppress aliasing warningDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-09-18regularize format of source file headers, no code changesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-27config: trim/improve item names and help texts, take 2Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-21config: deindent all help textsDenys Vlasenko
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-18Update menuconfig items with approximate applet sizesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-07mdev: create devices from /sys/devDenys Vlasenko
Currently some new devices that have a bus but no class will be missed by mdev coldplug device creation after boot. This happens because mdev recursively searches /sys/class which will by definition only find class devices. Some important devices such as iio and gpiochip does not have a class. But users will need them. This switches from using /sys/class as the place to look for devices to create to using /sys/dev where all char and block devices are listed. The subsystem lookup code that provide the G.subsystem environment variable is changed from using the directory name of the class device to instead dereference the "subsystem" symlink for the device, and look at the last element of the path of the symlink for the subsystem, which will work with class devices and bus devices alike. (The new bus-only devices only symlink to the /sys/bus/* hierarchy.) We delete the legacy kernel v2.6.2x /sys/block device path code as part of this change. It's too old to be kept alive. Tested on kernel v4.6-rc2 with a bunch of devices, including some IIO and gpiochip devices. With a print inserted before make_device() the log looks like so: Create device from "/sys/dev/char/1:1", subsystem "mem" Create device from "/sys/dev/char/1:2", subsystem "mem" Create device from "/sys/dev/char/1:3", subsystem "mem" Create device from "/sys/dev/char/1:5", subsystem "mem" (...) Create device from "/sys/dev/block/179:56", subsystem "block" Create device from "/sys/dev/block/179:64", subsystem "block" function old new delta mdev_main 1388 1346 -42 dirAction 134 14 -120 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-162) Total: -162 bytes Cc: Isaac Dunham <ibid.ag@gmail.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-21*: add most of the required setup_common_bufsiz() callsDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-21libbb: make bb_common_bufsiz1 1 kbyte, add capability to use bss tail for itDenys Vlasenko
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>
2015-10-19libbb: get_uidgid() always called with allow_numeric=1Denys Vlasenko
function old new delta xget_uidgid 30 25 -5 make_device 2188 2183 -5 main 797 792 -5 get_uidgid 240 225 -15 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-07libbb: more compact API for bb_parse_mode()Denys Vlasenko
function old new delta make_device 2182 2188 +6 parse_command 1440 1443 +3 parse_params 1497 1499 +2 install_main 773 769 -4 mkdir_main 168 160 -8 getoptscmd 641 632 -9 builtin_umask 158 147 -11 bb_parse_mode 431 410 -21 umaskcmd 286 258 -28 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/6 up/down: 11/-81) Total: -70 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-19libbb: add a function to make a copy of a region of memoryRon Yorston
Introduce a library routine to package the idiom: p = xmalloc(b, n); memcpy(p, b, n); and use it where possible. The example in traceroute used xzalloc but it didn't need to. function old new delta xmemdup - 32 +32 last_main 834 826 -8 make_device 2321 2311 -10 common_traceroute_main 3698 3685 -13 readtoken1 3182 3168 -14 procps_scan 1222 1206 -16 forkchild 655 638 -17 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/6 up/down: 32/-78) Total: -46 bytes Signed-off-by: Ron Yorston <rmy@frippery.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-04-19mdev: if a "future" mdev.seq is seen, do not overwrite it with oursDenys Vlasenko
This was seen to happen if two mdevs are run in parallel, mdev.seq is empty, and the "newer" one manages to write it first. function old new delta mdev_main 1366 1388 +22 atoll - 20 +20 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-04-19mdev: improve loggingDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-03-12libbb: introduce and use is_prefixed_with()Denys Vlasenko
function old new delta is_prefixed_with - 18 +18 complete_username 78 77 -1 man_main 737 735 -2 fsck_device 429 427 -2 unpack_ar_archive 80 76 -4 strip_unsafe_prefix 105 101 -4 singlemount 1054 1050 -4 rtc_adjtime_is_utc 90 86 -4 resolve_mount_spec 88 84 -4 parse_one_line 1029 1025 -4 parse_conf 1460 1456 -4 may_wakeup 83 79 -4 loadkmap_main 219 215 -4 get_irqs_from_stat 103 99 -4 get_header_cpio 913 909 -4 findfs_main 79 75 -4 fbsplash_main 1230 1226 -4 load_crontab 776 771 -5 expand_vars_to_list 1151 1146 -5 date_main 881 876 -5 skip_dev_pfx 30 24 -6 make_device 2199 2193 -6 complete_cmd_dir_file 773 767 -6 run_applet_and_exit 715 708 -7 uudecode_main 321 313 -8 pwdx_main 197 189 -8 execute 568 560 -8 i2cdetect_main 1186 1176 -10 procps_scan 1242 1230 -12 procps_read_smaps 1017 1005 -12 process_module 746 734 -12 patch_main 1903 1891 -12 nfsmount 3572 3560 -12 stack_machine 126 112 -14 process_timer_stats 449 435 -14 match_fstype 111 97 -14 do_ipaddr 1344 1330 -14 open_list_and_close 359 343 -16 get_header_tar 1795 1779 -16 prepend_new_eth_table 340 323 -17 fsck_main 1811 1794 -17 find_iface_state 56 38 -18 dnsd_main 1321 1303 -18 base_device 179 158 -21 find_keyword 104 82 -22 handle_incoming_and_exit 2785 2762 -23 parse_and_put_prompt 774 746 -28 modinfo 347 317 -30 find_action 204 171 -33 update_passwd 1470 1436 -34 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/49 up/down: 18/-540) Total: -522 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-09-08mdev: treat zero-length /dev/mdev.seq the same as "\n" one. Closes 7334Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-05-13mdev: use $DEVNAME in uevent sysfs file for device node nameNikolaus Voss
516530c932bd17d87c9eb4347a490be051e495f4 uses $DEVNAME variable for device node name. This is fine, but only works for hotplugging, "mdev -s" will behave differently when DEVNAME and basename(path) differ. This patch extracts the DEVNAME from the uevent sysfs file in make_device(), thus works for hot- and coldplugging; so using the environment DEVNAME on hotplug events is no longer necessary. Signed-off-by: Nikolaus Voss <n.voss@weinmann.de> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-04-02mdev: call index_in_strings on $ACTION only after we checked it for NULLDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-17mdev: fix build failureDenys Vlasenko
The error was "error: 'struct globals' has no member named 'parser'" Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-27mdev: improve $SEQ handling; improve debug loggingDenys Vlasenko
Sequential run of concurrent mdev's was too simplistic: they waited for /dev/mdev.seq to match. This could sometimes cause cumulative loss of time on the order of a second. Added SIGCHLD signaling from exiting mdev to all other mdev's. Added debugging required to see that code actually works as intended. Example of /dev/mdev.log (with "woken up" elevated from dbg lvl 3 to 2): mdev[1023]: first seq written ^^^^ seq, not pid mdev[1023]: 35.022395 ACTION:add SUBSYSTEM:module DEVNAME:(null) DEVPATH:/module/lib80211 mdev[1023]: rule matched, line -1 ^^^^^^^ means "default rule" mdev[1023]: 35.022676 exiting ^^^^^^^^^ second,usec timestamp mdev[1024]: 35.069691 ACTION:add SUBSYSTEM:vc DEVNAME:vcs9 DEVPATH:/devices/virtual/vc/vcs9 mdev[1024]: dev 7,9 mdev[1025]: 35.069889 waiting for '1024' mdev[1026]: 35.069946 waiting for '1024' mdev[1027]: 35.070151 waiting for '1024' mdev[1024]: rule matched, line -1 mdev[1024]: mknod vcs9 (7,9) 20660 0:0 mdev[1024]: 35.070346 exiting mdev[1025]: woken up mdev[1026]: woken up mdev[1025]: 35.071213 ACTION:add SUBSYSTEM:vc DEVNAME:vcsa9 DEVPATH:/devices/virtual/vc/vcsa9 ^^^^^^^^^ took only a millisecond to start running after prev mdev exited mdev[1025]: dev 7,137 mdev[1027]: woken up mdev[1025]: rule matched, line -1 mdev[1025]: mknod vcsa9 (7,137) 20660 0:0 mdev[1025]: 35.072109 exiting function old new delta mdev_main 849 1372 +523 curtime - 59 +59 dirAction 87 134 +47 static.ts - 8 +8 keywords 19 12 -7 make_device 2189 2119 -70 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-26mdev: add environment variable matchDenys Vlasenko
function old new delta make_device 1998 2189 +191 clean_up_cur_rule 61 96 +35 dirAction 75 87 +12 mdev_main 838 849 +11 packed_usage 29272 29273 +1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 5/0 up/down: 250/0) Total: 250 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-04mdev: chdir back to /dev after trying to read firmwareDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-30mdev: extend debug logging outputDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-21mdev: fix mode of dir1 in =dir1/dir2/file ruleDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-19mdev: tell kernel that we didn't find the firmwareChristoph Lohmann
function old new delta mdev_main 797 801 +4 Signed-off-by: Christoph Lohmann <20h@r-36.net> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-19Merge branch 'master' of git+ssh://vda@busybox.net/var/lib/git/busyboxDenys Vlasenko
2012-05-18mdev: remove undocumented subsystem/devname matching hackDenys Vlasenko
It was colliding with matching of devnames with slashes. We need a more generic way to examine env.vars in rules anyway. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-18mdev: when found, print major,minor into mdev.logDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-18tweak help textDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-18mdev: add support for $DEVNAME and /dev/mdev.log debug aidDenys Vlasenko
function old new delta make_device 1843 2083 +240 mdev_main 712 804 +92 packed_usage 29236 29251 +15 keywords 288 19 -269 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/1 up/down: 347/-269) Total: 78 bytes text data bss dec hex filename 887506 497 7584 895587 daa63 busybox_old 887982 497 7584 896063 dac3f busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-21mdev: fix mode of creatred node if config file support is not configuredDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-02-06mdev: add a comment. no code changesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-01-30mdev: fix wrong sizeofJavier Viguera
Signed-off-by: Javier Viguera <javier.viguera@digi.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-01-11mdev: do not treat non-leading '#' chars as start of comment. Closes 4676Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-22mdev: trim overlong comments. No code changesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-22mdev: don't reparse rules on -sDenys Vlasenko
function old new delta make_device 1648 1843 +195 clean_up_cur_rule - 61 +61 make_default_cur_rule - 41 +41 mdev_main 690 712 +22 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 2/0 up/down: 319/0) Total: 319 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-21add INIT_G()'s. No code changes.Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-19mdev: expand --help so that it's actually useful.Denys Vlasenko
function old new delta packed_usage 28634 28822 +188 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-16simplify parsing of /etc/busybox.confDenys Vlasenko
function old new delta parse_config_file 799 667 -132 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-04-11move remaining help text from include/usage.src.hPere Orga
Signed-off-by: Pere Orga <gotrunks@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-16*: make GNU licensing statement forms more regularDenys Vlasenko
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-16mdev: fix non-working device deletion, add a test for thatDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-06-24*: introduce and use bb_unsetenv_and_freeDenys Vlasenko
function old new delta bb_unsetenv_and_free - 17 +17 tcpudpsvd_main 1819 1810 -9 safe_setenv 58 47 -11 udhcp_run_script 630 616 -14 make_device 1683 1663 -20 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/4 up/down: 17/-54) Total: -37 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-04-02mdev: add "!" syntax supportDenys Vlasenko
Based on the patch by Steve Bennett <steveb@workware.net.au> function old new delta make_device 1640 1673 +33 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-23*: merge some common stringsDenys Vlasenko
text data bss dec hexfilename 838650 8009 0 846659 ceb43busybox_old 838519 8009 0 846528 ceac0busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-03-16mdev: fix a trivial SEGVDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>