Skip to content

Commit

Permalink
Merge remote-tracking branch 'fork-origin/master'
Browse files Browse the repository at this point in the history
Bump version to v1.10-RC1 (v1.10.1-RC1)
  • Loading branch information
jetwhiz committed Apr 29, 2016
2 parents db2205a + ba9b25a commit 9a52c50
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 48 deletions.
7 changes: 2 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.0)
set(CMAKE_CXX_STANDARD_REQUIRED on)
else ()
if (CMAKE_COMPILER_IS_GNUCXX)
message ("Assuming that GNU CXX uses -std=c++11 flag for C++11 compatibility.")
message ("** Assuming that GNU CXX uses -std=c++11 flag for C++11 compatibility.")
list(APPEND CMAKE_CXX_FLAGS "-std=c++11")
else()
message ("No CMAKE C++11 check. If the build breaks, you're on your own.")
message ("** No CMAKE C++11 check. If the build breaks, you're on your own.")
endif()
endif ()

Expand Down Expand Up @@ -72,9 +72,6 @@ include (CheckIncludeFileCXX)
check_include_file_cxx (attr/xattr.h HAVE_ATTR_XATTR_H)
check_include_file_cxx (sys/xattr.h HAVE_SYS_XATTR_H)

# Look for old pre-C++11 headers.
check_include_file_cxx (tr1/memory HAVE_TR1_MEMORY)

# Check if xattr functions take extra arguments, as they do on OSX.
# Output error is misleading, so do this test quietly.
include (CheckCXXSourceCompiles)
Expand Down
2 changes: 0 additions & 2 deletions config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#cmakedefine HAVE_SYS_XATTR_H
#cmakedefine XATTR_ADD_OPT

#cmakedefine HAVE_TR1_MEMORY

#cmakedefine HAVE_LCHMOD

/* TODO: add other thread library support. */
Expand Down
6 changes: 3 additions & 3 deletions encfs/FileNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,14 @@ int FileNode::mknod(mode_t mode, dev_t rdev, uid_t uid, gid_t gid) {
if (uid != 0) {
olduid = setfsuid(uid);
if (olduid == -1) {
RLOG(INFO) << "setfsuid error: " << strerror(errno);
RLOG(DEBUG) << "setfsuid error: " << strerror(errno);
return -EPERM;
}
}
if (gid != 0) {
oldgid = setfsgid(gid);
if (oldgid == -1) {
RLOG(INFO) << "setfsgid error: " << strerror(errno);
RLOG(DEBUG) << "setfsgid error: " << strerror(errno);
return -EPERM;
}
}
Expand Down Expand Up @@ -221,7 +221,7 @@ ssize_t FileNode::read(off_t offset, unsigned char *data, ssize_t size) const {
}

bool FileNode::write(off_t offset, unsigned char *data, ssize_t size) {
RLOG(INFO) << "FileNode::write offset " << offset << ", data size " << size;
VLOG(1) << "FileNode::write offset " << offset << ", data size " << size;

IORequest req;
req.offset = offset;
Expand Down
2 changes: 1 addition & 1 deletion encfs/FileUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1639,7 +1639,7 @@ int remountFS(EncFS_Context *ctx) {
ctx->setRoot(rootInfo->root);
return 0;
} else {
RLOG(INFO) << "Remount failed";
RLOG(WARNING) << "Remount failed";
return -EACCES;
}
}
Expand Down
4 changes: 4 additions & 0 deletions encfs/MemoryPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ static void freeBlock(BlockList *el) {
static pthread_mutex_t gMPoolMutex;
static BlockList *gMemPool = NULL;

void init_mpool_mutex() {
pthread_mutex_init(&gMPoolMutex, 0);
}

MemBlock MemoryPool::allocate(int size) {
pthread_mutex_lock(&gMPoolMutex);

Expand Down
16 changes: 8 additions & 8 deletions encfs/RawFileIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ int RawFileIO::open(int flags) {
result = fd = newFd;
} else {
result = -errno;
RLOG(INFO) << "::open error: " << strerror(errno);
RLOG(DEBUG) << "::open error: " << strerror(errno);
}
}

Expand All @@ -134,7 +134,7 @@ int RawFileIO::getAttr(struct stat_st *stbuf) const {
int eno = errno;

if (res < 0) {
RLOG(INFO) << "getAttr error on " << name << ": " << strerror(eno);
RLOG(DEBUG) << "getAttr error on " << name << ": " << strerror(eno);
}

return (res < 0) ? -eno : 0;
Expand Down Expand Up @@ -169,8 +169,8 @@ ssize_t RawFileIO::read(const IORequest &req) const {
ssize_t readSize = unix::pread(fd, req.data, req.dataLen, req.offset);

if (readSize < 0) {
RLOG(INFO) << "read failed at offset " << req.offset << " for "
<< req.dataLen << " bytes: " << strerror(errno);
RLOG(WARNING) << "read failed at offset " << req.offset << " for "
<< req.dataLen << " bytes: " << strerror(errno);
}

return readSize;
Expand All @@ -190,8 +190,8 @@ bool RawFileIO::write(const IORequest &req) {

if (writeSize < 0) {
knownSize = false;
RLOG(INFO) << "write failed at offset " << offset << " for " << bytes
<< " bytes: " << strerror(errno);
RLOG(WARNING) << "write failed at offset " << offset << " for " << bytes
<< " bytes: " << strerror(errno);
return false;
}

Expand Down Expand Up @@ -230,8 +230,8 @@ int RawFileIO::truncate(off_t size) {

if (res < 0) {
int eno = errno;
RLOG(INFO) << "truncate failed for " << name << " (" << fd << ") size "
<< size << ", error " << strerror(eno);
RLOG(WARNING) << "truncate failed for " << name << " (" << fd << ") size "
<< size << ", error " << strerror(eno);
res = -eno;
knownSize = false;
} else {
Expand Down
2 changes: 1 addition & 1 deletion encfs/encfs-installer.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "encfs"
!define PRODUCT_VERSION "1.9.0-RC4"
!define PRODUCT_VERSION "1.10.1-RC1"
!define PRODUCT_PUBLISHER "CEMi4"

SetCompressor lzma
Expand Down
14 changes: 12 additions & 2 deletions encfs/encfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ static int withFileNode(const char *opName, const char *path,
}

res = op(fnode.get());

LOG_IF(res < 0, INFO) << "op: " << opName << " error: " << strerror(-res);
if (res < 0) {
RLOG(DEBUG) << "op: " << opName << " error: " << strerror(-res);
}
} catch (encfs::Error &err) {
RLOG(ERROR) << "withFileNode: error caught in " << opName << ": "
<< err.what();
Expand Down Expand Up @@ -574,6 +575,15 @@ int encfs_open(const char *path, struct fuse_file_info *file) {
return res;
}

int encfs_create(const char *path, mode_t mode, struct fuse_file_info *file) {
int res = encfs_mknod(path, mode, 0);
if (res) {
return res;
}

return encfs_open(path, file);
}

int _do_flush(FileNode *fnode) {
/* Flush can be called multiple times for an open file, so it doesn't
close the file. However it is important to call close() for some
Expand Down
1 change: 1 addition & 0 deletions encfs/encfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ int encfs_truncate(const char *path, long long size);
int encfs_ftruncate(const char *path, long long size, struct fuse_file_info *fi);
int encfs_utime(const char *path, struct utimbuf *buf);
int encfs_open(const char *path, struct fuse_file_info *info);
int encfs_create(const char *path, mode_t mode, struct fuse_file_info *info);
int encfs_release(const char *path, struct fuse_file_info *info);
int encfs_read(const char *path, char *buf, size_t size, long long offset,
struct fuse_file_info *info);
Expand Down
13 changes: 9 additions & 4 deletions encfs/encfsctl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ static int showInfo(int argc, char **argv) {
string rootDir = argv[1];
if (!checkDir(rootDir)) return EXIT_FAILURE;

EncFSConfig *config = new EncFSConfig;
ConfigType type = readConfig(rootDir, config);
std::shared_ptr<EncFSConfig> config(new EncFSConfig);
ConfigType type = readConfig(rootDir, config.get());

// show information stored in config..
switch (type) {
Expand Down Expand Up @@ -229,8 +229,7 @@ static int showInfo(int argc, char **argv) {
break;
}

showFSInfo(config);
delete config;
showFSInfo(config.get());

return EXIT_SUCCESS;
}
Expand Down Expand Up @@ -739,7 +738,13 @@ static int ckpasswdAutomaticly(int argc, char **argv) {
return do_chpasswd(true, false, true, argc, argv);
}

namespace encfs {
void init_mpool_mutex();
}

int main(int argc, char **argv) {
encfs::init_mpool_mutex();

START_EASYLOGGINGPP(argc, argv);
encfs::initLogging();

Expand Down
53 changes: 31 additions & 22 deletions encfs/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,23 +529,16 @@ void *encfs_init(fuse_conn_info *conn) {
return (void *)ctx;
}

void encfs_destroy(void *_ctx) {
EncFS_Context *ctx = (EncFS_Context *)_ctx;
if (ctx->args->idleTimeout > 0) {
ctx->running = false;

// wake up the thread if it is waiting..
VLOG(1) << "waking up monitoring thread";
pthread_mutex_lock(&ctx->wakeupMutex);
pthread_cond_signal(&ctx->wakeupCond);
pthread_mutex_unlock(&ctx->wakeupMutex);
VLOG(1) << "joining with idle monitoring thread";
pthread_join(ctx->monitorThread, 0);
VLOG(1) << "join done";
}
void encfs_destroy(void *_ctx) {}

namespace encfs {
void init_mpool_mutex();
}

int main(int argc, char *argv[]) {
SetConsoleCP(65001); // set utf-8
encfs::init_mpool_mutex();

encfs::initLogging();

#if defined(ENABLE_NLS) && defined(LOCALEDIR)
Expand Down Expand Up @@ -613,7 +606,7 @@ int main(int argc, char *argv[]) {
encfs_oper.init = encfs_init;
encfs_oper.destroy = encfs_destroy;
// encfs_oper.access = encfs_access;
// encfs_oper.create = encfs_create;
encfs_oper.create = encfs_create;
encfs_oper.ftruncate = encfs_ftruncate;
encfs_oper.fgetattr = encfs_fgetattr;
// encfs_oper.lock = encfs_lock;
Expand Down Expand Up @@ -703,6 +696,18 @@ int main(int argc, char *argv[]) {
} catch (...) {
RLOG(ERROR) << "Internal error: Caught unexpected exception";
}

if (ctx->args->idleTimeout > 0) {
ctx->running = false;
// wake up the thread if it is waiting..
VLOG(1) << "waking up monitoring thread";
pthread_mutex_lock(&ctx->wakeupMutex);
pthread_cond_signal(&ctx->wakeupCond);
pthread_mutex_unlock(&ctx->wakeupMutex);
VLOG(1) << "joining with idle monitoring thread";
pthread_join(ctx->monitorThread, 0);
VLOG(1) << "join done";
}
}

// cleanup so that we can check for leaked resources..
Expand Down Expand Up @@ -730,7 +735,7 @@ static void *idleMonitor(void *_arg) {
std::shared_ptr<EncFS_Args> arg = ctx->args;

const int timeoutCycles = 60 * arg->idleTimeout / ActivityCheckInterval;
int idleCycles = 0;
int idleCycles = -1;

pthread_mutex_lock(&ctx->wakeupMutex);

Expand All @@ -744,13 +749,17 @@ static void *idleMonitor(void *_arg) {

if (idleCycles >= timeoutCycles) {
int openCount = ctx->openFileCount();
if (openCount == 0 && unmountFS(ctx)) {
// wait for main thread to wake us up
pthread_cond_wait(&ctx->wakeupCond, &ctx->wakeupMutex);
break;
if (openCount == 0) {
if (unmountFS(ctx)) {
// wait for main thread to wake us up
pthread_cond_wait(&ctx->wakeupCond, &ctx->wakeupMutex);
break;
}
} else {
RLOG(WARNING) << "Filesystem " << arg->opts->mountPoint
<< " inactivity detected, but still " << openCount
<< " opened files";
}

VLOG(1) << "num open files: " << openCount;
}

VLOG(1) << "idle cycle count: " << idleCycles << ", timeout after "
Expand Down

0 comments on commit 9a52c50

Please sign in to comment.