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