/* Lookup helper function for Hurd implementation of *at functions.
- Copyright (C) 2006,2010 Free Software Foundation, Inc.
+ Copyright (C) 2006-2019 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <hurd.h>
#include <hurd/lookup.h>
{
error_t err;
file_t result;
+ int empty = at_flags & AT_EMPTY_PATH;
- flags |= (at_flags & AT_SYMLINK_NOFOLLOW) ? O_NOLINK : 0;
- at_flags &= ~AT_SYMLINK_NOFOLLOW;
- if (at_flags != 0)
- return (__hurd_fail (EINVAL), MACH_PORT_NULL);
+ at_flags &= ~AT_EMPTY_PATH;
+
+ err = __hurd_at_flags (&at_flags, &flags);
+ if (err)
+ return (__hurd_fail (err), MACH_PORT_NULL);
if (fd == AT_FDCWD || file_name[0] == '/')
return __file_name_lookup (file_name, flags, mode);
+ if (empty != 0 && file_name[0] == '\0')
+ {
+ enum retry_type doretry;
+ char retryname[1024]; /* XXX string_t LOSES! */
+
+ err = HURD_DPORT_USE (fd, __dir_lookup (port, "", flags, mode,
+ &doretry, retryname,
+ &result));
+
+ if (! err)
+ err = __hurd_file_name_lookup_retry (&_hurd_ports_use, &__getdport,
+ NULL, doretry, retryname,
+ flags, mode, &result);
+
+ return err ? (__hurd_dfail (fd, err), MACH_PORT_NULL) : result;
+ }
+
file_t startdir;
error_t use_init_port (int which, error_t (*operate) (mach_port_t))
{
- return (which == INIT_PORT_CWDIR ? (*operate) (startdir) :
- _hurd_ports_use (which, operate));
+ return (which == INIT_PORT_CWDIR ? (*operate) (startdir)
+ : _hurd_ports_use (which, operate));
}
err = HURD_DPORT_USE (fd, (startdir = port,
file_t startdir;
error_t use_init_port (int which, error_t (*operate) (mach_port_t))
{
- return (which == INIT_PORT_CWDIR ? (*operate) (startdir) :
- _hurd_ports_use (which, operate));
+ return (which == INIT_PORT_CWDIR ? (*operate) (startdir)
+ : _hurd_ports_use (which, operate));
}
err = HURD_DPORT_USE (fd, (startdir = port,
file_t startdir;
error_t use_init_port (int which, error_t (*operate) (mach_port_t))
{
- return (which == INIT_PORT_CWDIR ? (*operate) (startdir) :
- _hurd_ports_use (which, operate));
+ return (which == INIT_PORT_CWDIR ? (*operate) (startdir)
+ : _hurd_ports_use (which, operate));
}
err = HURD_DPORT_USE (fd, (startdir = port,