[EMAIL PROTECTED] wrote:
Hi,
2008-07-29 Zheng Da <[EMAIL PROTECTED]>
*boot/boot.c: add an option to open the virtual network interface
That's not a complete changelog...
+ if (err)
+ fprintf (stderr, "open_device returns %x, %s\n",
+ err, strerror (err));
Why don't you use error() here as well?
(Note that error() only exits when passed a non-0 status; otherwise, it
just prints a warning.)
Otherwise, the patch looks fine :-)
Here goes the patch again.
Needed for Hurd 0.3
2008-07-29 Zheng Da <[EMAIL PROTECTED]>
* boot/boot.c: Add an option to open the virtual network device.
(parse_opt): Handle the new option '-n'.
(ds_device_open): Handle the request to open the virtual network device.
diff -u boot.old/boot.c boot/boot.c
--- boot.old/boot.c 2006-03-15 00:18:34.520000000 +0100
+++ boot/boot.c 2008-08-09 21:20:39.240000000 +0200
@@ -78,6 +78,7 @@
static struct termios orig_tty_state;
static int isig;
static char *kernel_command_line;
+static char *net_device_file=NULL;
static void
init_termstate ()
@@ -110,6 +111,7 @@
mach_port_t privileged_host_port, master_device_port, defpager;
mach_port_t pseudo_master_device_port;
+mach_port_t net_device_port = MACH_PORT_NULL;
mach_port_t receive_set;
mach_port_t pseudo_console, pseudo_root;
auth_t authserver;
@@ -432,6 +434,8 @@
"Pause for user confirmation at various times during booting" },
{ "isig", 'I', 0, 0,
"Do not disable terminal signals, so you can suspend and interrupt
boot."},
+ { "net_device", 'n', "FILE", 0,
+ "connect to a virtual network interface"},
{ 0 }
};
static char args_doc[] = "BOOT-SCRIPT";
@@ -450,6 +454,8 @@
case 'I': isig = 1; break;
+ case 'n': net_device_file = arg; break;
+
case 's': case 'd':
len = strlen (bootstrap_args);
if (len >= sizeof bootstrap_args - 1)
@@ -497,6 +503,13 @@
get_privileged_ports (&privileged_host_port, &master_device_port);
+ if (net_device_file)
+ {
+ net_device_port = file_name_lookup (net_device_file, 0, 0);
+ if (net_device_port == MACH_PORT_NULL)
+ error (10, errno, "file_name_lookup %s", net_device_file);
+ }
+
defpager = MACH_PORT_NULL;
vm_set_default_memory_manager (privileged_host_port, &defpager);
@@ -964,6 +977,16 @@
*devicetype = MACH_MSG_TYPE_MAKE_SEND;
return 0;
}
+ else if (strncmp (name, "veth", 4) == 0
+ && net_device_port != MACH_PORT_NULL)
+ {
+ kern_return_t err;
+ *devicetype = MACH_MSG_TYPE_MOVE_SEND;
+ err = device_open (net_device_port, mode, name, device);
+ if (err)
+ error (0, err, "open_device");
+ return err;
+ }
*devicetype = MACH_MSG_TYPE_MOVE_SEND;
return device_open (master_device_port, mode, name, device);