Back to index

glibc  2.9
Functions
path-lookup.c File Reference
#include <string.h>
#include <hurd.h>
#include <hurd/lookup.h>

Go to the source code of this file.

Functions

error_t file_name_path_scan (const char *file_name, const char *path, error_t(*fun)(const char *name), char **prefixed_name)
error_t hurd_file_name_path_lookup (error_t(*use_init_port)(int which, error_t(*operate)(mach_port_t)), file_t(*get_dtable_port)(int fd), error_t(*lookup)(file_t dir, char *name, int flags, mode_t mode, retry_type *do_retry, string_t retry_name, mach_port_t *result), const char *file_name, const char *path, int flags, mode_t mode, file_t *result, char **prefixed_name)
file_t file_name_path_lookup (const char *file_name, const char *path, int flags, mode_t mode, char **prefixed_name)

Function Documentation

file_t file_name_path_lookup ( const char *  file_name,
const char *  path,
int  flags,
mode_t  mode,
char **  prefixed_name 
)

Definition at line 112 of file path-lookup.c.

{
  error_t err;
  file_t result;

  err = hurd_file_name_path_lookup (&_hurd_ports_use, &__getdport, 0,
                                file_name, path, flags, mode,
                                &result, prefixed_name);

  return err ? (__hurd_fail (err), MACH_PORT_NULL) : result;
}

Here is the call graph for this function:

error_t file_name_path_scan ( const char *  file_name,
const char *  path,
error_t(*)(const char *name fun,
char **  prefixed_name 
)

Definition at line 33 of file path-lookup.c.

{
  if (path == NULL || index (file_name, '/'))
    {
      if (prefixed_name)
       *prefixed_name = 0;
      return (*fun)(file_name);
    }
  else
    {
      error_t real_err = 0;
      size_t file_name_len = strlen (file_name);

      for (;;)
       {
         error_t err;
         const char *next = index (path, ':') ?: path + strlen (path);
         size_t pfx_len = next - path;
         char pfxed_name[pfx_len + 2 + file_name_len + 1];

         if (pfx_len == 0)
           pfxed_name[pfx_len++] = '.';
         else
           memcpy (pfxed_name, path, pfx_len);
         if (pfxed_name[pfx_len - 1] != '/')
           pfxed_name[pfx_len++] = '/';
         memcpy (pfxed_name + pfx_len, file_name, file_name_len + 1);

         err = (*fun)(pfxed_name);
         if (err == 0)
           {
             if (prefixed_name)
              *prefixed_name = strdup (pfxed_name);
             return 0;
           }
         if (!real_err && err != ENOENT)
           real_err = err;

         if (*next == '\0')
           return real_err ?: ENOENT;
         else
           path = next + 1;
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

error_t hurd_file_name_path_lookup ( error_t(*)(int which, error_t(*operate)(mach_port_t))  use_init_port,
file_t(*)(int fd get_dtable_port,
error_t(*)(file_t dir, char *name, int flags, mode_t mode, retry_type *do_retry, string_t retry_name, mach_port_t *result lookup,
const char *  file_name,
const char *  path,
int  flags,
mode_t  mode,
file_t *  result,
char **  prefixed_name 
)

Definition at line 91 of file path-lookup.c.

{
  error_t scan_lookup (const char *name)
    {
      return
       __hurd_file_name_lookup (use_init_port, get_dtable_port, lookup,
                             name, flags, mode, result);
    }
  return file_name_path_scan (file_name, path, scan_lookup, prefixed_name);
}

Here is the call graph for this function:

Here is the caller graph for this function: