summaryrefslogtreecommitdiff
path: root/pfinet
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2012-02-19 12:09:53 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2012-02-19 12:09:53 +0000
commit17a310640b52e08483b6f04dda490e9ec229811a (patch)
tree5545284020c765f042c0baed2eb23f582af7757d /pfinet
parentf9b438f76afa50d99e25c46af6a3ea25b4e463a6 (diff)
parentd3ad9490749fe330bea91c0027a0c8319476cac0 (diff)
Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/hurd
Diffstat (limited to 'pfinet')
-rw-r--r--pfinet/ethernet.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/pfinet/ethernet.c b/pfinet/ethernet.c
index 3b632fa6..754c9156 100644
--- a/pfinet/ethernet.c
+++ b/pfinet/ethernet.c
@@ -169,14 +169,33 @@ ethernet_open (struct device *dev)
mach_port_set_qlimit (mach_task_self (), edev->readptname, MACH_PORT_QLIMIT_MAX);
- err = get_privileged_ports (0, &master_device);
- if (err)
- error (2, err, "cannot get device master port");
-
- err = device_open (master_device, D_WRITE | D_READ, dev->name, &edev->ether_port);
- mach_port_deallocate (mach_task_self (), master_device);
- if (err)
- error (2, err, "%s", dev->name);
+ master_device = file_name_lookup (dev->name, O_READ | O_WRITE, 0);
+ if (master_device != MACH_PORT_NULL)
+ {
+ /* The device name here is the path of a device file. */
+ err = device_open (master_device, D_WRITE | D_READ, "eth", &edev->ether_port);
+ mach_port_deallocate (mach_task_self (), master_device);
+ if (err)
+ error (2, err, "%s", dev->name);
+ }
+ else
+ {
+ /* No, perhaps a Mach device? */
+ int file_errno = errno;
+ err = get_privileged_ports (0, &master_device);
+ if (err)
+ {
+ error (0, errno, "file_name_lookup %s", dev->name);
+ error (2, err, "and cannot get device master port");
+ }
+ err = device_open (master_device, D_WRITE | D_READ, dev->name, &edev->ether_port);
+ mach_port_deallocate (mach_task_self (), master_device);
+ if (err)
+ {
+ error (0, errno, "file_name_lookup %s", dev->name);
+ error (2, err, "%s", dev->name);
+ }
+ }
err = device_set_filter (edev->ether_port, ports_get_right (edev->readpt),
MACH_MSG_TYPE_MAKE_SEND, 0,