[PATCH] was: mdev doesn't remove devices
Jason Schoon
floydpink at gmail.com
Mon Aug 28 21:21:29 UTC 2006
Since we're on the topic of mdev already, I have a patch I had to create
today that I thought I would run by the list.
I am using mdev with a mdev.conf to launch a script file in certain cases
(basically it enables hotplugging on USB flash devices for me).
In that script, I happened to add a line that sends its output to /dev/null
(i.e. 2>/dev/null). Well, this just so happens to create an empty file,
which then causes mknod of /dev/null to fail with an "already exists."
So, my solution was to either make sure that my hotplug script never, ever
talks to a dev file (a poor assumption I feel), or to patch mdev to check if
something is a regular file, and delete it. Attached is a patch that
accomplishes just that. If someone else thinks that is a sane thing to do,
please apply.
--- busybox/util-linux/mdev.c 2006-08-28 15:15:47.000000000 -0500
+++ busybox/util-linux/mdev.c.mine 2006-08-28 15:15:35.000000000 -0500
@@ -165,6 +165,9 @@
umask(0);
if (!delete) {
+ struct stat st;
+ if (!lstat(device_name, &st) && S_ISREG(st.st_mode))
unlink(device_name);
+
if (sscanf(temp, "%d:%d", &major, &minor) != 2) return;
if (mknod(device_name, mode | type, makedev(major, minor)) && errno
!= EEXIST)
bb_perror_msg_and_die("mknod %s failed", device_name);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.busybox.net/pipermail/busybox/attachments/20060828/b3c74316/attachment-0001.htm
-------------- next part --------------
A non-text attachment was scrubbed...
Name: busybox_mdev_remove_regular.patch
Type: text/x-patch
Size: 485 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20060828/b3c74316/attachment-0002.bin
More information about the busybox
mailing list