linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] get_netlink_msg: unable to receive kernel netlink message:
@ 2007-01-30  9:16 Matthias Schwarzott
  2007-01-31  9:24 ` [PATCH] get_netlink_msg: unable to receive kernel netlink Matthias Schwarzott
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Matthias Schwarzott @ 2007-01-30  9:16 UTC (permalink / raw)
  To: linux-hotplug

[-- 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-03-13 21:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-30  9:16 [PATCH] get_netlink_msg: unable to receive kernel netlink message: Matthias Schwarzott
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).