summary refs log tree commit diff
path: root/hurd/fchroot.c
diff options
context:
space:
mode:
Diffstat (limited to 'hurd/fchroot.c')
-rw-r--r--hurd/fchroot.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/hurd/fchroot.c b/hurd/fchroot.c
index d745fb0866..143ea23807 100644
--- a/hurd/fchroot.c
+++ b/hurd/fchroot.c
@@ -35,7 +35,13 @@ fchroot (int fd)
 			}));
 
   if (! err)
-    _hurd_port_set (&_hurd_ports[INIT_PORT_CRDIR], dir);
+    {
+      file_t root;
+      err = __file_reparent (dir, MACH_PORT_NULL, &root);
+      __mach_port_deallocate (__mach_task_self (), dir);
+      if (! err)
+	_hurd_port_set (&_hurd_ports[INIT_PORT_CRDIR], root);
+    }
 
   return err ? __hurd_fail (err) : 0;
 }