[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [PATCH] makedevs: make special node creation idempotent
From: Denys Vlasenko <vda.linux () googlemail ! com>
Date: 2016-11-27 22:29:47
Message-ID: CAK1hOcML774_xzX0Tynu0hofdjRLYxea0jGfPfdYd4e7RJxHAQ () mail ! gmail ! com
[Download RAW message or body]
On Sat, Nov 5, 2016 at 2:37 PM, Arnout Vandecappelle (Essensium/Mind)
<arnout@mind.be> 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
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic