about summary refs log tree commit diff
path: root/sysdeps/mach/hurd/getcwd.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1995-10-16 07:29:08 +0000
committerRoland McGrath <roland@gnu.org>1995-10-16 07:29:08 +0000
commit924b9ff68db26697e50a298c3ae12159de259c2f (patch)
tree2374009a4bcd22360f0380b4974255461ab660fa /sysdeps/mach/hurd/getcwd.c
parent2948fc64a6dd7aa23757daf2c5256dfe07f4c61a (diff)
downloadglibc-924b9ff68db26697e50a298c3ae12159de259c2f.tar.gz
glibc-924b9ff68db26697e50a298c3ae12159de259c2f.tar.xz
glibc-924b9ff68db26697e50a298c3ae12159de259c2f.zip
Mon Oct 16 03:22:37 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu> cvs/libc-951016
	* sysdeps/mach/hurd/getcwd.c: Use __file_name_lookup_under.
	* sysdeps/mach/hurd/bind.c: Likewise.
	* sysdeps/mach/hurd/access.c: Use new __hurd_file_name_lookup
	calling convention.

	* hurd/hurdexec.c: Undo last change (10 Oct 95).
Diffstat (limited to 'sysdeps/mach/hurd/getcwd.c')
-rw-r--r--sysdeps/mach/hurd/getcwd.c34
1 files changed, 14 insertions, 20 deletions
diff --git a/sysdeps/mach/hurd/getcwd.c b/sysdeps/mach/hurd/getcwd.c
index caed104bce..b42e0979a6 100644
--- a/sysdeps/mach/hurd/getcwd.c
+++ b/sysdeps/mach/hurd/getcwd.c
@@ -47,12 +47,9 @@ __getcwd (char *buf, size_t size)
   file_t parent;
   char *dirbuf = NULL;
   unsigned int dirbufsize = 0;
-  file_t crdir;
-  struct hurd_userlink crdir_ulink;
 
   inline void cleanup (void)
     {
-      _hurd_port_free (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink, crdir);
       __mach_port_deallocate (__mach_task_self (), parent);
 
       if (dirbuf != NULL)
@@ -86,12 +83,8 @@ __getcwd (char *buf, size_t size)
 
   /* Get a port to our root directory and stat it.  */
 
-  crdir = _hurd_port_get (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink);
-  if (err = __io_stat (crdir, &st))
-    {
-      _hurd_port_free (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink, crdir);
-      return __hurd_fail (err), NULL;
-    }
+  if (err = __USEPORT (CRDIR, __io_stat (port, &st)))
+    return __hurd_fail (err), NULL;
   rootdev = st.st_dev;
   rootino = st.st_ino;
 
@@ -101,10 +94,7 @@ __getcwd (char *buf, size_t size)
 						    (parent = port),
 						    MACH_PORT_RIGHT_SEND,
 						    1)))
-    {
-      _hurd_port_free (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink, crdir);
-      return __hurd_fail (err), NULL;
-    }
+    return __hurd_fail (err), NULL;
   if (err = __io_stat (parent, &st))
     {
       cleanup ();
@@ -130,14 +120,15 @@ __getcwd (char *buf, size_t size)
       int direntry, nentries;
 
       /* Look at the parent directory.  */
-      if (err = __hurd_file_name_lookup (crdir, parent, "..", O_READ, 0, &newp))
+      newp = __file_name_lookup_under (parent, "..", O_READ, 0);
+      if (newp == MACH_PORT_NULL)
 	goto lose;
       __mach_port_deallocate (__mach_task_self (), parent);
       parent = newp;
 
       /* Figure out if this directory is a mount point.  */
       if (err = __io_stat (parent, &st))
-	goto lose;
+	goto errlose;
       dotdev = st.st_dev;
       dotino = st.st_ino;
       mount_point = dotdev != thisdev;
@@ -184,14 +175,14 @@ __getcwd (char *buf, size_t size)
 
 	      if (mount_point || d->d_ino == thisino)
 		{
-		  file_t try;
-		  if (err = __hurd_file_name_lookup (crdir, parent, d->d_name,
-						     O_NOLINK, 0, &try))
+		  file_t try = __file_name_lookup_under (parent, d->d_name,
+							 O_NOLINK, 0);
+		  if (try == MACH_PORT_NULL)
 		    goto lose;
 		  err = __io_stat (try, &st);
 		  __mach_port_deallocate (__mach_task_self (), try);
 		  if (err)
-		    goto lose;
+		    goto errlose;
 		  if (st.st_dev == thisdev && st.st_ino == thisino)
 		    break;
 		}
@@ -199,7 +190,7 @@ __getcwd (char *buf, size_t size)
 	}
 
       if (err)
-	goto lose;
+	goto errlose;
       else
 	{
 	  /* Prepend the directory name just discovered.  */
@@ -244,6 +235,9 @@ __getcwd (char *buf, size_t size)
   cleanup ();
   return file_name;
 
+ errlose:
+  /* Set errno.  */
+  (void) __hurd_fail (err);
  lose:
   cleanup ();
   return NULL;