From: Matthias Schwarzott <zzam@gentoo.org>
To: linux-hotplug@vger.kernel.org
Subject: [PATCH] get_netlink_msg: unable to receive kernel netlink message:
Date: Tue, 30 Jan 2007 09:16:50 +0000 [thread overview]
Message-ID: <200701301016.50139.zzam@gentoo.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 1528 bytes --]
Hi there!
Had this Bug-report floating around since some time:
http://bugs.gentoo.org/show_bug.cgi?id=151414
It occurs, when root-partition has no /dev/console, meaning that kernel could
not open it, and such udevd is started without open filedescriptors 0 1 2.
In that case udevd openes its sockets (netlink and control).
They get fds between 0 and 2.
Later duping /dev/null to 0 1 2 closes the sockets and replaces them
with /dev/null.
Communicating over socket in main-look then gets that error-messages.
One possible solution is:
Checking at startup of udevd that fd 0 1 2 are open, and if not, connect them
to /dev/null.
A. For example by explictely checking each fd and dup /dev/null (attached
patch).
B. By opening /dev/null until open returns 2 meaning fds 0 1 2 are open.
C. Remembering which fd is open, and later only dup/close the ones that were
open.
But in case C one perhaps has to conditionalize each printf(...) and
fprintf(2,...) as the sockets are sure not happy about text-messages.
For gentoo-startup, that does work without /dev/console, only udevd has
problems there, we solved it for now this way in udev-startup script (until
udevd copes with this itself):
# check if /dev/console exists outside tmpfs
[[ -c /dev/console ]] ; local need_redirect=$?
....
mount /dev
....
mknod /dev/null
mknod /dev/console
...
if [[ ${need_redirect} == 1 ]]; then
/sbin/udevd --daemon </dev/console >/dev/console 2>/dev/console
else
/sbin/udevd --daemon
fi
Matthias
--
Matthias Schwarzott (zzam)
[-- Attachment #2: udev-104-std_fd_dup_fix.patch --]
[-- Type: text/x-diff, Size: 596 bytes --]
--- udev-104-orig/udevd.c 2007-01-15 14:56:11.000000000 +0100
+++ udev-104/udevd.c 2007-01-29 13:47:56.000000000 +0100
@@ -948,6 +948,21 @@
int rc = 1;
int maxfd;
+ fd = open("/dev/null", O_RDWR);
+
+ if (fd < 0) {
+ fprintf(stderr, "cannot open /dev/null\n");
+ err("cannot open /dev/null");
+ }
+ if (read(STDIN_FILENO, 0, 0) < 0)
+ dup2(fd, STDIN_FILENO);
+ if (write(STDOUT_FILENO, 0, 0) < 0)
+ dup2(fd, STDOUT_FILENO);
+ if (write(STDERR_FILENO, 0, 0) < 0)
+ dup2(fd, STDERR_FILENO);
+ if (fd > 2)
+ close(fd);
+
logging_init("udevd");
udev_config_init();
selinux_init();
[-- Attachment #3: Type: text/plain, Size: 347 bytes --]
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
[-- Attachment #4: Type: text/plain, Size: 226 bytes --]
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
next reply other threads:[~2007-01-30 9:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-30 9:16 Matthias Schwarzott [this message]
2007-01-31 9:24 ` [PATCH] get_netlink_msg: unable to receive kernel netlink Matthias Schwarzott
2007-03-09 14:09 ` Matthias Schwarzott
2007-03-10 21:15 ` Kay Sievers
2007-03-13 19:29 ` Matthias Schwarzott
2007-03-13 21:12 ` Kay Sievers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200701301016.50139.zzam@gentoo.org \
--to=zzam@gentoo.org \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.