CernVM-FS  2.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
posix.h File Reference
#include <pthread.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
#include <cassert>
#include <cstddef>
#include <map>
#include <set>
#include <string>
#include <vector>
#include "shortstring.h"
#include "util/pointer.h"
#include "util/single_copy.h"
Include dependency graph for posix.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  FileSystemInfo
 
struct  LsofEntry
 
struct  Pipe
 

Enumerations

enum  EFileSystemTypes {
  kFsTypeUnknown = 0, kFsTypeAutofs = 0x0187, kFsTypeNFS = 0x6969, kFsTypeProc = 0x9fa0,
  kFsTypeBeeGFS = 0x19830326
}
 

Functions

std::string MakeCanonicalPath (const std::string &path)
 
std::string GetParentPath (const std::string &path)
 
PathString GetParentPath (const PathString &path)
 
std::string GetFileName (const std::string &path)
 
NameString GetFileName (const PathString &path)
 
void SplitPath (const std::string &path, std::string *dirname, std::string *filename)
 
bool IsAbsolutePath (const std::string &path)
 
std::string GetAbsolutePath (const std::string &path)
 
bool IsHttpUrl (const std::string &path)
 
std::string ReadSymlink (const std::string &path)
 
std::string ResolvePath (const std::string &path)
 
bool IsMountPoint (const std::string &path)
 
FileSystemInfo GetFileSystemInfo (const std::string &path)
 
void CreateFile (const std::string &path, const int mode, const bool ignore_failure=false)
 
int MakeSocket (const std::string &path, const int mode)
 
int MakeTcpEndpoint (const std::string &ipv4_address, int portno)
 
int ConnectSocket (const std::string &path)
 
int ConnectTcpEndpoint (const std::string &ipv4_address, int portno)
 
void MakePipe (int pipe_fd[2])
 
void WritePipe (int fd, const void *buf, size_t nbyte)
 
void ReadPipe (int fd, void *buf, size_t nbyte)
 
void ReadHalfPipe (int fd, void *buf, size_t nbyte)
 
void ClosePipe (int pipe_fd[2])
 
bool DiffTree (const std::string &path_a, const std::string &path_b)
 
void Nonblock2Block (int filedes)
 
void Block2Nonblock (int filedes)
 
void SendMsg2Socket (const int fd, const std::string &msg)
 
bool SendFd2Socket (int socket_fd, int passing_fd)
 
int RecvFdFromSocket (int msg_fd)
 
bool SwitchCredentials (const uid_t uid, const gid_t gid, const bool temporarily)
 
bool FileExists (const std::string &path)
 
int64_t GetFileSize (const std::string &path)
 
bool DirectoryExists (const std::string &path)
 
bool SymlinkExists (const std::string &path)
 
bool SymlinkForced (const std::string &src, const std::string &dest)
 
bool MkdirDeep (const std::string &path, const mode_t mode, bool verify_writable=true)
 
bool MakeCacheDirectories (const std::string &path, const mode_t mode)
 
FILE * CreateTempFile (const std::string &path_prefix, const int mode, const char *open_flags, std::string *final_path)
 
std::string CreateTempPath (const std::string &path_prefix, const int mode)
 
std::string CreateTempDir (const std::string &path_prefix)
 
std::string GetCurrentWorkingDirectory ()
 
int TryLockFile (const std::string &path)
 
int LockFile (const std::string &path)
 
int WritePidFile (const std::string &path)
 
void UnlockFile (const int filedes)
 
bool RemoveTree (const std::string &path)
 
std::vector< std::string > FindFilesBySuffix (const std::string &dir, const std::string &suffix)
 
std::vector< std::string > FindFilesByPrefix (const std::string &dir, const std::string &prefix)
 
std::vector< std::string > FindDirectories (const std::string &parent_dir)
 
std::string FindExecutable (const std::string &exe)
 
bool ListDirectory (const std::string &directory, std::vector< std::string > *names, std::vector< mode_t > *modes)
 
std::string GetUserName ()
 
std::string GetShell ()
 
bool GetUserNameOf (uid_t uid, std::string *username)
 
bool GetUidOf (const std::string &username, uid_t *uid, gid_t *main_gid)
 
bool GetGidOf (const std::string &groupname, gid_t *gid)
 
mode_t GetUmask ()
 
bool AddGroup2Persona (const gid_t gid)
 
std::string GetHomeDirectory ()
 
int SetLimitNoFile (unsigned limit_nofile)
 
void GetLimitNoFile (unsigned *soft_limit, unsigned *hard_limit)
 
std::vector< LsofEntryLsof (const std::string &path)
 
bool ProcessExists (pid_t pid)
 
void BlockSignal (int signum)
 
void WaitForSignal (int signum)
 
int WaitForChild (pid_t pid)
 
void Daemonize ()
 
bool Shell (int *pipe_stdin, int *pipe_stdout, int *pipe_stderr)
 
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=true, pid_t *child_pid=NULL)
 
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=false, const bool double_fork=true, pid_t *child_pid=NULL)
 
void SafeSleepMs (const unsigned ms)
 
ssize_t SafeRead (int fd, void *buf, size_t nbyte)
 
bool SafeWrite (int fd, const void *buf, size_t nbyte)
 
bool SafeWriteV (int fd, struct iovec *iov, unsigned iovcnt)
 
bool SafeReadToString (int fd, std::string *final_result)
 
bool SafeWriteToFile (const std::string &content, const std::string &path, int mode)
 

Variables

const unsigned kPageSize = 4096
 
const size_t kMaxPathLength = 256
 
const int kDefaultFileMode = S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH
 
const int kDefaultDirMode
 
const int kPrivateFileMode = S_IWUSR | S_IRUSR
 
const int kPrivateDirMode = S_IXUSR | S_IWUSR | S_IRUSR
 

Enumeration Type Documentation

The magic numbers that identify a file system in statfs() Adjust GetFileSystemInfo() when new file systems are added

Enumerator
kFsTypeUnknown 
kFsTypeAutofs 
kFsTypeNFS 
kFsTypeProc 
kFsTypeBeeGFS 

Definition at line 41 of file posix.h.

Function Documentation

bool AddGroup2Persona ( const gid_t  gid)

Adds gid to the list of supplementary groups

Definition at line 1421 of file posix.cc.

Referenced by main().

Here is the caller graph for this function:

void Block2Nonblock ( int  filedes)

Changes a blocking file descriptor to a non-blocking one.

Definition at line 675 of file posix.cc.

Referenced by Watchdog::GenerateStackTrace(), and PosixQuotaManager::MainCommandServer().

Here is the call graph for this function:

Here is the caller graph for this function:

void BlockSignal ( int  signum)

Blocks a signal for the calling thread.

Definition at line 1583 of file posix.cc.

Referenced by FuseMain().

Here is the call graph for this function:

Here is the caller graph for this function:

int ConnectSocket ( const std::string &  path)

Connects to a named socket.

Returns
socket file descriptor on success, -1 else

Definition at line 456 of file posix.cc.

Referenced by CheckConcurrentMount(), ExternalCacheManager::ConnectLocator(), GetExistingFuseFd(), loader::loader_talk::MainReload(), SendCommand(), cvmfs::SendFuseFd(), and publish::SendTalkCommand().

Here is the call graph for this function:

Here is the caller graph for this function:

int ConnectTcpEndpoint ( const std::string &  ipv4_address,
int  portno 
)

Connects to a (remote) TCP server

Definition at line 490 of file posix.cc.

Referenced by ExternalCacheManager::ConnectLocator().

Here is the call graph for this function:

Here is the caller graph for this function:

void CreateFile ( const std::string &  path,
const int  mode,
const bool  ignore_failure 
)

By default PANIC(NULL) on failure

Definition at line 309 of file posix.cc.

Referenced by publish::CmdEnter::CreateUnderlay(), FuseMain(), loader::Reload(), FileSystem::SetupNfsMaps(), and FileSystem::SetupPosixCacheMgr().

Here is the caller graph for this function:

std::string CreateTempDir ( const std::string &  path_prefix)

Create a directory with a unique name.

Definition at line 1067 of file posix.cc.

Referenced by publish::ClearScratch(), GetExistingFuseFd(), publish::CmdEnter::Main(), and MakeShortSocketLink().

Here is the caller graph for this function:

void Daemonize ( )

Makes a daemon. The daemon() call is deprecated on OS X

Definition at line 1632 of file posix.cc.

Referenced by FuseMain(), PosixQuotaManager::MainCacheManager(), and Watchdog::Spawn().

Here is the call graph for this function:

Here is the caller graph for this function:

bool DiffTree ( const std::string &  path_a,
const std::string &  path_b 
)

Compares two directory trees on the meta-data level. Returns true iff the trees have identical content.

Definition at line 589 of file posix.cc.

Referenced by DiffTree().

Here is the call graph for this function:

Here is the caller graph for this function:

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 = true,
pid_t *  child_pid = NULL 
)

Definition at line 1663 of file posix.cc.

Referenced by Watchdog::GenerateStackTrace(), main(), and Shell().

Here is the call graph for this function:

Here is the caller graph for this function:

bool FileExists ( const std::string &  path)

Checks if the regular file path exists.

Definition at line 811 of file posix.cc.

Referenced by publish::CallServerHook(), MountPoint::CheckBlacklists(), PosixCacheManager::Create(), swissknife::CommandApplyDirtab::CreateCatalogMarkers(), publish::CheckoutMarker::CreateFrom(), publish::SettingsBuilder::CreateSettingsPublisher(), PosixQuotaManager::CreateShared(), swissknife::CommandInfo::Exists(), swissknife::CommandCheck::Exists(), LocalObjectFetcher< CatalogT, HistoryT, ReflogT >::Fetch(), LocalObjectFetcher< CatalogT, HistoryT, ReflogT >::FetchManifest(), swissknife::CommandApplyDirtab::FilterCandidatesFromGlobResult(), AuthzExternalFetcher::FindHelper(), GetCvmfsBinary(), publish::SettingsKeychain::HasDanglingMasterKeys(), publish::SettingsKeychain::HasDanglingRepositoryKeys(), publish::SettingsKeychain::HasGatewayKey(), publish::SettingsKeychain::HasMasterKeys(), publish::SettingsKeychain::HasRepositoryKeys(), swissknife::CommandTag::InitializeEnvironment(), InitializeGarbageCollection(), publish::SyncUnionAufs::IsOpaqueDirectory(), swissknife::CommandApplyDirtab::Main(), PosixQuotaManager::MainCacheManager(), PosixQuotaManager::MainCommandServer(), SpecTree::Open(), catalog::Dirtab::Open(), StatisticsDatabase::OpenStandardDB(), upload::S3Uploader::ParseSpoolerDefinition(), upload::LocalUploader::Peek(), swissknife::Peek(), posix_cleanup_path(), posix_do_link(), posix_has_file(), publish::Publisher(), MountPoint::ReloadBlacklists(), FileSystem::SetupNfsMaps(), and WaitForReload().

Here is the call graph for this function:

Here is the caller graph for this function:

std::vector<std::string> FindDirectories ( const std::string &  parent_dir)

Finds all direct subdirectories under parent_dir (except ., ..). Used, for instance, to parse /etc/cvmfs/repositories.d/<reponoame>

Definition at line 1199 of file posix.cc.

Referenced by publish::SettingsBuilder::GetSingleAlias().

Here is the call graph for this function:

Here is the caller graph for this function:

std::string FindExecutable ( const std::string &  exe)

Looks whether exe is an executable file. If exe is not an absolute path, searches the PATH environment.

Definition at line 1264 of file posix.cc.

Referenced by publish::CmdEnter::MountCvmfs(), and publish::CmdEnter::MountOverlayfs().

Here is the call graph for this function:

Here is the caller graph for this function:

std::vector<std::string> FindFilesByPrefix ( const std::string &  dir,
const std::string &  prefix 
)

Returns ls $dir/$prefixGLOB

Definition at line 1171 of file posix.cc.

Here is the call graph for this function:

std::vector<std::string> FindFilesBySuffix ( const std::string &  dir,
const std::string &  suffix 
)
std::string GetAbsolutePath ( const std::string &  path)

Definition at line 192 of file posix.cc.

Referenced by publish::SyncUnionTarball::Initialize(), and swissknife::CommandFileStats::Run().

Here is the call graph for this function:

Here is the caller graph for this function:

std::string GetCurrentWorkingDirectory ( )

Get the current working directory of the running process

Definition at line 1080 of file posix.cc.

Referenced by CreateMountNamespace(), GetAbsolutePath(), publish::CmdAbort::Main(), and publish::CmdEnter::Main().

Here is the caller graph for this function:

