LogCabin
Namespaces | Functions | Variables
Storage/FilesystemUtil.cc File Reference
#include <assert.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <sys/file.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/uio.h>
#include <unistd.h>
#include "Core/Debug.h"
#include "Core/StringUtil.h"
#include "Core/Util.h"
#include "Storage/FilesystemUtil.h"

Go to the source code of this file.

Namespaces

namespace  LogCabin
namespace  LogCabin::Storage
namespace  LogCabin::Storage::FilesystemUtil
namespace  LogCabin::Storage::FilesystemUtil::System

Functions

void LogCabin::Storage::FilesystemUtil::allocate (const File &file, uint64_t offset, uint64_t bytes)
 Allocate a contiguous range of a file, padding with zeros if necessary.
File LogCabin::Storage::FilesystemUtil::dup (const File &file)
 Clones a file descriptor.
void LogCabin::Storage::FilesystemUtil::fsync (const File &file)
 Flush changes to a File to its underlying storage device.
void LogCabin::Storage::FilesystemUtil::fdatasync (const File &file)
 Flush changes to a File to its underlying storage device, except for atime/mtime.
void LogCabin::Storage::FilesystemUtil::flock (const File &file, int operation)
 Apply or remove an advisory lock on a file or directory.
std::string LogCabin::Storage::FilesystemUtil::tryFlock (const File &file, int operation)
 Apply or remove an advisory lock on a file or directory.
uint64_t LogCabin::Storage::FilesystemUtil::getSize (const File &file)
 Returns the size of the file in bytes.
std::vector< std::string > LogCabin::Storage::FilesystemUtil::lsHelper (DIR *dir, const std::string &path)
std::vector< std::string > LogCabin::Storage::FilesystemUtil::ls (const std::string &path)
 List the contents of a directory by path.
std::vector< std::string > LogCabin::Storage::FilesystemUtil::ls (const File &dir)
 List the contents of an open directory.
File LogCabin::Storage::FilesystemUtil::openDir (const std::string &path)
 Open a directory, creating it if it doesn't exist.
File LogCabin::Storage::FilesystemUtil::openDir (const File &dir, const std::string &child)
 Open a directory relative to an already open directory, creating it if it doesn't exist.
File LogCabin::Storage::FilesystemUtil::openFile (const File &dir, const std::string &child, int flags)
 Open a file.
File LogCabin::Storage::FilesystemUtil::tryOpenFile (const File &dir, const std::string &child, int flags)
 Open a file.
void LogCabin::Storage::FilesystemUtil::remove (const std::string &path)
 Remove the file or directory at path.
void LogCabin::Storage::FilesystemUtil::removeFile (const File &dir, const std::string &path)
 Remove the file relative to an open directory.
void LogCabin::Storage::FilesystemUtil::rename (const File &oldDir, const std::string &oldChild, const File &newDir, const std::string &newChild)
 Rename a file.
void LogCabin::Storage::FilesystemUtil::syncDir (const std::string &path)
 Open a directory, fsync it, and close it.
void LogCabin::Storage::FilesystemUtil::truncate (const File &file, uint64_t bytes)
 Shrink or grow a file to the specified length, padding with zeros if necessary.
std::string LogCabin::Storage::FilesystemUtil::mkdtemp ()
 Return a path to a temporary directory.
ssize_t LogCabin::Storage::FilesystemUtil::write (int fildes, const void *data, uint64_t dataLen)
 A wrapper around write that retries interrupted calls.
ssize_t LogCabin::Storage::FilesystemUtil::write (int fildes, std::initializer_list< std::pair< const void *, uint64_t >> data)
 A wrapper around write that retries interrupted calls.

Variables

bool LogCabin::Storage::FilesystemUtil::skipFsync
 Set to true in some unit tests to skip fsync() and fdatasync(), which can speeds up some tests significantly.
ssize_t(* LogCabin::Storage::FilesystemUtil::System::writev )(int fildes, const struct iovec *iov, int iovcnt)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines