Add -fno-asynchronous-unwind-tables to initfini.s for i386
[glibc.git] / hurd / lookup-at.c
blob728a97090935aa5e9f93a6b12e2f214673a28257
1 /* Lookup helper function for Hurd implementation of *at functions.
2 Copyright (C) 2006,2010 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #include <hurd.h>
21 #include <hurd/lookup.h>
22 #include <hurd/fd.h>
23 #include <string.h>
24 #include <fcntl.h>
26 file_t
27 __file_name_lookup_at (int fd, int at_flags,
28 const char *file_name, int flags, mode_t mode)
30 error_t err;
31 file_t result;
33 if ((at_flags & AT_SYMLINK_FOLLOW) && (at_flags & AT_SYMLINK_NOFOLLOW))
34 return (__hurd_fail (EINVAL), MACH_PORT_NULL);
36 flags |= (at_flags & AT_SYMLINK_NOFOLLOW) ? O_NOLINK : 0;
37 at_flags &= ~AT_SYMLINK_NOFOLLOW;
38 if (at_flags & AT_SYMLINK_FOLLOW)
39 flags &= ~O_NOLINK;
40 at_flags &= ~AT_SYMLINK_FOLLOW;
41 if (at_flags != 0)
42 return (__hurd_fail (EINVAL), MACH_PORT_NULL);
44 if (fd == AT_FDCWD || file_name[0] == '/')
45 return __file_name_lookup (file_name, flags, mode);
47 file_t startdir;
48 error_t use_init_port (int which, error_t (*operate) (mach_port_t))
50 return (which == INIT_PORT_CWDIR ? (*operate) (startdir) :
51 _hurd_ports_use (which, operate));
54 err = HURD_DPORT_USE (fd, (startdir = port,
55 __hurd_file_name_lookup (&use_init_port,
56 &__getdport, NULL,
57 file_name,
58 flags,
59 mode & ~_hurd_umask,
60 &result)));
62 return err ? (__hurd_dfail (fd, err), MACH_PORT_NULL) : result;
65 file_t
66 __file_name_split_at (int fd, const char *file_name, char **name)
68 error_t err;
69 file_t result;
71 if (fd == AT_FDCWD || file_name[0] == '/')
72 return __file_name_split (file_name, name);
74 err = __hurd_file_name_split (&_hurd_ports_use, &__getdport, 0,
75 file_name, &result, name);
77 file_t startdir;
78 error_t use_init_port (int which, error_t (*operate) (mach_port_t))
80 return (which == INIT_PORT_CWDIR ? (*operate) (startdir) :
81 _hurd_ports_use (which, operate));
84 err = HURD_DPORT_USE (fd, (startdir = port,
85 __hurd_file_name_split (&use_init_port,
86 &__getdport, 0,
87 file_name,
88 &result, name)));
90 return err ? (__hurd_dfail (fd, err), MACH_PORT_NULL) : result;
93 file_t
94 __directory_name_split_at (int fd, const char *directory_name, char **name)
96 error_t err;
97 file_t result;
99 if (fd == AT_FDCWD || directory_name[0] == '/')
100 return __directory_name_split (directory_name, name);
102 file_t startdir;
103 error_t use_init_port (int which, error_t (*operate) (mach_port_t))
105 return (which == INIT_PORT_CWDIR ? (*operate) (startdir) :
106 _hurd_ports_use (which, operate));
109 err = HURD_DPORT_USE (fd, (startdir = port,
110 __hurd_directory_name_split (&use_init_port,
111 &__getdport, 0,
112 directory_name,
113 &result, name)));
115 return err ? (__hurd_dfail (fd, err), MACH_PORT_NULL) : result;