NameString GetFileName ( const PathString path)

Definition at line 168 of file posix.cc.

Here is the call graph for this function:

FileSystemInfo GetFileSystemInfo ( const std::string &  path)

Definition at line 212 of file posix.cc.

Referenced by PosixCacheManager::Create(), and publish::CmdTransaction::Main().

Here is the caller graph for this function:

bool GetGidOf ( const std::string &  groupname,
gid_t *  gid 
)

Name -> GID from groups database

Definition at line 1387 of file posix.cc.

Referenced by main().

Here is the caller graph for this function:

std::string GetHomeDirectory ( )

Definition at line 1444 of file posix.cc.

Referenced by publish::CmdEnter::Main().

Here is the caller graph for this function:

void GetLimitNoFile ( unsigned *  soft_limit,
unsigned *  hard_limit 
)

Get the file descriptor limits

Definition at line 1490 of file posix.cc.

Referenced by MountPoint::CreateCatalogManager(), FuseMain(), and monitor::GetMaxOpenFiles().

Here is the call graph for this function:

Here is the caller graph for this function:

PathString GetParentPath ( const PathString path)

Gets the file name part of a path.

Definition at line 141 of file posix.cc.

Here is the call graph for this function:

std::string GetShell ( )

Definition at line 1320 of file posix.cc.

Referenced by publish::CmdEnter::Main().

Here is the caller graph for this function:

bool GetUidOf ( const std::string &  username,
uid_t *  uid,
gid_t *  main_gid 
)

Name -> UID from passwd database

Definition at line 1364 of file posix.cc.

Referenced by main(), publish::SettingsPublisher::SetOwner(), and MountPoint::SetupBehavior().

Here is the caller graph for this function:

mode_t GetUmask ( )

read the current umask of this process Note: umask query is guarded by a global mutex. Hence, always use this function and beware of scalability bottlenecks

Definition at line 1410 of file posix.cc.

std::string GetUserName ( )

Definition at line 1302 of file posix.cc.

Referenced by publish::CmdMkfs::Main().

Here is the caller graph for this function:

bool GetUserNameOf ( uid_t  uid,
std::string *  username 
)

UID -> Name from passwd database

Definition at line 1341 of file posix.cc.

Referenced by publish::CmdAbort::Main().

Here is the caller graph for this function:

bool IsAbsolutePath ( const std::string &  path)

Definition at line 187 of file posix.cc.

Referenced by GetAbsolutePath().

Here is the caller graph for this function:

bool IsHttpUrl ( const std::string &  path)
bool IsMountPoint ( const std::string &  path)

Definition at line 295 of file posix.cc.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

bool ListDirectory ( const std::string &  directory,
std::vector< std::string > *  names,
std::vector< mode_t > *  modes 
)

Finds all files and direct subdirectories under directory (except ., ..).

Definition at line 1228 of file posix.cc.

Referenced by publish::ClearScratch(), publish::CmdEnter::CreateUnderlay(), and Lsof().

Here is the call graph for this function:

Here is the caller graph for this function:

int LockFile ( const std::string &  path)

Locks file path, blocks if file is already locked. Creates path if required.

Returns
file descriptor, -1 on error

Definition at line 991 of file posix.cc.

Referenced by PosixQuotaManager::CreateShared(), PosixQuotaManager::InitDatabase(), FileSystem::LockWorkspace(), and PosixQuotaManager::MainCacheManager().

Here is the caller graph for this function:

std::vector<LsofEntry> Lsof ( const std::string &  path)

Searches for open file descriptors on the subtree starting at path. For the time being works only on Linux, not on macOS.

Definition at line 1509 of file posix.cc.

Referenced by publish::CmdAbort::Main().

Here is the call graph for this function:

Here is the caller graph for this function:

bool MakeCacheDirectories ( const std::string &  path,
const mode_t  mode 
)

Creates the "hash cache" directory structure in path.

Definition at line 902 of file posix.cc.

Referenced by upload::LocalUploader::Create(), PosixCacheManager::Create(), FuseMain(), and main().

Here is the call graph for this function:

Here is the caller graph for this function:

int MakeSocket ( const std::string &  path,
const int  mode 
)

Creates and binds to a named socket.

Definition at line 360 of file posix.cc.

