root/opal/mca/pmix/pmix4x/pmix/src/util/path.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
   3  *                         University Research and Technology
   4  *                         Corporation.  All rights reserved.
   5  * Copyright (c) 2004-2007 The University of Tennessee and The University
   6  *                         of Tennessee Research Foundation.  All rights
   7  *                         reserved.
   8  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
   9  *                         University of Stuttgart.  All rights reserved.
  10  * Copyright (c) 2004-2005 The Regents of the University of California.
  11  *                         All rights reserved.
  12  * Copyright (c) 2012      Los Alamos National Security, LLC.
  13  *                         All rights reserved.
  14  * Copyright (c) 2016      University of Houston. All rights reserved.
  15  * Copyright (c) 2016-2017 Intel, Inc. All rights reserved.
  16  * $COPYRIGHT$
  17  *
  18  * Additional copyrights may follow
  19  *
  20  * $HEADER$
  21  *
  22  * @file
  23  */
  24 
  25 #ifndef PMIX_PATH_H
  26 #define PMIX_PATH_H
  27 
  28 #include <src/include/pmix_config.h>
  29 
  30 #include "pmix_common.h"
  31 
  32 #ifdef HAVE_UNISTD_H
  33 #include <unistd.h>
  34 #endif
  35 
  36 BEGIN_C_DECLS
  37 
  38 /**
  39  *  Locates a file with certain permissions
  40  *
  41  *  @param fname File name
  42  *  @param pathv Array of search directories
  43  *  @param mode  Permissions which must be satisfied (see access(2))
  44  *  @param envv  Pointer to string containing environment
  45  *
  46  *  @retval Full pathname of located file Success
  47  *  @retval NULL Failure
  48  *
  49  *  Environment variables can appear in the form $variable at the
  50  *  start of a prefix path and will be replaced by the environment
  51  *  value if it is defined; otherwise the whole prefix is ignored.
  52  *  Environment variables must be followed by a path delimiter or
  53  *  end-of-string.
  54  *
  55  * The caller is responsible for freeing the returned string.
  56  */
  57 PMIX_EXPORT char *pmix_path_find(char *fname, char **pathv, int mode,
  58                                  char **envv) __pmix_attribute_malloc__ __pmix_attribute_warn_unused_result__;
  59 
  60 /**
  61  *  Locates a file with certain permissions from a list of search
  62  *  paths
  63  *
  64  *  @param fname File name
  65  *  @param mode  Target permissions which must be satisfied (see access(2))
  66  *  @param envv  Pointer to environment list
  67  *  @param wrkdir Working directory
  68  *
  69  *  @retval Full pathname of located file Success
  70  *  @retval NULL Failure
  71  *
  72  *  Locates a file with certain permissions from the list of paths
  73  *  given by the $PATH environment variable.  Replaces "." in the
  74  *  path with the working dir.
  75  *
  76  * The caller is responsible for freeing the returned string.
  77  */
  78 PMIX_EXPORT char *pmix_path_findv(char *fname, int mode,
  79                                   char **envv, char *wrkdir) __pmix_attribute_malloc__ __pmix_attribute_warn_unused_result__;
  80 /**
  81  *  Detect if the requested path is absolute or relative.
  82  *
  83  *  @param path  File name
  84  *
  85  *  @retval true if the path is absolute
  86  *  @retval false otherwise
  87  *
  88  *  Detect if a path is absolute or relative. Handle Windows
  89  *  with special care as an absolute path on Windows starts
  90  *  with [A-Za-z]: or \\ instead of the usual / on UNIX.
  91  */
  92 PMIX_EXPORT bool pmix_path_is_absolute( const char *path );
  93 
  94 /**
  95  * Find the absolute path for an executable and return it.
  96  *
  97  *  @param app_name  Executable name
  98  *
  99  *  @retval The absolute path if the application can be reached,
 100  *  @retval NULL otherwise.
 101  *
 102  * Try to figure out the absolute path based on the application name
 103  * (usually argv[0]). If the path is already absolute return a copy, if
 104  * it start with . look into the current directory, if not dig into
 105  * the $PATH.
 106  * In case of error or if executable was not found (as an example if
 107  * the application did a cwd between the start and this call), the
 108  * function will return NULL. Otherwise, an newly allocated string
 109  * will be returned.
 110  */
 111 PMIX_EXPORT char* pmix_find_absolute_path( char* app_name ) __pmix_attribute_warn_unused_result__;
 112 
 113 /**
 114  * Forms a complete pathname and checks it for existance and
 115  * permissions
 116  *
 117  * @param fname File name
 118  * @param path Path prefix, if NULL then fname is an absolute path
 119  * @param mode Target permissions which must be satisfied (see access(2))
 120  *
 121  * @retval NULL Failure
 122  * @retval Full pathname of the located file on Success
 123  *
 124  * The caller is responsible for freeing the returned string.
 125  */
 126 PMIX_EXPORT char *pmix_path_access(char *fname, char *path, int mode) __pmix_attribute_malloc__ __pmix_attribute_warn_unused_result__;
 127 
 128 
 129 /**
 130  * @brief Figure out, whether fname is on network file system
 131  * and return fstype if known
 132  *
 133  * Try to figure out, whether the file name specified through fname is
 134  * on any network file system (currently NFS, Lustre, GPFS,  Panasas
 135  * and PVFS2 ).
 136  *
 137  * If the file is not created, the parent directory is checked.
 138  * This allows checking for NFS prior to opening the file.
 139  *
 140  * @fname[in]     File name to check
 141  * @fstype[out]   File system type if retval is true
 142  *
 143  * @retval true                If fname is on NFS, Lustre or Panasas
 144  * @retval false               otherwise
 145  */
 146 PMIX_EXPORT bool pmix_path_nfs(char *fname, char **fstype) __pmix_attribute_warn_unused_result__;
 147 
 148 /**
 149  * @brief Returns the disk usage of path.
 150  *
 151  * @param[in] path       Path to check
 152  * @out_avail[out]       Amount of free space available on path (if successful)
 153  *
 154  * @retval PMIX_SUCCESS  If the operation was successful
 155  * @retval PMIX_ERROR    otherwise
 156  */
 157 PMIX_EXPORT int pmix_path_df(const char *path,
 158                              uint64_t *out_avail)__pmix_attribute_warn_unused_result__;
 159 
 160 END_C_DECLS
 161 #endif /* PMIX_PATH_H */

/* [<][>][^][v][top][bottom][index][help] */