mirror of
https://github.com/vgough/encfs.git
synced 2025-08-16 08:47:54 +02:00
fix build with FUSE 3.9
This commit is contained in:
@ -101,7 +101,7 @@ endif()
|
||||
# Check for FUSE.
|
||||
find_package (FUSE REQUIRED)
|
||||
include_directories (${FUSE_INCLUDE_DIR})
|
||||
add_definitions (-D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=29)
|
||||
add_definitions (-D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=39)
|
||||
if (CYGWIN)
|
||||
# Cygwin build is intended to use WinFsp
|
||||
add_definitions(-DCYGFUSE)
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <cstring>
|
||||
#ifdef __linux__
|
||||
#include <sys/fsuid.h>
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#include <pthread.h>
|
||||
#include <sys/stat.h>
|
||||
@ -199,7 +200,7 @@ bool RenameOp::apply() {
|
||||
}
|
||||
|
||||
if (preserve_mtime) {
|
||||
struct utimbuf ut;
|
||||
::utimbuf ut;
|
||||
ut.actime = st.st_atime;
|
||||
ut.modtime = st.st_mtime;
|
||||
::utime(last->newCName.c_str(), &ut);
|
||||
@ -555,7 +556,9 @@ int DirNode::mkdir(const char *plaintextPath, mode_t mode, uid_t uid,
|
||||
return res;
|
||||
}
|
||||
|
||||
int DirNode::rename(const char *fromPlaintext, const char *toPlaintext) {
|
||||
// \todo use the flags parameter to handle RENAME_EXCHANGE and RENAME_NOREPLACE.
|
||||
int DirNode::rename(const char *fromPlaintext, const char *toPlaintext, const int flags) {
|
||||
(void)flags;
|
||||
Lock _lock(mutex);
|
||||
|
||||
string fromCName = rootDir + naming->encodePath(fromPlaintext);
|
||||
@ -614,7 +617,7 @@ int DirNode::rename(const char *fromPlaintext, const char *toPlaintext) {
|
||||
}
|
||||
#endif
|
||||
if (preserve_mtime) {
|
||||
struct utimbuf ut;
|
||||
::utimbuf ut;
|
||||
ut.actime = st.st_atime;
|
||||
ut.modtime = st.st_mtime;
|
||||
::utime(toCName.c_str(), &ut);
|
||||
|
@ -129,7 +129,7 @@ class DirNode {
|
||||
int mkdir(const char *plaintextPath, mode_t mode, uid_t uid = 0,
|
||||
gid_t gid = 0);
|
||||
|
||||
int rename(const char *fromPlaintext, const char *toPlaintext);
|
||||
int rename(const char *fromPlaintext, const char *toPlaintext, const int flags);
|
||||
|
||||
int link(const char *to, const char *from);
|
||||
|
||||
|
@ -1734,8 +1734,12 @@ RootPtr initFS(EncFS_Context *ctx, const std::shared_ptr<EncFS_Opts> &opts) {
|
||||
}
|
||||
|
||||
void unmountFS(const char *mountPoint) {
|
||||
// \todo DOJ: find a way to do fuse_unmount()
|
||||
(void)mountPoint;
|
||||
#if 0
|
||||
// fuse_unmount returns void, is assumed to succeed
|
||||
fuse_unmount(mountPoint, nullptr);
|
||||
fuse_unmount(f);
|
||||
#endif
|
||||
#ifdef __APPLE__
|
||||
// fuse_unmount does not work on Mac OS, see #428
|
||||
// However it makes encfs to hang, so we must unmount
|
||||
|
@ -224,17 +224,13 @@ int _do_getattr(FileNode *fnode, struct stat *stbuf) {
|
||||
return res;
|
||||
}
|
||||
|
||||
int encfs_getattr(const char *path, struct stat *stbuf) {
|
||||
return withFileNode("getattr", path, nullptr, bind(_do_getattr, _1, stbuf));
|
||||
}
|
||||
|
||||
int encfs_fgetattr(const char *path, struct stat *stbuf,
|
||||
int encfs_getattr(const char *path, struct stat *stbuf,
|
||||
struct fuse_file_info *fi) {
|
||||
return withFileNode("fgetattr", path, fi, bind(_do_getattr, _1, stbuf));
|
||||
}
|
||||
|
||||
int encfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
|
||||
off_t offset, struct fuse_file_info *finfo) {
|
||||
off_t offset, struct fuse_file_info *finfo, enum fuse_readdir_flags) {
|
||||
EncFS_Context *ctx = context();
|
||||
|
||||
//unused parameters
|
||||
@ -264,13 +260,9 @@ int encfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
|
||||
st.st_mode = fileType << 12;
|
||||
|
||||
// TODO: add offset support.
|
||||
#if defined(fuse_fill_dir_flags)
|
||||
if (filler(buf, name.c_str(), &st, 0, 0)) break;
|
||||
#else
|
||||
if (filler(buf, name.c_str(), &st, 0) != 0) {
|
||||
if (filler(buf, name.c_str(), &st, 0, FUSE_FILL_DIR_PLUS)) {
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
name = dt.nextPlaintextName(&fileType, &inode);
|
||||
}
|
||||
@ -528,7 +520,7 @@ int encfs_link(const char *to, const char *from) {
|
||||
return res;
|
||||
}
|
||||
|
||||
int encfs_rename(const char *from, const char *to) {
|
||||
int encfs_rename(const char *from, const char *to, unsigned int flags) {
|
||||
EncFS_Context *ctx = context();
|
||||
|
||||
if (isReadOnly(ctx)) {
|
||||
@ -542,7 +534,7 @@ int encfs_rename(const char *from, const char *to) {
|
||||
}
|
||||
|
||||
try {
|
||||
res = FSRoot->rename(from, to);
|
||||
res = FSRoot->rename(from, to, flags);
|
||||
} catch (encfs::Error &err) {
|
||||
RLOG(ERROR) << "error caught in rename: " << err.what();
|
||||
}
|
||||
@ -553,7 +545,8 @@ int _do_chmod(EncFS_Context *, const string &cipherPath, mode_t mode) {
|
||||
return chmod(cipherPath.c_str(), mode);
|
||||
}
|
||||
|
||||
int encfs_chmod(const char *path, mode_t mode) {
|
||||
int encfs_chmod(const char *path, mode_t mode, struct fuse_file_info *fi) {
|
||||
(void)fi;
|
||||
EncFS_Context *ctx = context();
|
||||
if (isReadOnly(ctx)) {
|
||||
return -EROFS;
|
||||
@ -566,7 +559,8 @@ int _do_chown(EncFS_Context *, const string &cyName, uid_t u, gid_t g) {
|
||||
return (res == -1) ? -errno : ESUCCESS;
|
||||
}
|
||||
|
||||
int encfs_chown(const char *path, uid_t uid, gid_t gid) {
|
||||
int encfs_chown(const char *path, uid_t uid, gid_t gid, struct fuse_file_info *fi) {
|
||||
(void)fi;
|
||||
EncFS_Context *ctx = context();
|
||||
if (isReadOnly(ctx)) {
|
||||
return -EROFS;
|
||||
@ -576,15 +570,7 @@ int encfs_chown(const char *path, uid_t uid, gid_t gid) {
|
||||
|
||||
int _do_truncate(FileNode *fnode, off_t size) { return fnode->truncate(size); }
|
||||
|
||||
int encfs_truncate(const char *path, off_t size) {
|
||||
EncFS_Context *ctx = context();
|
||||
if (isReadOnly(ctx)) {
|
||||
return -EROFS;
|
||||
}
|
||||
return withFileNode("truncate", path, nullptr, bind(_do_truncate, _1, size));
|
||||
}
|
||||
|
||||
int encfs_ftruncate(const char *path, off_t size, struct fuse_file_info *fi) {
|
||||
int encfs_truncate(const char *path, off_t size, struct fuse_file_info *fi) {
|
||||
EncFS_Context *ctx = context();
|
||||
if (isReadOnly(ctx)) {
|
||||
return -EROFS;
|
||||
@ -592,19 +578,6 @@ int encfs_ftruncate(const char *path, off_t size, struct fuse_file_info *fi) {
|
||||
return withFileNode("ftruncate", path, fi, bind(_do_truncate, _1, size));
|
||||
}
|
||||
|
||||
int _do_utime(EncFS_Context *, const string &cyName, struct utimbuf *buf) {
|
||||
int res = utime(cyName.c_str(), buf);
|
||||
return (res == -1) ? -errno : ESUCCESS;
|
||||
}
|
||||
|
||||
int encfs_utime(const char *path, struct utimbuf *buf) {
|
||||
EncFS_Context *ctx = context();
|
||||
if (isReadOnly(ctx)) {
|
||||
return -EROFS;
|
||||
}
|
||||
return withCipherPath("utime", path, bind(_do_utime, _1, _2, buf));
|
||||
}
|
||||
|
||||
int _do_utimens(EncFS_Context *, const string &cyName,
|
||||
const struct timespec ts[2]) {
|
||||
#ifdef HAVE_UTIMENSAT
|
||||
@ -621,7 +594,8 @@ int _do_utimens(EncFS_Context *, const string &cyName,
|
||||
return (res == -1) ? -errno : ESUCCESS;
|
||||
}
|
||||
|
||||
int encfs_utimens(const char *path, const struct timespec ts[2]) {
|
||||
int encfs_utimens(const char *path, const struct timespec ts[2], struct fuse_file_info *fi) {
|
||||
(void)fi;
|
||||
EncFS_Context *ctx = context();
|
||||
if (isReadOnly(ctx)) {
|
||||
return -EROFS;
|
||||
|
@ -58,24 +58,19 @@ static __inline int setfsgid(gid_t gid) {
|
||||
}
|
||||
#endif
|
||||
|
||||
int encfs_getattr(const char *path, struct stat *stbuf);
|
||||
int encfs_fgetattr(const char *path, struct stat *stbuf,
|
||||
struct fuse_file_info *fi);
|
||||
int encfs_getattr(const char *path, struct stat *stbuf, struct fuse_file_info *fi);
|
||||
int encfs_readlink(const char *path, char *buf, size_t size);
|
||||
int encfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
|
||||
off_t offset, struct fuse_file_info *finfo);
|
||||
int encfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *finfo, enum fuse_readdir_flags);
|
||||
int encfs_mknod(const char *path, mode_t mode, dev_t rdev);
|
||||
int encfs_mkdir(const char *path, mode_t mode);
|
||||
int encfs_unlink(const char *path);
|
||||
int encfs_rmdir(const char *path);
|
||||
int encfs_symlink(const char *from, const char *to);
|
||||
int encfs_rename(const char *from, const char *to);
|
||||
int encfs_rename(const char *from, const char *to, unsigned int flags);
|
||||
int encfs_link(const char *to, const char *from);
|
||||
int encfs_chmod(const char *path, mode_t mode);
|
||||
int encfs_chown(const char *path, uid_t uid, gid_t gid);
|
||||
int encfs_truncate(const char *path, off_t size);
|
||||
int encfs_ftruncate(const char *path, off_t size, struct fuse_file_info *fi);
|
||||
int encfs_utime(const char *path, struct utimbuf *buf);
|
||||
int encfs_chmod(const char *path, mode_t mode, struct fuse_file_info *fi);
|
||||
int encfs_chown(const char *path, uid_t uid, gid_t gid, struct fuse_file_info *fi);
|
||||
int encfs_truncate(const char *path, off_t size, struct fuse_file_info *fi);
|
||||
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);
|
||||
@ -105,7 +100,7 @@ int encfs_listxattr(const char *path, char *list, size_t size);
|
||||
int encfs_removexattr(const char *path, const char *name);
|
||||
#endif
|
||||
|
||||
int encfs_utimens(const char *path, const struct timespec ts[2]);
|
||||
int encfs_utimens(const char *path, const struct timespec ts[2], struct fuse_file_info *fi);
|
||||
|
||||
} // namespace encfs
|
||||
|
||||
|
@ -615,12 +615,12 @@ static bool processArgs(int argc, char *argv[],
|
||||
|
||||
static void *idleMonitor(void *);
|
||||
|
||||
void *encfs_init(fuse_conn_info *conn) {
|
||||
// \todo use the cfg object to configure EncFS behavior.
|
||||
void *encfs_init(fuse_conn_info *conn, struct fuse_config *cfg) {
|
||||
(void)conn;
|
||||
(void)cfg;
|
||||
auto *ctx = (EncFS_Context *)fuse_get_context()->private_data;
|
||||
|
||||
// set fuse connection options
|
||||
conn->async_read = 1u;
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
// WinFsp needs this to partially handle read-only FS
|
||||
// See https://github.com/billziss-gh/winfsp/issues/157 for details
|
||||
@ -705,7 +705,6 @@ int main(int argc, char *argv[]) {
|
||||
encfs_oper.chmod = encfs_chmod;
|
||||
encfs_oper.chown = encfs_chown;
|
||||
encfs_oper.truncate = encfs_truncate;
|
||||
encfs_oper.utime = encfs_utime; // deprecated for utimens
|
||||
encfs_oper.open = encfs_open;
|
||||
encfs_oper.read = encfs_read;
|
||||
encfs_oper.write = encfs_write;
|
||||
@ -726,8 +725,6 @@ int main(int argc, char *argv[]) {
|
||||
encfs_oper.init = encfs_init;
|
||||
// encfs_oper.access = encfs_access;
|
||||
encfs_oper.create = encfs_create;
|
||||
encfs_oper.ftruncate = encfs_ftruncate;
|
||||
encfs_oper.fgetattr = encfs_fgetattr;
|
||||
// encfs_oper.lock = encfs_lock;
|
||||
encfs_oper.utimens = encfs_utimens;
|
||||
// encfs_oper.bmap = encfs_bmap;
|
||||
|
Reference in New Issue
Block a user