Referenced by TalkManager::Create(), GetExistingFuseFd(), loader::loader_talk::Init(), and CachePlugin::Listen().

Here is the call graph for this function:

Here is the caller graph for this function:

int MakeTcpEndpoint ( const std::string &  ipv4_address,
int  portno 
)

Creates and binds a TCP/IPv4 socket. An empty address binds to the "any" address.

Definition at line 418 of file posix.cc.

Referenced by CachePlugin::Listen().

Here is the call graph for this function:

Here is the caller graph for this function:

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 
)

Execve to the given command line, preserving the given file descriptors. If stdin, stdout, stderr should be preserved, add 0, 1, 2. File descriptors from the parent process can also be mapped to the new process (dup2) using map_fildes. Can be useful for stdout/in/err redirection. NOTE: The destination fildes have to be preserved! Does a double fork to detach child. The command_line parameter contains the binary at index 0 and the arguments in the rest of the vector. Using the optional parameter *pid it is possible to retrieve the process ID of the spawned process.

Definition at line 1774 of file posix.cc.

Referenced by publish::CallServerHook(), PosixQuotaManager::CreateShared(), ExecuteBinary(), publish::CmdEnter::Main(), publish::CmdEnter::MountCvmfs(), publish::CmdEnter::MountOverlayfs(), publish::RunSuidHelper(), and ExternalCacheManager::SpawnPlugin().

Here is the call graph for this function:

Here is the caller graph for this function:

void Nonblock2Block ( int  filedes)

Changes a non-blocking file descriptor to a blocking one.

Definition at line 664 of file posix.cc.

Referenced by PosixQuotaManager::BindReturnPipe(), PosixQuotaManager::CreateShared(), PosixQuotaManager::MainCacheManager(), and PosixQuotaManager::MakeReturnPipe().

Here is the call graph for this function:

Here is the caller graph for this function:

bool ProcessExists ( pid_t  pid)

Definition at line 1571 of file posix.cc.

Referenced by publish::CmdEnter::CleanupSession(), and publish::ServerLockFile::IsLocked().

Here is the call graph for this function:

Here is the caller graph for this function:

void ReadHalfPipe ( int  fd,
void *  buf,
size_t  nbyte 
)
std::string ReadSymlink ( const std::string &  path)

Definition at line 252 of file posix.cc.

Referenced by Lsof().

Here is the caller graph for this function:

int RecvFdFromSocket ( int  msg_fd)

Returns the file descriptor that has been sent with SendFd2Socket. The msg_fd file descriptor needs to come from a call to accept() on the socket where the passing file descriptor has been sent to. Returns -errno on error.

Definition at line 736 of file posix.cc.

Referenced by GetExistingFuseFd().

Here is the call graph for this function:

Here is the caller graph for this function:

bool RemoveTree ( const std::string &  path)

Does rm -rf on path.

Definition at line 1115 of file posix.cc.

Referenced by publish::CmdEnter::CleanupSession(), NfsMapsLeveldb::Create(), and RaiiTempDir::~RaiiTempDir().

Here is the call graph for this function:

Here is the caller graph for this function:

std::string ResolvePath ( const std::string &  path)

Follow all symlinks if possible. Equivalent to readlink --canonicalize-missing

Definition at line 68 of file cvmfs_suid_util.cc.

Referenced by IsMountPoint(), Mount(), and ResolvePath().

Here is the call graph for this function:

Here is the caller graph for this function:

ssize_t SafeRead ( int  fd,
void *  buf,
size_t  nbyte 
)

Deal with EINTR and partial reads.

Definition at line 1977 of file posix.cc.

Referenced by CheckNamespaceFeatures(), anonymous_namespace{cmd_enter.cc}::EnterRootContainer(), FileIngestionSource::Read(), receiver::Reactor::ReadReply(), receiver::Reactor::ReadRequest(), AuthzExternalFetcher::Recv(), CacheTransport::RecvFrame(), CacheTransport::RecvHeader(), and SafeReadToString().

Here is the call graph for this function:

Here is the caller graph for this function:

bool SafeReadToString ( int  fd,
std::string *  final_result 
)

Pull file contents into a string

Definition at line 2000 of file posix.cc.

Referenced by notify::DoPublish(), swissknife::Ingest::Main(), swissknife::CommandSync::Main(), gateway::ReadKeys(), and download::ResolveProxyDescription().

Here is the call graph for this function:

Here is the caller graph for this function:

bool SafeWrite ( int  fd,
const void *  buf,
size_t  nbyte 
)
bool SafeWriteToFile ( const std::string &  content,
const std::string &  path,
int  mode 
)

Definition at line 2016 of file posix.cc.

Referenced by publish::ExportKeychain(), swissknife::CommandLease::Main(), publish::CmdEnter::Main(), download::ResolveProxyDescription(), SigningTool::Run(), publish::CheckoutMarker::SaveAs(), and publish::CmdEnter::WriteCvmfsConfig().

Here is the call graph for this function:

Here is the caller graph for this function:

bool SafeWriteV ( int  fd,
struct iovec *  iov,
unsigned  iovcnt 
)

The contents of the iov vector might be modified by the function.

Definition at line 1937 of file posix.cc.

Referenced by CacheTransport::SendData().

Here is the call graph for this function:

Here is the caller graph for this function:

bool SendFd2Socket ( int  socket_fd,
int  passing_fd 
)

Sends the file descriptor passing_fd to the socket socket_fd. Can be used to transfer an open file descriptor from one process to another. Use ConnectSocket() to get the socket_fd.

Definition at line 696 of file posix.cc.

Referenced by cvmfs::SendFuseFd().

Here is the caller graph for this function:

void SendMsg2Socket ( const int  fd,
const std::string &  msg 
)

Drops the characters of string to a socket. It doesn't matter if the other side has hung up.

Definition at line 687 of file posix.cc.

Referenced by CheckConcurrentMount(), FreeSavedState(), CacheManager::FreeState(), GetExistingFuseFd(), loader::loader_talk::MainTalk(), MaintenanceMode(), loader::Reload(), CacheManager::RestoreState(), RestoreState(), CacheManager::SaveState(), and SaveState().

Here is the caller graph for this function:

int SetLimitNoFile ( unsigned  limit_nofile)

Sets soft and hard limit for maximum number of open file descriptors. Returns 0 on success, -1 on failure, -2 if running under valgrind.

Definition at line 1468 of file posix.cc.

Referenced by FuseMain(), and LibGlobals::Initialize().

Here is the caller graph for this function:

bool Shell ( int *  fd_stdin,
int *  fd_stdout,
int *  fd_stderr 
)

Opens /bin/sh and provides file descriptors to write into stdin and read from stdout. Quit shell simply by closing stderr, stdout, and stdin.

Definition at line 1719 of file posix.cc.

Referenced by BashOptionsManager::ParsePath().

Here is the call graph for this function:

Here is the caller graph for this function:

void SplitPath ( const std::string &  path,
std::string *  dirname,
std::string *  filename 
)

Return both the file and directory name for a given path.

NOTE: If only a filename is given, the directory is returned as "."

Definition at line 110 of file posix.cc.

Referenced by catalog::WritableCatalogManager::Clone(), publish::SyncUnionTarball::CreateDirectories(), publish::SyncUnionTarball::ProcessArchiveEntry(), swissknife::CommandGraft::Publish(), and publish::SyncUnionTarball::Traverse().

Here is the caller graph for this function:

bool SwitchCredentials ( const uid_t  uid,
const gid_t  gid,
const bool  temporarily 
)

set(e){g/u}id wrapper.

Definition at line 781 of file posix.cc.

Referenced by FuseMain(), Watchdog::GenerateStackTrace(), publish::CmdAbort::Main(), publish::CmdTransaction::Main(), ManagedExec(), SwitchCredentials(), and auto_umount::UmountOnCrash().

Here is the call graph for this function:

Here is the caller graph for this function:

bool SymlinkExists ( const std::string &  path)

Checks if the symlink file path exists.

Definition at line 843 of file posix.cc.

Referenced by CheckNamespaceFeatures(), swissknife::CommandCheck::Exists(), GetCvmfsBinary(), posix_cleanup_path(), and ResolvePath().

Here is the call graph for this function:

Here is the caller graph for this function:

bool SymlinkForced ( const std::string &  src,
const std::string &  dest 
)

Equivalent of ln -sf $src $dest

Definition at line 853 of file posix.cc.

Referenced by publish::CmdEnter::CreateUnderlay(), publish::CmdEnter::Main(), and upload::LocalUploader::PlaceBootstrappingShortcut().

