Skip to content

Commit

Permalink
replace rlog with easylogging++
Browse files Browse the repository at this point in the history
  • Loading branch information
vgough committed Apr 25, 2016
1 parent f345450 commit 46a5c9f
Show file tree
Hide file tree
Showing 70 changed files with 7,908 additions and 1,126 deletions.
27 changes: 22 additions & 5 deletions CMakeLists.txt
Expand Up @@ -9,6 +9,8 @@ set (ENCFS_VERSION "${ENCFS_MAJOR}.${ENCFS_MINOR}.${ENCFS_PATCH}")
set (ENCFS_SOVERSION "1.9")
set (ENCFS_NAME "Encrypted Filesystem")

option(IWYU "Build with IWYU analyais." OFF)

set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
"${CMAKE_SOURCE_DIR}/cmake")

Expand Down Expand Up @@ -62,10 +64,6 @@ else ()
include_directories (${TINYXML_INCLUDE_DIR})
endif ()

find_package (RLog REQUIRED)
add_definitions (-DRLOG_COMPONENT="encfs")
include_directories (${RLOG_INCLUDE_DIR})

find_program (POD2MAN pod2man)
include (FindGettext)

Expand Down Expand Up @@ -95,6 +93,14 @@ check_function_exists_glibc (lchmod HAVE_LCHMOD)
set (CMAKE_THREAD_PREFER_PTHREAD)
find_package (Threads REQUIRED)

# Logging.
add_definitions (-DELPP_THREAD_SAFE -DELPP_DISABLE_DEFAULT_CRASH_HANDLING)
check_include_file_cxx (syslog.h HAVE_SYSLOG_H)
if (HAVE_SYSLOG_H)
message ("-- Enabled syslog logging support")
add_definitions(-DELPP_SYSLOG)
endif (HAVE_SYSLOG_H)

