- Fix clash of our ERROR log level with the ERROR macro defined in windows
- Fix definition of log levels so msvc accepts them
This commit is contained in:
parent
6a37f750f4
commit
9d872ea00c
@ -62,7 +62,7 @@ bool OnDiskBlockStore2::remove(const BlockId &blockId) {
|
|||||||
}
|
}
|
||||||
bool retval = boost::filesystem::remove(filepath);
|
bool retval = boost::filesystem::remove(filepath);
|
||||||
if (!retval) {
|
if (!retval) {
|
||||||
cpputils::logging::LOG(cpputils::logging::ERROR, "Couldn't find block {} to remove", blockId.ToString());
|
cpputils::logging::LOG(cpputils::logging::ERR, "Couldn't find block {} to remove", blockId.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (boost::filesystem::is_empty(filepath.parent_path())) {
|
if (boost::filesystem::is_empty(filepath.parent_path())) {
|
||||||
|
@ -23,13 +23,13 @@ namespace cpputils {
|
|||||||
inline void assert_fail_release [[noreturn]] (const char *expr, const std::string &message, const char *file, int line) {
|
inline void assert_fail_release [[noreturn]] (const char *expr, const std::string &message, const char *file, int line) {
|
||||||
auto msg = format(expr, message, file, line);
|
auto msg = format(expr, message, file, line);
|
||||||
using namespace logging;
|
using namespace logging;
|
||||||
LOG(ERROR, msg);
|
LOG(ERR, msg);
|
||||||
throw AssertFailed(msg);
|
throw AssertFailed(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void assert_fail_debug [[noreturn]] (const char *expr, const std::string &message, const char *file, int line) {
|
inline void assert_fail_debug [[noreturn]] (const char *expr, const std::string &message, const char *file, int line) {
|
||||||
using namespace logging;
|
using namespace logging;
|
||||||
LOG(ERROR, format(expr, message, file, line));
|
LOG(ERR, format(expr, message, file, line));
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ namespace {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
void sigsegv_handler(int) {
|
void sigsegv_handler(int) {
|
||||||
LOG(ERROR, "SIGSEGV\n{}", backtrace());
|
LOG(ERR, "SIGSEGV\n{}", backtrace());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,7 +70,7 @@ namespace {
|
|||||||
void showBacktraceOnSigSegv() {
|
void showBacktraceOnSigSegv() {
|
||||||
auto result = signal(SIGSEGV, sigsegv_handler);
|
auto result = signal(SIGSEGV, sigsegv_handler);
|
||||||
if (SIG_ERR == result) {
|
if (SIG_ERR == result) {
|
||||||
LOG(ERROR, "Failed to set sigsegv signal handler. Errno: {}", errno);
|
LOG(ERR, "Failed to set sigsegv signal handler. Errno: {}", errno);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ namespace cpputils {
|
|||||||
LONG WINAPI TopLevelExceptionHandler(PEXCEPTION_POINTERS pExceptionInfo)
|
LONG WINAPI TopLevelExceptionHandler(PEXCEPTION_POINTERS pExceptionInfo)
|
||||||
{
|
{
|
||||||
std::string backtrace = backtrace_to_string(pExceptionInfo->ContextRecord);
|
std::string backtrace = backtrace_to_string(pExceptionInfo->ContextRecord);
|
||||||
LOG(ERROR, "Top level exception. Backtrace:\n{}", backtrace);
|
LOG(ERR, "Top level exception. Backtrace:\n{}", backtrace);
|
||||||
|
|
||||||
return EXCEPTION_CONTINUE_SEARCH;
|
return EXCEPTION_CONTINUE_SEARCH;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ namespace cpputils {
|
|||||||
optional<Data> RandomPadding::remove(const Data &data) {
|
optional<Data> RandomPadding::remove(const Data &data) {
|
||||||
uint32_t size = deserialize<uint32_t>(data.data());
|
uint32_t size = deserialize<uint32_t>(data.data());
|
||||||
if(sizeof(size) + size >= data.size()) {
|
if(sizeof(size) + size >= data.size()) {
|
||||||
LOG(ERROR, "Config file is invalid: Invalid padding.");
|
LOG(ERR, "Config file is invalid: Invalid padding.");
|
||||||
return boost::none;
|
return boost::none;
|
||||||
};
|
};
|
||||||
Data result(size);
|
Data result(size);
|
||||||
|
@ -9,10 +9,15 @@
|
|||||||
namespace cpputils {
|
namespace cpputils {
|
||||||
namespace logging {
|
namespace logging {
|
||||||
|
|
||||||
constexpr struct ERROR_TYPE {} ERROR {};
|
struct ERROR_TYPE {};
|
||||||
constexpr struct WARN_TYPE {} WARN {};
|
struct WARN_TYPE {};
|
||||||
constexpr struct INFO_TYPE {} INFO {};
|
struct INFO_TYPE {};
|
||||||
constexpr struct DEBUG_TYPE {} DEBUG {};
|
struct DEBUG_TYPE {};
|
||||||
|
|
||||||
|
constexpr ERROR_TYPE ERR;
|
||||||
|
constexpr WARN_TYPE WARN;
|
||||||
|
constexpr INFO_TYPE INFO;
|
||||||
|
constexpr DEBUG_TYPE DEBUG;
|
||||||
|
|
||||||
inline void setLogger(std::shared_ptr<spdlog::logger> newLogger) {
|
inline void setLogger(std::shared_ptr<spdlog::logger> newLogger) {
|
||||||
logger().setLogger(newLogger);
|
logger().setLogger(newLogger);
|
||||||
|
@ -34,13 +34,13 @@ namespace cpputils {
|
|||||||
// Create a new SID for the child process
|
// Create a new SID for the child process
|
||||||
pid_t sid = setsid();
|
pid_t sid = setsid();
|
||||||
if (sid < 0) {
|
if (sid < 0) {
|
||||||
LOG(ERROR, "Failed to get SID for daemon process");
|
LOG(ERR, "Failed to get SID for daemon process");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change the current working directory to a directory that's always existin
|
// Change the current working directory to a directory that's always existin
|
||||||
if ((chdir("/")) < 0) {
|
if ((chdir("/")) < 0) {
|
||||||
LOG(ERROR, "Failed to change working directory for daemon process");
|
LOG(ERR, "Failed to change working directory for daemon process");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ void TempDir::remove() {
|
|||||||
bf::remove_all(_path);
|
bf::remove_all(_path);
|
||||||
}
|
}
|
||||||
} catch (const boost::filesystem::filesystem_error &e) {
|
} catch (const boost::filesystem::filesystem_error &e) {
|
||||||
LOG(ERROR, "Could not delete tempfile.");
|
LOG(ERR, "Could not delete tempfile.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ TempFile::~TempFile() {
|
|||||||
bf::remove(_path);
|
bf::remove(_path);
|
||||||
}
|
}
|
||||||
} catch (const boost::filesystem::filesystem_error &e) {
|
} catch (const boost::filesystem::filesystem_error &e) {
|
||||||
LOG(ERROR, "Could not delete tempfile.");
|
LOG(ERR, "Could not delete tempfile.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,9 +77,9 @@ namespace cpputils {
|
|||||||
} catch (const boost::thread_interrupted &e) {
|
} catch (const boost::thread_interrupted &e) {
|
||||||
//Do nothing, exit thread.
|
//Do nothing, exit thread.
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
LOG(ERROR, "LoopThread crashed: {}", e.what());
|
LOG(ERR, "LoopThread crashed: {}", e.what());
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
LOG(ERROR, "LoopThread crashed");
|
LOG(ERR, "LoopThread crashed");
|
||||||
}
|
}
|
||||||
//TODO We should remove the thread from _runningThreads here, not in stop().
|
//TODO We should remove the thread from _runningThreads here, not in stop().
|
||||||
}
|
}
|
||||||
|
@ -259,9 +259,9 @@ namespace cryfs {
|
|||||||
} catch (const CryfsException &e) {
|
} catch (const CryfsException &e) {
|
||||||
throw; // CryfsException is only thrown if setup goes wrong. Throw it through so that we get the correct process exit code.
|
throw; // CryfsException is only thrown if setup goes wrong. Throw it through so that we get the correct process exit code.
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
LOG(ERROR, "Crashed: {}", e.what());
|
LOG(ERR, "Crashed: {}", e.what());
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
LOG(ERROR, "Crashed");
|
LOG(ERR, "Crashed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ CryConfigFile::~CryConfigFile() {
|
|||||||
optional<CryConfigFile> CryConfigFile::load(bf::path path, const string &password) {
|
optional<CryConfigFile> CryConfigFile::load(bf::path path, const string &password) {
|
||||||
auto encryptedConfigData = Data::LoadFromFile(path);
|
auto encryptedConfigData = Data::LoadFromFile(path);
|
||||||
if (encryptedConfigData == none) {
|
if (encryptedConfigData == none) {
|
||||||
LOG(ERROR, "Config file not found");
|
LOG(ERR, "Config file not found");
|
||||||
return none;
|
return none;
|
||||||
}
|
}
|
||||||
auto encryptor = CryConfigEncryptorFactory::loadKey(*encryptedConfigData, password);
|
auto encryptor = CryConfigEncryptorFactory::loadKey(*encryptedConfigData, password);
|
||||||
@ -41,7 +41,7 @@ optional<CryConfigFile> CryConfigFile::load(bf::path path, const string &passwor
|
|||||||
}
|
}
|
||||||
CryConfig config = CryConfig::load(decrypted->data);
|
CryConfig config = CryConfig::load(decrypted->data);
|
||||||
if (config.Cipher() != decrypted->cipherName) {
|
if (config.Cipher() != decrypted->cipherName) {
|
||||||
LOG(ERROR, "Inner cipher algorithm used to encrypt config file doesn't match config value");
|
LOG(ERR, "Inner cipher algorithm used to encrypt config file doesn't match config value");
|
||||||
return none;
|
return none;
|
||||||
}
|
}
|
||||||
auto configFile = CryConfigFile(std::move(path), std::move(config), std::move(*encryptor));
|
auto configFile = CryConfigFile(std::move(path), std::move(config), std::move(*encryptor));
|
||||||
|
@ -33,12 +33,12 @@ namespace cryfs {
|
|||||||
template<class Cipher>
|
template<class Cipher>
|
||||||
boost::optional<cpputils::Data> ConcreteInnerEncryptor<Cipher>::decrypt(const InnerConfig &innerConfig) const {
|
boost::optional<cpputils::Data> ConcreteInnerEncryptor<Cipher>::decrypt(const InnerConfig &innerConfig) const {
|
||||||
if (innerConfig.cipherName != Cipher::NAME) {
|
if (innerConfig.cipherName != Cipher::NAME) {
|
||||||
cpputils::logging::LOG(cpputils::logging::ERROR, "Initialized ConcreteInnerEncryptor with wrong cipher");
|
cpputils::logging::LOG(cpputils::logging::ERR, "Initialized ConcreteInnerEncryptor with wrong cipher");
|
||||||
return boost::none;
|
return boost::none;
|
||||||
}
|
}
|
||||||
auto decrypted = Cipher::decrypt(static_cast<const uint8_t*>(innerConfig.encryptedConfig.data()), innerConfig.encryptedConfig.size(), _key);
|
auto decrypted = Cipher::decrypt(static_cast<const uint8_t*>(innerConfig.encryptedConfig.data()), innerConfig.encryptedConfig.size(), _key);
|
||||||
if (decrypted == boost::none) {
|
if (decrypted == boost::none) {
|
||||||
cpputils::logging::LOG(cpputils::logging::ERROR, "Failed decrypting configuration file");
|
cpputils::logging::LOG(cpputils::logging::ERR, "Failed decrypting configuration file");
|
||||||
return boost::none;
|
return boost::none;
|
||||||
}
|
}
|
||||||
auto configData = cpputils::RandomPadding::remove(*decrypted);
|
auto configData = cpputils::RandomPadding::remove(*decrypted);
|
||||||
|
@ -23,7 +23,7 @@ namespace cryfs {
|
|||||||
serializer.writeTailData(encryptedConfig);
|
serializer.writeTailData(encryptedConfig);
|
||||||
return serializer.finished();
|
return serializer.finished();
|
||||||
} catch (const exception &e) {
|
} catch (const exception &e) {
|
||||||
LOG(ERROR, "Error serializing inner configuration: {}", e.what());
|
LOG(ERR, "Error serializing inner configuration: {}", e.what());
|
||||||
throw; // This is a programming logic error, pass through exception.
|
throw; // This is a programming logic error, pass through exception.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -37,7 +37,7 @@ namespace cryfs {
|
|||||||
deserializer.finished();
|
deserializer.finished();
|
||||||
return InnerConfig {cipherName, std::move(result)};
|
return InnerConfig {cipherName, std::move(result)};
|
||||||
} catch (const exception &e) {
|
} catch (const exception &e) {
|
||||||
LOG(ERROR, "Error deserializing inner configuration: {}", e.what());
|
LOG(ERR, "Error deserializing inner configuration: {}", e.what());
|
||||||
return none; // This can be caused by invalid input data and does not have to be a programming error. Don't throw exception.
|
return none; // This can be caused by invalid input data and does not have to be a programming error. Don't throw exception.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ namespace cryfs {
|
|||||||
serializer.writeTailData(encryptedInnerConfig);
|
serializer.writeTailData(encryptedInnerConfig);
|
||||||
return serializer.finished();
|
return serializer.finished();
|
||||||
} catch (const exception &e) {
|
} catch (const exception &e) {
|
||||||
LOG(ERROR, "Error serializing CryConfigEncryptor: {}", e.what());
|
LOG(ERR, "Error serializing CryConfigEncryptor: {}", e.what());
|
||||||
throw; // This is a programming logic error. Pass through exception.
|
throw; // This is a programming logic error. Pass through exception.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ namespace cryfs {
|
|||||||
return _deserializeNewFormat(&deserializer);
|
return _deserializeNewFormat(&deserializer);
|
||||||
#endif
|
#endif
|
||||||
} catch (const exception &e) {
|
} catch (const exception &e) {
|
||||||
LOG(ERROR, "Error deserializing outer configuration: {}", e.what());
|
LOG(ERR, "Error deserializing outer configuration: {}", e.what());
|
||||||
return none; // This can be caused by invalid input data and does not have to be a programming error. Don't throw exception.
|
return none; // This can be caused by invalid input data and does not have to be a programming error. Don't throw exception.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,7 +201,7 @@ CryDevice::BlobWithParent CryDevice::LoadBlobWithParent(const bf::path &path) {
|
|||||||
optional<unique_ref<DirBlobRef>> parentBlob = none;
|
optional<unique_ref<DirBlobRef>> parentBlob = none;
|
||||||
optional<unique_ref<FsBlobRef>> currentBlobOpt = _fsBlobStore->load(_rootBlobId);
|
optional<unique_ref<FsBlobRef>> currentBlobOpt = _fsBlobStore->load(_rootBlobId);
|
||||||
if (currentBlobOpt == none) {
|
if (currentBlobOpt == none) {
|
||||||
LOG(ERROR, "Could not load root blob. Is the base directory accessible?");
|
LOG(ERR, "Could not load root blob. Is the base directory accessible?");
|
||||||
throw FuseErrnoException(EIO);
|
throw FuseErrnoException(EIO);
|
||||||
}
|
}
|
||||||
unique_ref<FsBlobRef> currentBlob = std::move(*currentBlobOpt);
|
unique_ref<FsBlobRef> currentBlob = std::move(*currentBlobOpt);
|
||||||
@ -267,7 +267,7 @@ unique_ref<SymlinkBlobRef> CryDevice::CreateSymlinkBlob(const bf::path &target,
|
|||||||
unique_ref<FsBlobRef> CryDevice::LoadBlob(const blockstore::BlockId &blockId) {
|
unique_ref<FsBlobRef> CryDevice::LoadBlob(const blockstore::BlockId &blockId) {
|
||||||
auto blob = _fsBlobStore->load(blockId);
|
auto blob = _fsBlobStore->load(blockId);
|
||||||
if (blob == none) {
|
if (blob == none) {
|
||||||
LOG(ERROR, "Could not load blob {}. Is the base directory accessible?", blockId.ToString());
|
LOG(ERR, "Could not load blob {}. Is the base directory accessible?", blockId.ToString());
|
||||||
throw FuseErrnoException(EIO);
|
throw FuseErrnoException(EIO);
|
||||||
}
|
}
|
||||||
return std::move(*blob);
|
return std::move(*blob);
|
||||||
@ -276,7 +276,7 @@ unique_ref<FsBlobRef> CryDevice::LoadBlob(const blockstore::BlockId &blockId) {
|
|||||||
void CryDevice::RemoveBlob(const blockstore::BlockId &blockId) {
|
void CryDevice::RemoveBlob(const blockstore::BlockId &blockId) {
|
||||||
auto blob = _fsBlobStore->load(blockId);
|
auto blob = _fsBlobStore->load(blockId);
|
||||||
if (blob == none) {
|
if (blob == none) {
|
||||||
LOG(ERROR, "Could not load blob {}. Is the base directory accessible?", blockId.ToString());
|
LOG(ERR, "Could not load blob {}. Is the base directory accessible?", blockId.ToString());
|
||||||
throw FuseErrnoException(EIO);
|
throw FuseErrnoException(EIO);
|
||||||
}
|
}
|
||||||
_fsBlobStore->remove(std::move(*blob));
|
_fsBlobStore->remove(std::move(*blob));
|
||||||
|
@ -222,11 +222,11 @@ Fuse::Fuse(Filesystem *fs, std::string fstype, boost::optional<std::string> fsna
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Fuse::_logException(const std::exception &e) {
|
void Fuse::_logException(const std::exception &e) {
|
||||||
LOG(ERROR, "Exception thrown: {}", e.what());
|
LOG(ERR, "Exception thrown: {}", e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fuse::_logUnknownException() {
|
void Fuse::_logUnknownException() {
|
||||||
LOG(ERROR, "Unknown exception thrown");
|
LOG(ERR, "Unknown exception thrown");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fuse::run(const bf::path &mountdir, const vector<string> &fuseOptions) {
|
void Fuse::run(const bf::path &mountdir, const vector<string> &fuseOptions) {
|
||||||
@ -296,7 +296,7 @@ void Fuse::stop() {
|
|||||||
int ret = system(("fusermount -z -u " + _mountdir.native()).c_str()); // "-z" takes care that if the filesystem can't be unmounted right now because something is opened, it will be unmounted as soon as it can be.
|
int ret = system(("fusermount -z -u " + _mountdir.native()).c_str()); // "-z" takes care that if the filesystem can't be unmounted right now because something is opened, it will be unmounted as soon as it can be.
|
||||||
#endif
|
#endif
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
LOG(ERROR, "Could not unmount filesystem");
|
LOG(ERR, "Could not unmount filesystem");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,7 +308,7 @@ int Fuse::getattr(const bf::path &path, struct stat *stbuf) {
|
|||||||
_fs->lstat(path, stbuf);
|
_fs->lstat(path, stbuf);
|
||||||
return 0;
|
return 0;
|
||||||
} catch(const cpputils::AssertFailed &e) {
|
} catch(const cpputils::AssertFailed &e) {
|
||||||
LOG(ERROR, "AssertFailed in Fuse::getattr: {}", e.what());
|
LOG(ERR, "AssertFailed in Fuse::getattr: {}", e.what());
|
||||||
return -EIO;
|
return -EIO;
|
||||||
} catch(fspp::fuse::FuseErrnoException &e) {
|
} catch(fspp::fuse::FuseErrnoException &e) {
|
||||||
return -e.getErrno();
|
return -e.getErrno();
|
||||||
@ -339,7 +339,7 @@ int Fuse::fgetattr(const bf::path &path, struct stat *stbuf, fuse_file_info *fil
|
|||||||
_fs->fstat(fileinfo->fh, stbuf);
|
_fs->fstat(fileinfo->fh, stbuf);
|
||||||
return 0;
|
return 0;
|
||||||
} catch(const cpputils::AssertFailed &e) {
|
} catch(const cpputils::AssertFailed &e) {
|
||||||
LOG(ERROR, "AssertFailed in Fuse::fgetattr: {}", e.what());
|
LOG(ERR, "AssertFailed in Fuse::fgetattr: {}", e.what());
|
||||||
return -EIO;
|
return -EIO;
|
||||||
} catch(fspp::fuse::FuseErrnoException &e) {
|
} catch(fspp::fuse::FuseErrnoException &e) {
|
||||||
return -e.getErrno();
|
return -e.getErrno();
|
||||||
@ -360,7 +360,7 @@ int Fuse::readlink(const bf::path &path, char *buf, size_t size) {
|
|||||||
_fs->readSymlink(path, buf, size);
|
_fs->readSymlink(path, buf, size);
|
||||||
return 0;
|
return 0;
|
||||||
} catch(const cpputils::AssertFailed &e) {
|
} catch(const cpputils::AssertFailed &e) {
|
||||||
LOG(ERROR, "AssertFailed in Fuse::readlink: {}", e.what());
|
LOG(ERR, "AssertFailed in Fuse::readlink: {}", e.what());
|
||||||
return -EIO;
|
return -EIO;
|
||||||
} catch (fspp::fuse::FuseErrnoException &e) {
|
} catch (fspp::fuse::FuseErrnoException &e) {
|
||||||
return -e.getErrno();
|
return -e.getErrno();
|
||||||
@ -390,7 +390,7 @@ int Fuse::mkdir(const bf::path &path, mode_t mode) {
|
|||||||
_fs->mkdir(path, mode, context->uid, context->gid);
|
_fs->mkdir(path, mode, context->uid, context->gid);
|
||||||
return 0;
|
return 0;
|
||||||
} catch(const cpputils::AssertFailed &e) {
|
} catch(const cpputils::AssertFailed &e) {
|
||||||
LOG(ERROR, "AssertFailed in Fuse::mkdir: {}", e.what());
|
LOG(ERR, "AssertFailed in Fuse::mkdir: {}", e.what());
|
||||||
return -EIO;
|
return -EIO;
|
||||||
} catch(fspp::fuse::FuseErrnoException &e) {
|
} catch(fspp::fuse::FuseErrnoException &e) {
|
||||||
return -e.getErrno();
|
return -e.getErrno();
|
||||||
@ -411,7 +411,7 @@ int Fuse::unlink(const bf::path &path) {
|
|||||||
_fs->unlink(path);
|
_fs->unlink(path);
|
||||||
return 0;
|
return 0;
|
||||||
} catch(const cpputils::AssertFailed &e) {
|
} catch(const cpputils::AssertFailed &e) {
|
||||||
LOG(ERROR, "AssertFailed in Fuse::unlink: {}", e.what());
|
LOG(ERR, "AssertFailed in Fuse::unlink: {}", e.what());
|
||||||
return -EIO;
|
return -EIO;
|
||||||
} catch(fspp::fuse::FuseErrnoException &e) {
|
} catch(fspp::fuse::FuseErrnoException &e) {
|
||||||
return -e.getErrno();
|
return -e.getErrno();
|
||||||
@ -432,7 +432,7 @@ int Fuse::rmdir(const bf::path &path) {
|
|||||||
_fs->rmdir(path);
|
_fs->rmdir(path);
|
||||||
return 0;
|
return 0;
|
||||||
} catch(const cpputils::AssertFailed &e) {
|
} catch(const cpputils::AssertFailed &e) {
|
||||||
LOG(ERROR, "AssertFailed in Fuse::rmdir: {}", e.what());
|
LOG(ERR, "AssertFailed in Fuse::rmdir: {}", e.what());
|
||||||
return -EIO;
|
return -EIO;
|
||||||
} catch(fspp::fuse::FuseErrnoException &e) {
|
} catch(fspp::fuse::FuseErrnoException &e) {
|
||||||
return -e.getErrno();
|
return -e.getErrno();
|
||||||
@ -454,7 +454,7 @@ int Fuse::symlink(const bf::path &from, const bf::path &to) {
|
|||||||
_fs->createSymlink(from, to, context->uid, context->gid);
|
_fs->createSymlink(from, to, context->uid, context->gid);
|
||||||
return 0;
|
return 0;
|
||||||
} catch(const cpputils::AssertFailed &e) {
|
} catch(const cpputils::AssertFailed &e) {
|
||||||
LOG(ERROR, "AssertFailed in Fuse::symlink: {}", e.what());
|
LOG(ERR, "AssertFailed in Fuse::symlink: {}", e.what());
|
||||||
return -EIO;
|
return -EIO;
|
||||||
} catch(fspp::fuse::FuseErrnoException &e) {
|
} catch(fspp::fuse::FuseErrnoException &e) {
|
||||||
return -e.getErrno();
|
return -e.getErrno();
|
||||||
@ -477,7 +477,7 @@ int Fuse::rename(const bf::path &from, const bf::path &to) {
|
|||||||
_fs->rename(from, to);
|
_fs->rename(from, to);
|
||||||
return 0;
|
return 0;
|
||||||
} catch(const cpputils::AssertFailed &e) {
|
} catch(const cpputils::AssertFailed &e) {
|
||||||
LOG(ERROR, "AssertFailed in Fuse::rename: {}", e.what());
|
LOG(ERR, "AssertFailed in Fuse::rename: {}", e.what());
|
||||||
return -EIO;
|
return -EIO;
|
||||||
} catch(fspp::fuse::FuseErrnoException &e) {
|
} catch(fspp::fuse::FuseErrnoException &e) {
|
||||||
return -e.getErrno();
|
return -e.getErrno();
|
||||||
@ -508,7 +508,7 @@ int Fuse::chmod(const bf::path &path, mode_t mode) {
|
|||||||
_fs->chmod(path, mode);
|
_fs->chmod(path, mode);
|
||||||
return 0;
|
return 0;
|
||||||
} catch(const cpputils::AssertFailed &e) {
|
} catch(const cpputils::AssertFailed &e) {
|
||||||
LOG(ERROR, "AssertFailed in Fuse::chmod: {}", e.what());
|
LOG(ERR, "AssertFailed in Fuse::chmod: {}", e.what());
|
||||||
return -EIO;
|
return -EIO;
|
||||||
} catch (fspp::fuse::FuseErrnoException &e) {
|
} catch (fspp::fuse::FuseErrnoException &e) {
|
||||||
return -e.getErrno();
|
return -e.getErrno();
|
||||||
@ -529,7 +529,7 @@ int Fuse::chown(const bf::path &path, uid_t uid, gid_t gid) {
|
|||||||
_fs->chown(path, uid, gid);
|
_fs->chown(path, uid, gid);
|
||||||
return 0;
|
return 0;
|
||||||
} catch(const cpputils::AssertFailed &e) {
|
} catch(const cpputils::AssertFailed &e) {
|
||||||
LOG(ERROR, "AssertFailed in Fuse::chown: {}", e.what());
|
LOG(ERR, "AssertFailed in Fuse::chown: {}", e.what());
|
||||||
return -EIO;
|
return -EIO;
|
||||||
} catch (fspp::fuse::FuseErrnoException &e) {
|
} catch (fspp::fuse::FuseErrnoException &e) {
|
||||||
return -e.getErrno();
|
return -e.getErrno();
|
||||||
@ -550,7 +550,7 @@ int Fuse::truncate(const bf::path &path, off_t size) {
|
|||||||
_fs->truncate(path, size);
|
_fs->truncate(path, size);
|
||||||
return 0;
|
return 0;
|
||||||
} catch(const cpputils::AssertFailed &e) {
|
} catch(const cpputils::AssertFailed &e) {
|
||||||
LOG(ERROR, "AssertFailed in Fuse::truncate: {}", e.what());
|
LOG(ERR, "AssertFailed in Fuse::truncate: {}", e.what());
|
||||||
return -EIO;
|
return -EIO;
|
||||||
} catch (FuseErrnoException &e) {
|
} catch (FuseErrnoException &e) {
|
||||||
return -e.getErrno();
|
return -e.getErrno();
|
||||||
@ -572,7 +572,7 @@ int Fuse::ftruncate(const bf::path &path, off_t size, fuse_file_info *fileinfo)
|
|||||||
_fs->ftruncate(fileinfo->fh, size);
|
_fs->ftruncate(fileinfo->fh, size);
|
||||||
return 0;
|
return 0;
|
||||||
} catch(const cpputils::AssertFailed &e) {
|
} catch(const cpputils::AssertFailed &e) {
|
||||||
LOG(ERROR, "AssertFailed in Fuse::ftruncate: {}", e.what());
|
LOG(ERR, "AssertFailed in Fuse::ftruncate: {}", e.what());
|
||||||
return -EIO;
|
return -EIO;
|
||||||
} catch (FuseErrnoException &e) {
|
} catch (FuseErrnoException &e) {
|
||||||
return -e.getErrno();
|
return -e.getErrno();
|
||||||
@ -593,7 +593,7 @@ int Fuse::utimens(const bf::path &path, const timespec times[2]) {
|
|||||||
_fs->utimens(path, times[0], times[1]);
|
_fs->utimens(path, times[0], times[1]);
|
||||||
return 0;
|
return 0;
|
||||||
} catch(const cpputils::AssertFailed &e) {
|
} catch(const cpputils::AssertFailed &e) {
|
||||||
LOG(ERROR, "AssertFailed in Fuse::utimens: {}", e.what());
|
LOG(ERR, "AssertFailed in Fuse::utimens: {}", e.what());
|
||||||
return -EIO;
|
return -EIO;
|
||||||
} catch (FuseErrnoException &e) {
|
} catch (FuseErrnoException &e) {
|
||||||
return -e.getErrno();
|
return -e.getErrno();
|
||||||
@ -614,7 +614,7 @@ int Fuse::open(const bf::path &path, fuse_file_info *fileinfo) {
|
|||||||
fileinfo->fh = _fs->openFile(path, fileinfo->flags);
|
fileinfo->fh = _fs->openFile(path, fileinfo->flags);
|
||||||
return 0;
|
return 0;
|
||||||
} catch(const cpputils::AssertFailed &e) {
|
} catch(const cpputils::AssertFailed &e) {
|
||||||
LOG(ERROR, "AssertFailed in Fuse::open: {}", e.what());
|
LOG(ERR, "AssertFailed in Fuse::open: {}", e.what());
|
||||||
return -EIO;
|
return -EIO;
|
||||||
} catch (FuseErrnoException &e) {
|
} catch (FuseErrnoException &e) {
|
||||||
return -e.getErrno();
|
return -e.getErrno();
|
||||||
@ -636,7 +636,7 @@ int Fuse::release(const bf::path &path, fuse_file_info *fileinfo) {
|
|||||||
_fs->closeFile(fileinfo->fh);
|
_fs->closeFile(fileinfo->fh);
|
||||||
return 0;
|
return 0;
|
||||||
} catch(const cpputils::AssertFailed &e) {
|
} catch(const cpputils::AssertFailed &e) {
|
||||||
LOG(ERROR, "AssertFailed in Fuse::release: {}", e.what());
|
LOG(ERR, "AssertFailed in Fuse::release: {}", e.what());
|
||||||
return -EIO;
|
return -EIO;
|
||||||
} catch (FuseErrnoException &e) {
|
} catch (FuseErrnoException &e) {
|
||||||
return -e.getErrno();
|
return -e.getErrno();
|
||||||
@ -657,7 +657,7 @@ int Fuse::read(const bf::path &path, char *buf, size_t size, off_t offset, fuse_
|
|||||||
try {
|
try {
|
||||||
return _fs->read(fileinfo->fh, buf, size, offset);
|
return _fs->read(fileinfo->fh, buf, size, offset);
|
||||||
} catch(const cpputils::AssertFailed &e) {
|
} catch(const cpputils::AssertFailed &e) {
|
||||||
LOG(ERROR, "AssertFailed in Fuse::read: {}", e.what());
|
LOG(ERR, "AssertFailed in Fuse::read: {}", e.what());
|
||||||
return -EIO;
|
return -EIO;
|
||||||
} catch (FuseErrnoException &e) {
|
} catch (FuseErrnoException &e) {
|
||||||
return -e.getErrno();
|
return -e.getErrno();
|
||||||
@ -679,7 +679,7 @@ int Fuse::write(const bf::path &path, const char *buf, size_t size, off_t offset
|
|||||||
_fs->write(fileinfo->fh, buf, size, offset);
|
_fs->write(fileinfo->fh, buf, size, offset);
|
||||||
return size;
|
return size;
|
||||||
} catch(const cpputils::AssertFailed &e) {
|
} catch(const cpputils::AssertFailed &e) {
|
||||||
LOG(ERROR, "AssertFailed in Fuse::write: {}", e.what());
|
LOG(ERR, "AssertFailed in Fuse::write: {}", e.what());
|
||||||
return -EIO;
|
return -EIO;
|
||||||
} catch (FuseErrnoException &e) {
|
} catch (FuseErrnoException &e) {
|
||||||
return -e.getErrno();
|
return -e.getErrno();
|
||||||
@ -701,7 +701,7 @@ int Fuse::statfs(const bf::path &path, struct statvfs *fsstat) {
|
|||||||
_fs->statfs(path, fsstat);
|
_fs->statfs(path, fsstat);
|
||||||
return 0;
|
return 0;
|
||||||
} catch(const cpputils::AssertFailed &e) {
|
} catch(const cpputils::AssertFailed &e) {
|
||||||
LOG(ERROR, "AssertFailed in Fuse::statfs: {}", e.what());
|
LOG(ERR, "AssertFailed in Fuse::statfs: {}", e.what());
|
||||||
return -EIO;
|
return -EIO;
|
||||||
} catch (FuseErrnoException &e) {
|
} catch (FuseErrnoException &e) {
|
||||||
return -e.getErrno();
|
return -e.getErrno();
|
||||||
@ -723,7 +723,7 @@ int Fuse::flush(const bf::path &path, fuse_file_info *fileinfo) {
|
|||||||
_fs->flush(fileinfo->fh);
|
_fs->flush(fileinfo->fh);
|
||||||
return 0;
|
return 0;
|
||||||
} catch(const cpputils::AssertFailed &e) {
|
} catch(const cpputils::AssertFailed &e) {
|
||||||
LOG(ERROR, "AssertFailed in Fuse::flush: {}", e.what());
|
LOG(ERR, "AssertFailed in Fuse::flush: {}", e.what());
|
||||||
return -EIO;
|
return -EIO;
|
||||||
} catch (FuseErrnoException &e) {
|
} catch (FuseErrnoException &e) {
|
||||||
return -e.getErrno();
|
return -e.getErrno();
|
||||||
@ -749,7 +749,7 @@ int Fuse::fsync(const bf::path &path, int datasync, fuse_file_info *fileinfo) {
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} catch(const cpputils::AssertFailed &e) {
|
} catch(const cpputils::AssertFailed &e) {
|
||||||
LOG(ERROR, "AssertFailed in Fuse::fsync: {}", e.what());
|
LOG(ERR, "AssertFailed in Fuse::fsync: {}", e.what());
|
||||||
return -EIO;
|
return -EIO;
|
||||||
} catch (FuseErrnoException &e) {
|
} catch (FuseErrnoException &e) {
|
||||||
return -e.getErrno();
|
return -e.getErrno();
|
||||||
@ -799,7 +799,7 @@ int Fuse::readdir(const bf::path &path, void *buf, fuse_fill_dir_t filler, off_t
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} catch(const cpputils::AssertFailed &e) {
|
} catch(const cpputils::AssertFailed &e) {
|
||||||
LOG(ERROR, "AssertFailed in Fuse::readdir: {}", e.what());
|
LOG(ERR, "AssertFailed in Fuse::readdir: {}", e.what());
|
||||||
return -EIO;
|
return -EIO;
|
||||||
} catch (FuseErrnoException &e) {
|
} catch (FuseErrnoException &e) {
|
||||||
return -e.getErrno();
|
return -e.getErrno();
|
||||||
@ -853,7 +853,7 @@ int Fuse::access(const bf::path &path, int mask) {
|
|||||||
_fs->access(path, mask);
|
_fs->access(path, mask);
|
||||||
return 0;
|
return 0;
|
||||||
} catch(const cpputils::AssertFailed &e) {
|
} catch(const cpputils::AssertFailed &e) {
|
||||||
LOG(ERROR, "AssertFailed in Fuse::access: {}", e.what());
|
LOG(ERR, "AssertFailed in Fuse::access: {}", e.what());
|
||||||
return -EIO;
|
return -EIO;
|
||||||
} catch (FuseErrnoException &e) {
|
} catch (FuseErrnoException &e) {
|
||||||
return -e.getErrno();
|
return -e.getErrno();
|
||||||
@ -875,7 +875,7 @@ int Fuse::create(const bf::path &path, mode_t mode, fuse_file_info *fileinfo) {
|
|||||||
fileinfo->fh = _fs->createAndOpenFile(path, mode, context->uid, context->gid);
|
fileinfo->fh = _fs->createAndOpenFile(path, mode, context->uid, context->gid);
|
||||||
return 0;
|
return 0;
|
||||||
} catch(const cpputils::AssertFailed &e) {
|
} catch(const cpputils::AssertFailed &e) {
|
||||||
LOG(ERROR, "AssertFailed in Fuse::create: {}", e.what());
|
LOG(ERR, "AssertFailed in Fuse::create: {}", e.what());
|
||||||
return -EIO;
|
return -EIO;
|
||||||
} catch (FuseErrnoException &e) {
|
} catch (FuseErrnoException &e) {
|
||||||
return -e.getErrno();
|
return -e.getErrno();
|
||||||
|
@ -37,12 +37,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EXPECT_ERROR_LOG_ENABLED() {
|
void EXPECT_ERROR_LOG_ENABLED() {
|
||||||
LOG(ERROR, "My log message");
|
LOG(ERR, "My log message");
|
||||||
EXPECT_THAT(mockLogger.capturedLog(), MatchesRegex(".*\\[MockLogger\\].*\\[error\\].*My log message.*"));
|
EXPECT_THAT(mockLogger.capturedLog(), MatchesRegex(".*\\[MockLogger\\].*\\[error\\].*My log message.*"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EXPECT_ERROR_LOG_DISABLED() {
|
void EXPECT_ERROR_LOG_DISABLED() {
|
||||||
LOG(ERROR, "My log message");
|
LOG(ERR, "My log message");
|
||||||
EXPECT_EQ("", mockLogger.capturedLog());
|
EXPECT_EQ("", mockLogger.capturedLog());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -110,7 +110,7 @@ TEST_F(LoggingLevelTest, WARNING_SetAfterSettingLogger) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(LoggingLevelTest, ERROR_SetBeforeSettingLogger) {
|
TEST_F(LoggingLevelTest, ERROR_SetBeforeSettingLogger) {
|
||||||
setLevel(ERROR);
|
setLevel(ERR);
|
||||||
setLogger(mockLogger.get());
|
setLogger(mockLogger.get());
|
||||||
EXPECT_DEBUG_LOG_DISABLED();
|
EXPECT_DEBUG_LOG_DISABLED();
|
||||||
EXPECT_INFO_LOG_DISABLED();
|
EXPECT_INFO_LOG_DISABLED();
|
||||||
@ -120,7 +120,7 @@ TEST_F(LoggingLevelTest, ERROR_SetBeforeSettingLogger) {
|
|||||||
|
|
||||||
TEST_F(LoggingLevelTest, ERROR_SetAfterSettingLogger) {
|
TEST_F(LoggingLevelTest, ERROR_SetAfterSettingLogger) {
|
||||||
setLogger(mockLogger.get());
|
setLogger(mockLogger.get());
|
||||||
setLevel(ERROR);
|
setLevel(ERR);
|
||||||
EXPECT_DEBUG_LOG_DISABLED();
|
EXPECT_DEBUG_LOG_DISABLED();
|
||||||
EXPECT_INFO_LOG_DISABLED();
|
EXPECT_INFO_LOG_DISABLED();
|
||||||
EXPECT_WARNING_LOG_DISABLED();
|
EXPECT_WARNING_LOG_DISABLED();
|
||||||
|
@ -59,7 +59,7 @@ TEST_F(LoggingTest, DebugLog) {
|
|||||||
|
|
||||||
TEST_F(LoggingTest, ErrorLog) {
|
TEST_F(LoggingTest, ErrorLog) {
|
||||||
setLogger(mockLogger.get());
|
setLogger(mockLogger.get());
|
||||||
LOG(ERROR, "My log message");
|
LOG(ERR, "My log message");
|
||||||
EXPECT_THAT(mockLogger.capturedLog(), MatchesRegex(".*\\[MockLogger\\].*\\[error\\].*My log message.*"));
|
EXPECT_THAT(mockLogger.capturedLog(), MatchesRegex(".*\\[MockLogger\\].*\\[error\\].*My log message.*"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user