![]() |
|
|||
File indexing completed on 2025-02-22 10:47:27
0001 /* 0002 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana 0003 * University Research and Technology 0004 * Corporation. All rights reserved. 0005 * Copyright (c) 2004-2007 The University of Tennessee and The University 0006 * of Tennessee Research Foundation. All rights 0007 * reserved. 0008 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 0009 * University of Stuttgart. All rights reserved. 0010 * Copyright (c) 2004-2005 The Regents of the University of California. 0011 * All rights reserved. 0012 * Copyright (c) 2012 Los Alamos National Security, LLC. 0013 * All rights reserved. 0014 * Copyright (c) 2016 University of Houston. All rights reserved. 0015 * Copyright (c) 2016-2020 Intel, Inc. All rights reserved. 0016 * Copyright (c) 2021-2023 Nanook Consulting. All rights reserved. 0017 * $COPYRIGHT$ 0018 * 0019 * Additional copyrights may follow 0020 * 0021 * $HEADER$ 0022 * 0023 * @file 0024 */ 0025 0026 #ifndef PMIX_PATH_H 0027 #define PMIX_PATH_H 0028 0029 #include "src/include/pmix_config.h" 0030 0031 #include "pmix_common.h" 0032 0033 #ifdef HAVE_UNISTD_H 0034 # include <unistd.h> 0035 #endif 0036 0037 BEGIN_C_DECLS 0038 0039 /** 0040 * Locates a file with certain permissions 0041 * 0042 * @param fname File name 0043 * @param pathv Array of search directories 0044 * @param mode Permissions which must be satisfied (see access(2)) 0045 * @param envv Pointer to string containing environment 0046 * 0047 * @retval Full pathname of located file Success 0048 * @retval NULL Failure 0049 * 0050 * Environment variables can appear in the form $variable at the 0051 * start of a prefix path and will be replaced by the environment 0052 * value if it is defined; otherwise the whole prefix is ignored. 0053 * Environment variables must be followed by a path delimiter or 0054 * end-of-string. 0055 * 0056 * The caller is responsible for freeing the returned string. 0057 */ 0058 PMIX_EXPORT char *pmix_path_find(char *fname, char **pathv, int mode, char **envv) 0059 __pmix_attribute_malloc__ __pmix_attribute_warn_unused_result__; 0060 0061 /** 0062 * Locates a file with certain permissions from a list of search 0063 * paths 0064 * 0065 * @param fname File name 0066 * @param mode Target permissions which must be satisfied (see access(2)) 0067 * @param envv Pointer to environment list 0068 * @param wrkdir Working directory 0069 * 0070 * @retval Full pathname of located file Success 0071 * @retval NULL Failure 0072 * 0073 * Locates a file with certain permissions from the list of paths 0074 * given by the $PATH environment variable. Replaces "." in the 0075 * path with the working dir. 0076 * 0077 * The caller is responsible for freeing the returned string. 0078 */ 0079 PMIX_EXPORT char *pmix_path_findv(char *fname, int mode, char **envv, char *wrkdir) 0080 __pmix_attribute_malloc__ __pmix_attribute_warn_unused_result__; 0081 /** 0082 * Detect if the requested path is absolute or relative. 0083 * 0084 * @param path File name 0085 * 0086 * @retval true if the path is absolute 0087 * @retval false otherwise 0088 * 0089 * Detect if a path is absolute or relative. Handle Windows 0090 * with special care as an absolute path on Windows starts 0091 * with [A-Za-z]: or \\ instead of the usual / on UNIX. 0092 */ 0093 PMIX_EXPORT bool pmix_path_is_absolute(const char *path); 0094 0095 /** 0096 * Find the absolute path for an executable and return it. 0097 * 0098 * @param app_name Executable name 0099 * 0100 * @retval The absolute path if the application can be reached, 0101 * @retval NULL otherwise. 0102 * 0103 * Try to figure out the absolute path based on the application name 0104 * (usually argv[0]). If the path is already absolute return a copy, if 0105 * it start with . look into the current directory, if not dig into 0106 * the $PATH. 0107 * In case of error or if executable was not found (as an example if 0108 * the application did a cwd between the start and this call), the 0109 * function will return NULL. Otherwise, an newly allocated string 0110 * will be returned. 0111 */ 0112 PMIX_EXPORT char *pmix_find_absolute_path(char *app_name) __pmix_attribute_warn_unused_result__; 0113 0114 /** 0115 * Forms a complete pathname and checks it for existence and 0116 * permissions 0117 * 0118 * @param fname File name 0119 * @param path Path prefix, if NULL then fname is an absolute path 0120 * @param mode Target permissions which must be satisfied (see access(2)) 0121 * 0122 * @retval NULL Failure 0123 * @retval Full pathname of the located file on Success 0124 * 0125 * The caller is responsible for freeing the returned string. 0126 */ 0127 PMIX_EXPORT char *pmix_path_access(char *fname, char *path, int mode) 0128 __pmix_attribute_malloc__ __pmix_attribute_warn_unused_result__; 0129 0130 /** 0131 * @brief Figure out whether fname is on network file system 0132 * and return fstype if known 0133 * 0134 * Try to figure out whether the file name specified through fname is 0135 * on any network file system (currently NFS, Lustre, GPFS, Panasas 0136 * and PVFS2 ). 0137 * 0138 * If the file is not created, the parent directory is checked. 0139 * This allows checking for NFS prior to opening the file. 0140 * 0141 * @fname[in] File name to check 0142 * @fstype[out] File system type if retval is true 0143 * 0144 * @retval true If fname is on NFS, Lustre or Panasas 0145 * @retval false otherwise 0146 */ 0147 PMIX_EXPORT bool pmix_path_nfs(char *fname, char **fstype) __pmix_attribute_warn_unused_result__; 0148 0149 /** 0150 * @brief Returns the disk usage of path. 0151 * 0152 * @param[in] path Path to check 0153 * @out_avail[out] Amount of free space available on path (if successful) 0154 * 0155 * @retval PMIX_SUCCESS If the operation was successful 0156 * @retval PMIX_ERROR otherwise 0157 */ 0158 PMIX_EXPORT int pmix_path_df(const char *path, 0159 uint64_t *out_avail) __pmix_attribute_warn_unused_result__; 0160 0161 END_C_DECLS 0162 #endif /* PMIX_PATH_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |