5 #ifndef CVMFS_UTIL_POSIX_H_
6 #define CVMFS_UTIL_POSIX_H_
10 #include <sys/types.h>
26 #ifdef CVMFS_NAMESPACE_GUARD
27 namespace CVMFS_NAMESPACE_GUARD {
34 S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
74 std::string *filename);
85 const bool ignore_failure =
false);
97 const std::string &path_b);
107 const bool temporarily);
114 const std::string &dest);
116 bool verify_writable =
true);
121 const char *open_flags,
122 std::string *final_path);
134 const std::string &suffix);
137 const std::string &prefix);
139 std::vector<std::string>
FindDirectories(
const std::string &parent_dir);
142 std::vector<std::string> *names,
143 std::vector<mode_t> *modes);
172 const std::vector<int> &sig_ok = std::vector<int>());
175 pid_t *child_pid = NULL);
180 const std::string &binary_path,
181 const std::vector<std::string> &argv,
182 const bool double_fork =
true,
183 pid_t *child_pid = NULL);
185 const std::set<int> &preserve_fildes,
186 const std::map<int, int> &map_fildes,
187 const bool drop_credentials,
188 const bool clear_env =
false,
189 const bool double_fork =
true,
190 pid_t *child_pid = NULL);
203 const std::string &path,
int mode);
205 #ifdef CVMFS_NAMESPACE_GUARD
209 #endif // CVMFS_UTIL_POSIX_H_
bool MakeCacheDirectories(const std::string &path, const mode_t mode)
int MakeSocket(const std::string &path, const int mode)
bool SymlinkForced(const std::string &src, const std::string &dest)
NameString GetFileName(const PathString &path)
const int kPrivateDirMode
int MakeTcpEndpoint(const std::string &ipv4_address, int portno)
std::string GetUserName()
const int kDefaultFileMode
void CreateFile(const std::string &path, const int mode, const bool ignore_failure)
bool GetUserNameOf(uid_t uid, std::string *username)
FILE * CreateTempFile(const std::string &path_prefix, const int mode, const char *open_flags, std::string *final_path)
int ConnectTcpEndpoint(const std::string &ipv4_address, int portno)
bool Shell(int *fd_stdin, int *fd_stdout, int *fd_stderr)
bool IsHttpUrl(const std::string &path)
bool ManagedExec(const std::vector< std::string > &command_line, const std::set< int > &preserve_fildes, const std::map< int, int > &map_fildes, const bool drop_credentials, const bool clear_env, const bool double_fork, pid_t *child_pid)
std::string CreateTempPath(const std::string &path_prefix, const int mode)
bool SafeWrite(int fd, const void *buf, size_t nbyte)
void SendMsg2Socket(const int fd, const std::string &msg)
bool SafeWriteToFile(const std::string &content, const std::string &path, int mode)
std::string FindExecutable(const std::string &exe)
bool SendFd2Socket(int socket_fd, int passing_fd)
int WaitForChild(pid_t pid, const std::vector< int > &sig_ok)
bool AddGroup2Persona(const gid_t gid)
void MakePipe(int pipe_fd[2])
std::vector< std::string > FindDirectories(const std::string &parent_dir)
int SetLimitNoFile(unsigned limit_nofile)
bool SymlinkExists(const std::string &path)
bool FileExists(const std::string &path)
const int kPrivateFileMode
std::string GetAbsolutePath(const std::string &path)
void SplitPath(const std::string &path, std::string *dirname, std::string *filename)
std::string GetHostname()
void GetLimitNoFile(unsigned *soft_limit, unsigned *hard_limit)
bool ReadHalfPipe(int fd, void *buf, size_t nbyte, unsigned timeout_ms)
ssize_t SafeRead(int fd, void *buf, size_t nbyte)
const int kDefaultDirMode
FileSystemInfo GetFileSystemInfo(const std::string &path)
void Nonblock2Block(int filedes)
int TryLockFile(const std::string &path)
bool MkdirDeep(const std::string &path, const mode_t mode, bool verify_writable)
int LockFile(const std::string &path)
string ResolvePath(const std::string &path)
std::string GetHomeDirectory()
void WaitForSignal(int signum)
bool GetGidOf(const std::string &groupname, gid_t *gid)
std::string CreateTempDir(const std::string &path_prefix)
bool DirectoryExists(const std::string &path)
bool ExecuteBinary(int *fd_stdin, int *fd_stdout, int *fd_stderr, const std::string &binary_path, const std::vector< std::string > &argv, const bool double_fork, pid_t *child_pid)
bool RemoveTree(const std::string &path)
bool SafeReadToString(int fd, std::string *final_result)
bool CloseAllFildes(const std::set< int > &preserve_fildes)
int WritePidFile(const std::string &path)
int ConnectSocket(const std::string &path)
bool GetUidOf(const std::string &username, uid_t *uid, gid_t *main_gid)
std::vector< std::string > FindFilesByPrefix(const std::string &dir, const std::string &prefix)
bool SwitchCredentials(const uid_t uid, const gid_t gid, const bool temporarily)
bool ExecAsDaemon(const std::vector< std::string > &command_line, pid_t *child_pid)
std::string ReadSymlink(const std::string &path)
PathString GetParentPath(const PathString &path)
std::vector< LsofEntry > Lsof(const std::string &path)
bool ListDirectory(const std::string &directory, std::vector< std::string > *names, std::vector< mode_t > *modes)
int64_t GetFileSize(const std::string &path)
void SafeSleepMs(const unsigned ms)
bool DiffTree(const std::string &path_a, const std::string &path_b)
void Block2Nonblock(int filedes)
bool IsAbsolutePath(const std::string &path)
bool ProcessExists(pid_t pid)
std::string MakeCanonicalPath(const std::string &path)
void WritePipe(int fd, const void *buf, size_t nbyte)
std::string GetCurrentWorkingDirectory()
void ReadPipe(int fd, void *buf, size_t nbyte)
std::vector< std::string > FindFilesBySuffix(const std::string &dir, const std::string &suffix)
void ClosePipe(int pipe_fd[2])
bool IsMountPoint(const std::string &path)
int RecvFdFromSocket(int msg_fd)
const size_t kMaxPathLength
bool SafeWriteV(int fd, struct iovec *iov, unsigned iovcnt)
void UnlockFile(const int filedes)
void BlockSignal(int signum)