On Sat, Nov 5, 2016 at 2:37 PM, Arnout Vandecappelle (Essensium/Mind) <[email protected]> wrote: > When makedevs is called for a second time with the same device file, it > will fail because the files already exist and mknod() gives -EEXISTS. > > To avoid this, check if the file already exists and if so, if it is of > the right type. The chmod and chown changes are still done.
Another applet, mdev, deals with this problem by simply checking EEXIST and if it happens, ignore it. Sure, this is suboptimal (this way the existing object may be not a device node at all), but usually only root can create entries in /dev, so in practice this is okayish. And it's small: function old new delta makedevs_main 246 256 +10 > function old new delta > makedevs_main 1086 1201 +115 > .rodata 138731 138832 +101 > ------------------------------------------------------------------------------ > (add/remove: 0/0 grow/shrink: 2/0 up/down: 216/0) Total: 216 bytes > text data bss dec hex filename > 856021 15958 1968 873947 d55db busybox_old > 856237 15958 1968 874163 d56b3 busybox_unstripped I fixed it in git by adding this errno check: mknod(...) != 0 && errno != EEXIST _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
