Back to index

glibc  2.9
Go to the documentation of this file.
00001 /* Declarations of file name translation functions for the GNU Hurd.
00002    Copyright (C) 1995, 1996, 1997, 2006 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    Lesser General Public License for more details.
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00020 #ifndef _HURD_LOOKUP_H
00021 #define _HURD_LOOKUP_H      1
00023 /* These functions all take two callback functions as the first two arguments.
00024    The first callback function USE_INIT_PORT is called as follows:
00026    error_t use_init_port (int which, error_t (*operate) (mach_port_t));
00028    WHICH is nonnegative value less than INIT_PORT_MAX, indicating which
00029    init port is required.  The callback function should call *OPERATE
00030    with a send right to the appropriate init port.  No user reference
00031    is consumed; the right will only be used after *OPERATE returns if
00032    *OPERATE has added its own user reference.
00034    LOOKUP is a function to do the actual filesystem lookup.  It is passed the
00035    same arguments that the dir_lookup rpc accepts, and if 0, __dir_lookup is
00036    used.
00038    The second callback function GET_DTABLE_PORT should behave like `getdport'.
00040    All these functions return zero on success or an error code on failure.  */
00043 /* Open a port to FILE with the given FLAGS and MODE (see <fcntl.h>).  If
00044    successful, returns zero and store the port to FILE in *PORT; otherwise
00045    returns an error code. */
00047 error_t __hurd_file_name_lookup (error_t (*use_init_port)
00048                                (int which,
00049                                 error_t (*operate) (mach_port_t)),
00050                              file_t (*get_dtable_port) (int fd),
00051                              error_t (*lookup)
00052                                (file_t dir, char *name, int flags, mode_t mode,
00053                                 retry_type *do_retry, string_t retry_name,
00054                                 mach_port_t *result),
00055                              const char *file_name,
00056                              int flags, mode_t mode,
00057                              file_t *result);
00058 error_t hurd_file_name_lookup (error_t (*use_init_port)
00059                               (int which,
00060                               error_t (*operate) (mach_port_t)),
00061                             file_t (*get_dtable_port) (int fd),
00062                             error_t (*lookup)
00063                              (file_t dir, char *name, int flags, mode_t mode,
00064                               retry_type *do_retry, string_t retry_name,
00065                               mach_port_t *result),
00066                             const char *file_name,
00067                             int flags, mode_t mode,
00068                             file_t *result);
00071 /* Split FILE into a directory and a name within the directory.  Look up a
00072    port for the directory and store it in *DIR; store in *NAME a pointer
00073    into FILE where the name within directory begins.  */
00075 error_t __hurd_file_name_split (error_t (*use_init_port)
00076                               (int which,
00077                                error_t (*operate) (mach_port_t)),
00078                             file_t (*get_dtable_port) (int fd),
00079                             error_t (*lookup) (file_t dir, char *name,
00080                                              int flags, mode_t mode,
00081                                retry_type *do_retry, string_t retry_name,
00082                                mach_port_t *result),
00083                             const char *file_name,
00084                             file_t *dir, char **name);
00085 error_t hurd_file_name_split (error_t (*use_init_port)
00086                              (int which,
00087                              error_t (*operate) (mach_port_t)),
00088                            file_t (*get_dtable_port) (int fd),
00089                            error_t (*lookup) (file_t dir, char *name,
00090                                            int flags, mode_t mode,
00091                              retry_type *do_retry, string_t retry_name,
00092                              mach_port_t *result),
00093                            const char *file_name,
00094                            file_t *dir, char **name);
00096 /* Split DIRECTORY into a parent directory and a name within the directory.
00097    This is the same as hurd_file_name_split, but ignores trailing slashes.  */
00099 error_t __hurd_directory_name_split (error_t (*use_init_port)
00100                               (int which,
00101                                error_t (*operate) (mach_port_t)),
00102                             file_t (*get_dtable_port) (int fd),
00103                             error_t (*lookup) (file_t dir, char *name,
00104                                              int flags, mode_t mode,
00105                                retry_type *do_retry, string_t retry_name,
00106                                mach_port_t *result),
00107                             const char *directory_name,
00108                             file_t *dir, char **name);
00109 error_t hurd_directory_name_split (error_t (*use_init_port)
00110                                (int which,
00111                                 error_t (*operate) (mach_port_t)),
00112                                file_t (*get_dtable_port) (int fd),
00113                                error_t (*lookup) (file_t dir, char *name,
00114                                                 int flags, mode_t mode,
00115                                 retry_type *do_retry, string_t retry_name,
00116                                 mach_port_t *result),
00117                                const char *directory_name,
00118                                file_t *dir, char **name);
00121 /* Process the values returned by `dir_lookup' et al, and loop doing
00122    `dir_lookup' calls until one returns FS_RETRY_NONE.  The arguments
00123    should be those just passed to and/or returned from `dir_lookup',
00124    `fsys_getroot', or `file_invoke_translator'.  This function consumes the
00125    reference in *RESULT even if it returns an error.  */
00127 error_t __hurd_file_name_lookup_retry (error_t (*use_init_port)
00128                                      (int which,
00129                                      error_t (*operate) (mach_port_t)),
00130                                    file_t (*get_dtable_port) (int fd),
00131                                    error_t (*lookup)
00132                                      (file_t dir, char *name,
00133                                      int flags, mode_t mode,
00134                                      retry_type *do_retry,
00135                                      string_t retry_name,
00136                                      mach_port_t *result),
00137                                    enum retry_type doretry,
00138                                    char retryname[1024],
00139                                    int flags, mode_t mode,
00140                                    file_t *result);
00141 error_t hurd_file_name_lookup_retry (error_t (*use_init_port)
00142                                    (int which,
00143                                    error_t (*operate) (mach_port_t)),
00144                                  file_t (*get_dtable_port) (int fd),
00145                                  error_t (*lookup)
00146                                    (file_t dir, char *name,
00147                                    int flags, mode_t mode,
00148                                    retry_type *do_retry,
00149                                    string_t retry_name,
00150                                    mach_port_t *result),
00151                                  enum retry_type doretry,
00152                                  char retryname[1024],
00153                                  int flags, mode_t mode,
00154                                  file_t *result);
00157 /* If FILE_NAME contains a '/', or PATH is NULL, call FUN with FILE_NAME, and
00158    return the result (if PREFIXED_NAME is non-NULL, setting *PREFIXED_NAME to
00159    NULL).  Otherwise, call FUN repeatedly with FILE_NAME prefixed with each
00160    successive `:' separated element of PATH, returning whenever FUN returns
00161    0 (if PREFIXED_NAME is non-NULL, setting *PREFIXED_NAME to the resulting
00162    prefixed path).  If FUN never returns 0, return the first non-ENOENT
00163    return value, or ENOENT if there is none.  */
00164 error_t file_name_path_scan (const char *file_name, const char *path,
00165                           error_t (*fun)(const char *name),
00166                           char **prefixed_name);
00168 /* Lookup FILE_NAME and return the node opened with FLAGS & MODE in result
00169    (see hurd_file_name_lookup for details), but a simple filename (without
00170    any directory prefixes) will be consecutively prefixed with the pathnames
00171    in the `:' separated list PATH until one succeeds in a successful lookup.
00172    If none succeed, then the first error that wasn't ENOENT is returned, or
00173    ENOENT if no other errors were returned.  If PREFIXED_NAME is non-NULL,
00174    then if RESULT is looked up directly, *PREFIXED_NAME is set to NULL, and
00175    if it is looked up using a prefix from PATH, *PREFIXED_NAME is set to
00176    malloced storage containing the prefixed name.  */
00177 error_t hurd_file_name_path_lookup (error_t (*use_init_port)
00178                                 (int which,
00179                                  error_t (*operate) (mach_port_t)),
00180                                 file_t (*get_dtable_port) (int fd),
00181                                 error_t (*lookup)
00182                                   (file_t dir, char *name,
00183                                    int flags, mode_t mode,
00184                                    retry_type *do_retry,
00185                                    string_t retry_name,
00186                                    mach_port_t *result),
00187                                 const char *file_name, const char *path,
00188                                 int flags, mode_t mode,
00189                                 file_t *result, char **prefixed_name);
00191 #endif /* hurd/lookup.h */