Here is the caller graph for this function:

int TryLockFile ( const std::string &  path)

Tries to locks file path, return an error if file is already locked. Creates path if required.

Returns
file descriptor, -1 on error, -2 if it would block

Definition at line 933 of file posix.cc.

Referenced by CachePlugin::Listen(), and FileSystem::LockWorkspace().

Here is the caller graph for this function:

void UnlockFile ( const int  filedes)
int WaitForChild ( pid_t  pid)

Returns -1 of the child crashed or the exit code otherwise

Definition at line 1610 of file posix.cc.

Referenced by publish::CallServerHook(), publish::CmdEnter::Main(), publish::CmdEnter::MountCvmfs(), publish::CmdEnter::MountOverlayfs(), and publish::RunSuidHelper().

Here is the call graph for this function:

Here is the caller graph for this function:

void WaitForSignal ( int  signum)

Waits for a signal. The signal should be blocked before for all threads. Threads inherit their parent's signal mask.

Definition at line 1598 of file posix.cc.

Referenced by loader::Reload().

Here is the call graph for this function:

Here is the caller graph for this function:

int WritePidFile ( const std::string &  path)

Tries to write the process id in a /var/run/progname.pid like file. Returns the same as TryLockFile.

Returns
file descriptor, -1 on error, -2 if it would block

Definition at line 955 of file posix.cc.

Here is the call graph for this function:

void WritePipe ( int  fd,
const void *  buf,
size_t  nbyte 
)

Writes to a pipe should always succeed.

Definition at line 529 of file posix.cc.

Referenced by CachePlugin::AskToDetach(), publish::CallServerHook(), PosixQuotaManager::Cleanup(), PosixQuotaManager::DoInsert(), PosixQuotaManager::DoList(), download::DownloadManager::Fetch(), download::DownloadManager::Fini(), PosixQuotaManager::GetCleanupRate(), PosixQuotaManager::GetLimits(), PosixQuotaManager::GetPid(), PosixQuotaManager::GetProtocolRevision(), PosixQuotaManager::GetSharedStatus(), shrinkwrap::handle_file(), FuseInvalidator::InvalidateInodes(), swissknife::CommandPull::Main(), PosixQuotaManager::MainCacheManager(), PosixQuotaManager::MainCommandServer(), download::DownloadManager::MainDownload(), loader::loader_talk::MainReload(), CachePlugin::NotifySupervisor(), upload::S3Uploader::OnReqComplete(), BashOptionsManager::ParsePath(), PosixQuotaManager::Pin(), swissknife::CommandPull::Pull(), s3fanout::S3FanoutManager::PushCompletedJob(), s3fanout::S3FanoutManager::PushNewJob(), PosixQuotaManager::RegisterBackChannel(), PosixQuotaManager::Remove(), file_watcher::FileWatcherKqueue::RunEventLoop(), file_watcher::FileWatcherInotify::RunEventLoop(), SendCommand(), publish::SendTalkCommand(), FuseRemounter::SetAlarm(), cvmfs::Fetcher::SignalWaitingThreads(), file_watcher::FileWatcher::Stop(), shrinkwrap::SyncInit(), CachePlugin::Terminate(), PosixQuotaManager::Touch(), PosixQuotaManager::Unpin(), PosixQuotaManager::UnregisterBackChannel(), quota::UnregisterListener(), Pipe::Write(), FuseInvalidator::~FuseInvalidator(), FuseRemounter::~FuseRemounter(), glue::NentryTracker::~NentryTracker(), PosixQuotaManager::~PosixQuotaManager(), and s3fanout::S3FanoutManager::~S3FanoutManager().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

const int kDefaultDirMode
Initial value:
= S_IXUSR | S_IWUSR | S_IRUSR |
S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH

Definition at line 32 of file posix.h.

Referenced by publish::ExportKeychain().

const size_t kMaxPathLength = 256

Definition at line 30 of file posix.h.

const unsigned kPageSize = 4096

This file is part of the CernVM File System.

Definition at line 29 of file posix.h.

Referenced by upload::LocalUploader::DoUpload(), upload::S3Uploader::DoUpload(), AuthzExternalFetcher::Recv(), and RamCacheManager::StartTxn().

const int kPrivateDirMode = S_IXUSR | S_IWUSR | S_IRUSR