bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

The patch of boot to open a virtual network interface


From: zhengda
Subject: The patch of boot to open a virtual network interface
Date: Fri, 08 Aug 2008 07:06:29 +0200
User-agent: Thunderbird 2.0.0.16 (X11/20080707)

Hello,

The patch enables boot to open the virtual network interface,
so boot can work with the multiplexer and the subhurd can connect to the main hurd. But the way to open the virtual network interface will be changed if the translator that helps open the device is created.


Here is the patch:

Needed for Hurd 0.3

2008-07-29 Zheng Da <zhengda1936@gmail.com>

   *boot/boot.c: add an option to open the virtual network interface

diff -u boot.old/boot.c boot/boot.c
--- boot.old/boot.c    2006-03-15 00:18:34.920000000 +0100
+++ boot/boot.c    2008-08-08 06:48:48.220000000 +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,17 @@
      *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)
+        fprintf (stderr, "open_device returns %x, %s\n",
+                 err, strerror (err));
+      return err;
+    }

  *devicetype = MACH_MSG_TYPE_MOVE_SEND;
  return device_open (master_device_port, mode, name, device);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]