1 /* Declarations of file name translation functions for the GNU Hurd.
2 Copyright (C) 1995-2015 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, see
17 <http://www.gnu.org/licenses/>. */
19 #ifndef _HURD_LOOKUP_H
20 #define _HURD_LOOKUP_H 1
22 /* These functions all take two callback functions as the first two arguments.
23 The first callback function USE_INIT_PORT is called as follows:
25 error_t use_init_port (int which, error_t (*operate) (mach_port_t));
27 WHICH is nonnegative value less than INIT_PORT_MAX, indicating which
28 init port is required. The callback function should call *OPERATE
29 with a send right to the appropriate init port. No user reference
30 is consumed; the right will only be used after *OPERATE returns if
31 *OPERATE has added its own user reference.
33 LOOKUP is a function to do the actual filesystem lookup. It is passed the
34 same arguments that the dir_lookup rpc accepts, and if 0, __dir_lookup is
37 The second callback function GET_DTABLE_PORT should behave like `getdport'.
39 All these functions return zero on success or an error code on failure. */
42 /* Open a port to FILE with the given FLAGS and MODE (see <fcntl.h>). If
43 successful, returns zero and store the port to FILE in *PORT; otherwise
44 returns an error code. */
46 error_t
__hurd_file_name_lookup (error_t (*use_init_port
)
48 error_t (*operate
) (mach_port_t
)),
49 file_t (*get_dtable_port
) (int fd
),
51 (file_t dir
, char *name
, int flags
, mode_t mode
,
52 retry_type
*do_retry
, string_t retry_name
,
54 const char *file_name
,
55 int flags
, mode_t mode
,
57 error_t
hurd_file_name_lookup (error_t (*use_init_port
)
59 error_t (*operate
) (mach_port_t
)),
60 file_t (*get_dtable_port
) (int fd
),
62 (file_t dir
, char *name
, int flags
, mode_t mode
,
63 retry_type
*do_retry
, string_t retry_name
,
65 const char *file_name
,
66 int flags
, mode_t mode
,
70 /* Split FILE into a directory and a name within the directory. Look up a
71 port for the directory and store it in *DIR; store in *NAME a pointer
72 into FILE where the name within directory begins. */
74 error_t
__hurd_file_name_split (error_t (*use_init_port
)
76 error_t (*operate
) (mach_port_t
)),
77 file_t (*get_dtable_port
) (int fd
),
78 error_t (*lookup
) (file_t dir
, char *name
,
79 int flags
, mode_t mode
,
80 retry_type
*do_retry
, string_t retry_name
,
82 const char *file_name
,
83 file_t
*dir
, char **name
);
84 error_t
hurd_file_name_split (error_t (*use_init_port
)
86 error_t (*operate
) (mach_port_t
)),
87 file_t (*get_dtable_port
) (int fd
),
88 error_t (*lookup
) (file_t dir
, char *name
,
89 int flags
, mode_t mode
,
90 retry_type
*do_retry
, string_t retry_name
,
92 const char *file_name
,
93 file_t
*dir
, char **name
);
95 /* Split DIRECTORY into a parent directory and a name within the directory.
96 This is the same as hurd_file_name_split, but ignores trailing slashes. */
98 error_t
__hurd_directory_name_split (error_t (*use_init_port
)
100 error_t (*operate
) (mach_port_t
)),
101 file_t (*get_dtable_port
) (int fd
),
102 error_t (*lookup
) (file_t dir
, char *name
,
103 int flags
, mode_t mode
,
104 retry_type
*do_retry
, string_t retry_name
,
105 mach_port_t
*result
),
106 const char *directory_name
,
107 file_t
*dir
, char **name
);
108 error_t
hurd_directory_name_split (error_t (*use_init_port
)
110 error_t (*operate
) (mach_port_t
)),
111 file_t (*get_dtable_port
) (int fd
),
112 error_t (*lookup
) (file_t dir
, char *name
,
113 int flags
, mode_t mode
,
114 retry_type
*do_retry
, string_t retry_name
,
115 mach_port_t
*result
),
116 const char *directory_name
,
117 file_t
*dir
, char **name
);
120 /* Process the values returned by `dir_lookup' et al, and loop doing
121 `dir_lookup' calls until one returns FS_RETRY_NONE. The arguments
122 should be those just passed to and/or returned from `dir_lookup',
123 `fsys_getroot', or `file_invoke_translator'. This function consumes the
124 reference in *RESULT even if it returns an error. */
126 error_t
__hurd_file_name_lookup_retry (error_t (*use_init_port
)
128 error_t (*operate
) (mach_port_t
)),
129 file_t (*get_dtable_port
) (int fd
),
131 (file_t dir
, char *name
,
132 int flags
, mode_t mode
,
133 retry_type
*do_retry
,
135 mach_port_t
*result
),
136 enum retry_type doretry
,
137 char retryname
[1024],
138 int flags
, mode_t mode
,
140 error_t
hurd_file_name_lookup_retry (error_t (*use_init_port
)
142 error_t (*operate
) (mach_port_t
)),
143 file_t (*get_dtable_port
) (int fd
),
145 (file_t dir
, char *name
,
146 int flags
, mode_t mode
,
147 retry_type
*do_retry
,
149 mach_port_t
*result
),
150 enum retry_type doretry
,
151 char retryname
[1024],
152 int flags
, mode_t mode
,
156 /* If FILE_NAME contains a '/', or PATH is NULL, call FUN with FILE_NAME, and
157 return the result (if PREFIXED_NAME is non-NULL, setting *PREFIXED_NAME to
158 NULL). Otherwise, call FUN repeatedly with FILE_NAME prefixed with each
159 successive `:' separated element of PATH, returning whenever FUN returns
160 0 (if PREFIXED_NAME is non-NULL, setting *PREFIXED_NAME to the resulting
161 prefixed path). If FUN never returns 0, return the first non-ENOENT
162 return value, or ENOENT if there is none. */
163 error_t
file_name_path_scan (const char *file_name
, const char *path
,
164 error_t (*fun
)(const char *name
),
165 char **prefixed_name
);
167 /* Lookup FILE_NAME and return the node opened with FLAGS & MODE in result
168 (see hurd_file_name_lookup for details), but a simple filename (without
169 any directory prefixes) will be consecutively prefixed with the pathnames
170 in the `:' separated list PATH until one succeeds in a successful lookup.
171 If none succeed, then the first error that wasn't ENOENT is returned, or
172 ENOENT if no other errors were returned. If PREFIXED_NAME is non-NULL,
173 then if RESULT is looked up directly, *PREFIXED_NAME is set to NULL, and
174 if it is looked up using a prefix from PATH, *PREFIXED_NAME is set to
175 malloced storage containing the prefixed name. */
176 error_t
hurd_file_name_path_lookup (error_t (*use_init_port
)
178 error_t (*operate
) (mach_port_t
)),
179 file_t (*get_dtable_port
) (int fd
),
181 (file_t dir
, char *name
,
182 int flags
, mode_t mode
,
183 retry_type
*do_retry
,
185 mach_port_t
*result
),
186 const char *file_name
, const char *path
,
187 int flags
, mode_t mode
,
188 file_t
*result
, char **prefixed_name
);
190 #endif /* hurd/lookup.h */