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