/usr/include/arc/FileAccess.h is in nordugrid-arc-dev 4.2.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | #ifndef __ARC_FILEACCESS_H__
#define __ARC_FILEACCESS_H__
#include <string>
#include <list>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <glibmm.h>
#ifdef WIN32
#ifndef uid_t
#define uid_t int
#endif
#ifndef gid_t
#define gid_t int
#endif
#endif
namespace Arc {
class Run;
/// Defines interface for accessing filesystems.
/** This class accesses the local filesystem through a proxy executable
which allows switching user id in multithreaded systems without
introducing conflict with other threads. Its methods are mostly
replicas of corresponding POSIX functions with some convenience
tweaking.
\ingroup common
\headerfile FileAccess.h arc/FileAccess.h
*/
class FileAccess {
public:
/// New FileAccess object.
FileAccess(void);
/// Shuts down any spawned executable.
~FileAccess(void);
/// Constructor which takes already existing object from global cache
static FileAccess* Acquire(void);
/// Destructor which returns object into global cache
static void Release(FileAccess* fa);
/// Check if communication with proxy works
bool ping(void);
/// Modify user uid and gid.
/**
* If any is set to 0 then executable is switched to original uid/gid.
*
* \since Renamed in 3.0.0 from setuid
*/
bool fa_setuid(int uid,int gid);
/// Make a directory and assign it specified mode.
/**
* \since Renamed in 3.0.0 from mkdir
*/
bool fa_mkdir(const std::string& path, mode_t mode);
/// Make a directory and assign it specified mode.
/**
* If missing all intermediate directories are created too.
*
* \since Renamed in 3.0.0 from mkdirp
*/
bool fa_mkdirp(const std::string& path, mode_t mode);
/// Create hard link.
/**
* \since Renamed in 3.0.0 from link
*/
bool fa_link(const std::string& oldpath, const std::string& newpath);
/// Create symbolic (aka soft) link.
/**
* \since Renamed in 3.0.0 form softlink
*/
bool fa_softlink(const std::string& oldpath, const std::string& newpath);
/// Copy file to new location.
/**
* If new file is created it is assigned specified mode.
*
* \since Renamed in 3.0.0 from copy
*/
bool fa_copy(const std::string& oldpath, const std::string& newpath, mode_t mode);
/// Rename file
/**
* \since Renamed in 3.0.0 from rename
*/
bool fa_rename(const std::string& oldpath, const std::string& newpath);
/// Change mode of filesystem object
/**
* \since Renamed in 3.0.0 from chmod
*/
bool fa_chmod(const std::string& path,mode_t mode);
/// Stat file.
/**
* \since Renamed in 3.0.0 from stat
*/
bool fa_stat(const std::string& path, struct stat& st);
/// Stat symbolic link or file.
/**
* \since Renamed in 3.0.0 from lstat
*/
bool fa_lstat(const std::string& path, struct stat& st);
/// Stat open file.
/**
* \since Renamed in 3.0.0 from fstat
*/
bool fa_fstat(struct stat& st);
/// Truncate open file.
/**
* \since Renamed in 3.0.0 from ftruncate
*/
bool fa_ftruncate(off_t length);
/// Allocate disk space for open file.
/**
* \since Renamed in 3.0.0 from fallocate
*/
off_t fa_fallocate(off_t length);
/// Read content of symbolic link.
/**
* \since Renamed in 3.0.0 from readlink
*/
bool fa_readlink(const std::string& path, std::string& linkpath);
/// Remove file system object.
/**
* \since Renamed in 3.0.0 from remove
*/
bool fa_remove(const std::string& path);
/// Remove file.
/**
* \since Renamed in 3.0.0 from unlink
*/
bool fa_unlink(const std::string& path);
/// Remove directory (if empty).
/**
* \since Renamed in 3.0.0 from rmdir
*/
bool fa_rmdir(const std::string& path);
/// Remove directory recursively.
/**
* \since Renamed in 3.0.0 from rmdirr
*/
bool fa_rmdirr(const std::string& path);
/// Open directory.
/**
* Only one directory may be open at a time.
*
* \since Renamed in 3.0.0 from opendir
*/
bool fa_opendir(const std::string& path);
/// Close open directory.
/**
* \since Renamed in 3.0.0 from closedir
*/
bool fa_closedir(void);
/// Read relative name of object in open directory.
/**
* \since Renamed in 3.0.0 from readdir
*/
bool fa_readdir(std::string& name);
/// Open file. Only one file may be open at a time.
/**
* \since Renamed in 3.0.0 from open
*/
bool fa_open(const std::string& path, int flags, mode_t mode);
/// Close open file.
/**
* \since Renamed in 3.0.0 from close
*/
bool fa_close(void);
/// Open new temporary file for writing.
/**
* On input path contains template of file name ending with XXXXXX.
* On output path is path to created file.
*
* \since Renamed in 3.0.0 from mkstemp
*/
bool fa_mkstemp(std::string& path, mode_t mode);
/// Change current position in open file.
/**
* \since Renamed in 3.0.0 from lseek
*/
off_t fa_lseek(off_t offset, int whence);
/// Read from open file.
/**
* \since Renamed in 3.0.0 from read
*/
ssize_t fa_read(void* buf,size_t size);
/// Write to open file.
/**
* \since Renamed in 3.0.0 from write
*/
ssize_t fa_write(const void* buf,size_t size);
/// Read from open file at specified offset.
/**
* \since Renamed in 3.0.0 from pread
*/
ssize_t fa_pread(void* buf,size_t size,off_t offset);
/// Write to open file at specified offset.
/**
* \since Renamed in 3.0.0 from pwrite
*/
ssize_t fa_pwrite(const void* buf,size_t size,off_t offset);
/// Get errno of last operation. Every operation resets errno.
int geterrno() { return errno_; };
/// Returns true if this instance is in useful condition
operator bool(void) { return (file_access_ != NULL); };
/// Returns true if this instance is not in useful condition
bool operator!(void) { return (file_access_ == NULL); };
/// Special method for using in unit tests.
static void testtune(void);
private:
Glib::Mutex lock_;
Run* file_access_;
int errno_;
uid_t uid_;
gid_t gid_;
public:
/// Internal struct used for communication between processes.
typedef struct {
unsigned int size;
unsigned int cmd;
} header_t;
};
/// Container for shared FileAccess objects.
/** FileAccessContainer maintains a pool of executables and can be used to
reduce the overhead in creating and destroying executables when using
FileAccess.
\ingroup common
\headerfile FileAccess.h arc/FileAccess.h */
class FileAccessContainer {
public:
/// Creates container with number of stored objects between minval and maxval.
FileAccessContainer(unsigned int minval, unsigned int maxval);
/// Creates container with number of stored objects between 1 and 10.
FileAccessContainer(void);
/// Destroys container and all stored objects.
~FileAccessContainer(void);
/// Get object from container.
/** Object either is taken from stored ones or new one created.
Acquired object looses its connection to container and
can be safely destroyed or returned into other container. */
FileAccess* Acquire(void);
/// Returns object into container.
/** It can be any object - taken from another container or created using
new. */
void Release(FileAccess* fa);
/// Adjust minimal number of stored objects.
void SetMin(unsigned int val);
/// Adjust maximal number of stored objects.
void SetMax(unsigned int val);
private:
Glib::Mutex lock_;
unsigned int min_;
unsigned int max_;
std::list<FileAccess*> fas_;
void KeepRange(void);
};
} // namespace Arc
#endif // __ARC_FILEACCESS_H__
|