# Packaging config.
set (CPACK_PACKAGE_NAME "encfs")
set (CPACK_PACKAGE_VERSION_MAJOR ${ENCFS_MAJOR})
Expand Down Expand Up @@ -124,6 +130,7 @@ set(SOURCE_FILES
encfs/Context.cpp
encfs/DirNode.cpp
encfs/encfs.cpp
encfs/Error.cpp
encfs/FileIO.cpp
encfs/FileNode.cpp
encfs/FileUtils.cpp
Expand All @@ -148,11 +155,21 @@ target_link_libraries(encfs
${FUSE_LIBRARIES}
${OPENSSL_LIBRARIES}
${TINYXML_LIBRARIES}
${RLOG_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
install (TARGETS encfs DESTINATION lib)

if (IWYU)
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.2)
find_program(iwyu_path NAMES include-what-you-use iwyu)
if (iwyu_path)
message ("-- Enabled IWYU")
set_property(TARGET encfs PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${iwyu_path})
endif()
endif()
endif()


# Set RPATH to library install path.
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")

Expand Down
13 changes: 8 additions & 5 deletions INSTALL.md
Expand Up @@ -41,13 +41,16 @@ Dependencies

EncFS depends on a number of libraries:

openssl fuse tinyxml2 gettext libintl librlog
* fuse : the userspace filesystem layer
* openssl : used for cryptographic primitives
* tinyxml2 : for reading and writing XML configuration files
* gettext : internationalization support
* libintl : internationalization support

Compiling on Debian and Ubuntu
==============================

We use separate [Drone.io](https://drone.io/) and [CircleCi](https://circleci.com/) builds to automatically
test every commit. See the README.md file for current build status.
See the automated build static in README.md for current build status on Ubuntu systems.

The build configuration files (.drone.yml and circle.yml) therefore
always contains up-to-date instructions to build EncFS on Ubuntu distributions.
The build configuration files (.drone.yml and circle.yml) always contains up-to-date
instructions to build EncFS on Ubuntu distributions.
2 changes: 1 addition & 1 deletion ci/config.sh
Expand Up @@ -2,4 +2,4 @@ set -x
set -e
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX:PATH=/tmp/encfs -DCMAKE_BUILD_TYPE=Debug ..
cmake -DCMAKE_INSTALL_PREFIX:PATH=/tmp/encfs -DCMAKE_BUILD_TYPE=Debug -DMINIGLOG=ON ..
2 changes: 1 addition & 1 deletion circle.yml
Expand Up @@ -4,7 +4,7 @@ machine:

dependencies:
pre:
- sudo apt-get install cmake libfuse-dev librlog-dev libgettextpo-dev
- sudo apt-get install cmake libfuse-dev libgettextpo-dev
- bash ./ci/install-gcc.sh

test:
Expand Down
28 changes: 0 additions & 28 deletions cmake/FindRLog.cmake

This file was deleted.

1 change: 0 additions & 1 deletion drone-config/worker/Dockerfile
Expand Up @@ -32,7 +32,6 @@ RUN apt-get -y upgrade \
git \
libfuse-dev \
libssl-dev \
librlog-dev \
gettext \
libgettextpo-dev \
&& apt-get clean
Expand Down
50 changes: 24 additions & 26 deletions encfs/BlockFileIO.cpp
Expand Up @@ -20,16 +20,15 @@

#include "BlockFileIO.h"

#include <inttypes.h>
#include <rlog/rlog.h>
#include <cstring>
#include <memory>
#include <cstring> // for memset, memcpy, NULL

#include "FSConfig.h"
#include "FileIO.h"
#include "FileUtils.h"
#include "MemoryPool.h"
#include "i18n.h"
#include "Error.h"
#include "FSConfig.h" // for FSConfigPtr
#include "FileIO.h" // for IORequest, FileIO
#include "FileUtils.h" // for EncFS_Opts
#include "MemoryPool.h" // for MemBlock, release, allocation

namespace encfs {

template <typename Type>
inline Type min(Type A, Type B) {
Expand All @@ -43,7 +42,7 @@ static void clearCache(IORequest &req, int blockSize) {

BlockFileIO::BlockFileIO(int blockSize, const FSConfigPtr &cfg)
: _blockSize(blockSize), _allowHoles(cfg->config->allowHoles) {
rAssert(_blockSize > 1);
CHECK(_blockSize > 1);
_cache.data = new unsigned char[_blockSize];
_noCache = cfg->opts->noCache;
}
Expand All @@ -60,9 +59,8 @@ BlockFileIO::~BlockFileIO() {
* returned data as neccessary.
*/
ssize_t BlockFileIO::cacheReadOneBlock(const IORequest &req) const {

rAssert(req.dataLen <= _blockSize);
rAssert(req.offset % _blockSize == 0);
CHECK(req.dataLen <= _blockSize);
CHECK(req.offset % _blockSize == 0);

/* we can satisfy the request even if _cache.dataLen is too short, because
* we always request a full block during reads. This just means we are
Expand Down Expand Up @@ -115,7 +113,7 @@ bool BlockFileIO::cacheWriteOneBlock(const IORequest &req) {
* lower layer.
*/
ssize_t BlockFileIO::read(const IORequest &req) const {
rAssert(_blockSize != 0);
CHECK(_blockSize != 0);

int partialOffset = req.offset % _blockSize;
off_t blockNum = req.offset / _blockSize;
Expand Down Expand Up @@ -149,11 +147,10 @@ ssize_t BlockFileIO::read(const IORequest &req) const {
}

ssize_t readSize = cacheReadOneBlock(blockReq);
if (unlikely(readSize <= partialOffset))
break; // didn't get enough bytes
if (readSize <= partialOffset) break; // didn't get enough bytes

int cpySize = min((size_t)(readSize - partialOffset), size);
rAssert(cpySize <= readSize);
CHECK(cpySize <= readSize);

// if we read to a temporary buffer, then move the data
if (blockReq.data != out)
Expand All @@ -165,7 +162,7 @@ ssize_t BlockFileIO::read(const IORequest &req) const {
++blockNum;
partialOffset = 0;

if (unlikely(readSize < _blockSize)) break;
if (readSize < _blockSize) break;
}

if (mb.data) MemoryPool::release(mb);
Expand All @@ -175,11 +172,10 @@ ssize_t BlockFileIO::read(const IORequest &req) const {
}

bool BlockFileIO::write(const IORequest &req) {
rAssert(_blockSize != 0);
CHECK(_blockSize != 0);

off_t fileSize = getSize();
if (fileSize < 0)
return false;
if (fileSize < 0) return false;

// where write request begins
off_t blockNum = req.offset / _blockSize;
Expand Down Expand Up @@ -301,7 +297,7 @@ void BlockFileIO::padFile(off_t oldSize, off_t newSize, bool forceWrite) {
cacheWriteOneBlock(req);
}
} else
rDebug("optimization: not padding last block");
VLOG(1) << "optimization: not padding last block";
} else {
mb = MemoryPool::allocate(_blockSize);
req.data = mb.data;
Expand All @@ -315,7 +311,7 @@ void BlockFileIO::padFile(off_t oldSize, off_t newSize, bool forceWrite) {

// 1. req.dataLen == 0, iff oldSize was already a multiple of blocksize
if (req.dataLen != 0) {
rDebug("padding block %" PRIi64, oldLastBlock);
VLOG(1) << "padding block " << oldLastBlock;
memset(mb.data, 0, _blockSize);
cacheReadOneBlock(req);
req.dataLen = _blockSize; // expand to full block size
Expand All @@ -326,7 +322,7 @@ void BlockFileIO::padFile(off_t oldSize, off_t newSize, bool forceWrite) {
// 2, pad zero blocks unless holes are allowed
if (!_allowHoles) {
for (; oldLastBlock != newLastBlock; ++oldLastBlock) {
rDebug("padding block %" PRIi64, oldLastBlock);
VLOG(1) << "padding block " << oldLastBlock;
req.offset = oldLastBlock * _blockSize;
req.dataLen = _blockSize;
memset(mb.data, 0, req.dataLen);
Expand Down Expand Up @@ -386,8 +382,8 @@ int BlockFileIO::truncateBase(off_t size, FileIO *base) {

if ((rdSz < 0) || (!wrRes)) {
// rwarning - unlikely to ever occur..
rWarning(_("truncate failure: read %i bytes, partial block of %i"),
(int)rdSz, partialBlock);
RLOG(WARNING) << "truncate failure: read " << rdSz
<< " bytes, partial block of " << partialBlock;
}

MemoryPool::release(mb);
Expand All @@ -399,3 +395,5 @@ int BlockFileIO::truncateBase(off_t size, FileIO *base) {

return res;
}

} // namespace encfs
4 changes: 4 additions & 0 deletions encfs/BlockFileIO.h
Expand Up @@ -26,6 +26,8 @@
#include "FSConfig.h"
#include "FileIO.h"

namespace encfs {

/*
Implements block scatter / gather interface. Requires derived classes to
implement readOneBlock() / writeOneBlock() at a minimum.
Expand Down Expand Up @@ -65,4 +67,6 @@ class BlockFileIO : public FileIO {
mutable IORequest _cache;
};

} // namespace encfs

#endif

0 comments on commit 46a5c9f

Please sign in to comment.