diff options
author | Roland McGrath <roland@gnu.org> | 1998-10-23 22:31:15 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 1998-10-23 22:31:15 +0000 |
commit | 8db34fe108b62c166d65bb70377f5e01867dc9fb (patch) | |
tree | 66b15c1e3680ff0ac9a7935636c9f5999ed0a268 /sysdeps | |
parent | 0d486134da09d9c29bba8f906d9f0069813e3426 (diff) | |
download | glibc-8db34fe108b62c166d65bb70377f5e01867dc9fb.tar.gz glibc-8db34fe108b62c166d65bb70377f5e01867dc9fb.tar.xz glibc-8db34fe108b62c166d65bb70377f5e01867dc9fb.zip |
1998-10-24 Roland McGrath <roland@baalperazim.frob.com>
* sysdeps/mach/hurd/opendir.c (__opendir): Return ENOENT for "". (__opendir): Add trailing slash to name for open, for ENOTDIR check.
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/mach/hurd/opendir.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/sysdeps/mach/hurd/opendir.c b/sysdeps/mach/hurd/opendir.c index 2919f8f465..ae92fd9043 100644 --- a/sysdeps/mach/hurd/opendir.c +++ b/sysdeps/mach/hurd/opendir.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1993, 94, 95, 96, 97, 98 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -39,7 +39,29 @@ __opendir (const char *name) int fd; struct hurd_fd *d; - fd = __open (name, O_RDONLY); + if (name[0] == '\0') + { + /* POSIX.1-1990 says an empty name gets ENOENT; + but `open' might like it fine. */ + __set_errno (ENOENT); + return NULL; + } + + { + /* Append trailing slash to directory name to force ENOTDIR + if it's not a directory. */ + size_t len = strlen (name); + if (name[len - 1] == '/') + fd = __open (name, O_RDONLY); + else + { + char n[len + 2]; + memcpy (n, name, len); + n[len] = '/'; + n[len + 1] = '\0'; + fd = __open (n, O_RDONLY); + } + } if (fd < 0) return NULL; |