Re: [PATCH] Console: fall back to /dev/null when no console is availlable

From: Jörn Engel
Date: Wed Oct 06 2004 - 14:24:29 EST


On Wed, 6 October 2004 11:18:36 -0700, Greg KH wrote:
>
> Care to send a patch to do this?

Below. Never tried udev and/or hotplug, never even looked at the code
yet. So you better don't trust me.

Jörn

--
A defeated army first battles and then seeks victory.
-- Sun Tzu

Open the standard fds 0, 1 and 2 for usermode helpers. Or at least
try to do so.

Signed-off-by: Jörn Engel <joern@xxxxxxxxxxxxxxxxxxxx>
---

kmod.c | 7 +++++++
1 files changed, 7 insertions(+)

--- linux-2.6.8cow/kernel/kmod.c~hotplug 2004-09-04 22:59:14.000000000 +0200
+++ linux-2.6.8cow/kernel/kmod.c 2004-10-06 21:16:16.000000000 +0200
@@ -166,6 +166,13 @@
/* We can run anywhere, unlike our parent keventd(). */
set_cpus_allowed(current, CPU_MASK_ALL);

+ /* Try to open either /dev/console or /dev/null for fds 0, 1 and 2 */
+ if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
+ (void) sys_open("/dev/null", O_RDWR, 0);
+
+ (void) sys_dup(0);
+ (void) sys_dup(0);
+
retval = -EPERM;
if (current->fs->root)
retval = execve(sub_info->path, sub_info->argv,sub_info->envp);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/