diff --git a/Makefile b/Makefile index 6008710a..5d5b92bd 100644 --- a/Makefile +++ b/Makefile @@ -115,9 +115,7 @@ LIBFUSE := libfuse/$(BUILDDIR)/libfuse.a LDFLAGS ?= LDLIBS := \ -lrt \ - -latomic \ - -pthread \ - -lstdc++fs + -pthread override LDLIBS += \ $(LIBFUSE) diff --git a/libfuse/include/fs_dirent64.hpp b/libfuse/include/fs_dirent64.hpp index 6e660fad..54052862 100644 --- a/libfuse/include/fs_dirent64.hpp +++ b/libfuse/include/fs_dirent64.hpp @@ -8,16 +8,16 @@ namespace fs struct dirent64 { public: - uint64_t d_ino; - int64_t d_off; - uint16_t d_reclen; - uint8_t d_type; - char d_name[]; + uint64_t ino; + int64_t off; + uint16_t reclen; + uint8_t type; + char name[]; public: - int d_namelen() const + int namelen() const { - return (d_reclen - offsetof(dirent64,d_name)); + return (reclen - offsetof(dirent64,name)); } }; } diff --git a/libfuse/include/fuse.h b/libfuse/include/fuse.h index 8259ce35..ec17a71d 100644 --- a/libfuse/include/fuse.h +++ b/libfuse/include/fuse.h @@ -526,12 +526,12 @@ struct fuse_operations * destination. Effectively doing an inefficient copy of the * data. */ - ssize_t (*copy_file_range)(const fuse_file_info_t *fi_in, - off_t offset_in, - const fuse_file_info_t *fi_out, - off_t offset_out, - size_t size, - int flags); + ssize_t (*copy_file_range)(const fuse_file_info_t *src_fi, + off_t src_off, + const fuse_file_info_t *dst_fi, + off_t dst_off, + const size_t size, + const unsigned int flags); ssize_t (*setupmapping)(uint64_t *fh_, uint64_t foffset_, diff --git a/libfuse/include/thread_pool.hpp b/libfuse/include/thread_pool.hpp index 3ffed9b7..ea3b0c5d 100644 --- a/libfuse/include/thread_pool.hpp +++ b/libfuse/include/thread_pool.hpp @@ -77,7 +77,7 @@ public: template [[nodiscard]] - std::future::type> + std::future> enqueue_task(FuncType&& func_); public: @@ -340,10 +340,10 @@ ThreadPool::enqueue_work(FuncType &&func_) template [[nodiscard]] inline -std::future::type> +std::future> ThreadPool::enqueue_task(FuncType&& func_) { - using TaskReturnType = typename std::result_of::type; + using TaskReturnType = std::invoke_result_t; using Promise = std::promise; Promise promise; diff --git a/libfuse/lib/fuse_dirents.cpp b/libfuse/lib/fuse_dirents.cpp index 14409cc1..34157786 100644 --- a/libfuse/lib/fuse_dirents.cpp +++ b/libfuse/lib/fuse_dirents.cpp @@ -122,10 +122,10 @@ fuse_dirents_add(fuse_dirents_t *d_, d->off = kv_size(d_->offs); kv_push(uint32_t,d_->offs,kv_size(d_->data)); - d->ino = de_->d_ino; + d->ino = de_->ino; d->namelen = namelen_; - d->type = de_->d_type; - memcpy(d->name,de_->d_name,namelen_); + d->type = de_->type; + memcpy(d->name,de_->name,namelen_); return 0; } diff --git a/libfuse/lib/mount_bsd.c b/libfuse/lib/mount_bsd.c index b1a54575..a9cdf576 100644 --- a/libfuse/lib/mount_bsd.c +++ b/libfuse/lib/mount_bsd.c @@ -7,7 +7,6 @@ */ #include "fuse_i.h" -#include "fuse_misc.h" #include "fuse_opt.h" #include diff --git a/src/dirinfo.hpp b/src/dirinfo.hpp index d9b67755..c9c71ad4 100644 --- a/src/dirinfo.hpp +++ b/src/dirinfo.hpp @@ -18,14 +18,16 @@ #include "fh.hpp" +#include "int_types.h" + class DirInfo : public FH { public: - static DirInfo *from_fh(const uint64_t fh); + static DirInfo *from_fh(const u64 fh); public: - uint64_t to_fh() const; + u64 to_fh() const; public: DirInfo(const fs::path &fusepath_) @@ -38,12 +40,12 @@ inline uint64_t DirInfo::to_fh() const { - return reinterpret_cast(this); + return reinterpret_cast(this); } inline DirInfo* -DirInfo::from_fh(const uint64_t fh_) +DirInfo::from_fh(const u64 fh_) { return reinterpret_cast(fh_); } diff --git a/src/fileinfo.hpp b/src/fileinfo.hpp index b5e08369..f45ecefe 100644 --- a/src/fileinfo.hpp +++ b/src/fileinfo.hpp @@ -28,7 +28,7 @@ class FileInfo : public FH { public: - static FileInfo *from_fh(const uintptr_t fh); + static FileInfo *from_fh(const u64 fh); public: FileInfo(const int fd_, @@ -62,7 +62,7 @@ public: } public: - uint64_t to_fh() const; + u64 to_fh() const; public: int fd; @@ -72,15 +72,15 @@ public: }; inline -uintptr_t +u64 FileInfo::to_fh() const { - return reinterpret_cast(this); + return reinterpret_cast(this); } inline FileInfo* -FileInfo::from_fh(const uintptr_t fh_) +FileInfo::from_fh(const u64 fh_) { return reinterpret_cast(fh_); } diff --git a/src/fs_attr_unsupported.icpp b/src/fs_attr_unsupported.icpp index a743af8d..0d4e3c1f 100644 --- a/src/fs_attr_unsupported.icpp +++ b/src/fs_attr_unsupported.icpp @@ -20,15 +20,16 @@ int -fs::attr::copy(const int fdin, - const int fdout) +fs::attr::copy(const int fdin_, + const int fdout_, + const u32 flags_) { return -ENOTSUP; } int -fs::attr::copy(const std::string &from, - const std::string &to) +fs::attr::copy(const std::string &from_, + const std::string &to_) { return -ENOTSUP; } diff --git a/src/fs_copy_file_range.cpp b/src/fs_copy_file_range.cpp index 40ec76ce..ded23722 100644 --- a/src/fs_copy_file_range.cpp +++ b/src/fs_copy_file_range.cpp @@ -16,6 +16,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include "fs_copy_file_range.hpp" + #ifdef __linux__ #pragma message "using fs_copy_file_range_linux.icpp" #include "fs_copy_file_range_linux.icpp" diff --git a/src/fs_copy_file_range.hpp b/src/fs_copy_file_range.hpp index 5ffdc656..09baf76b 100644 --- a/src/fs_copy_file_range.hpp +++ b/src/fs_copy_file_range.hpp @@ -26,11 +26,11 @@ namespace fs { - int64_t - copy_file_range(const int fd_in, - int64_t *off_in, - const int fd_out, - int64_t *off_out, - const uint64_t len, + ssize_t + copy_file_range(const int src_fd_, + off_t *src_off_, + const int dst_fd_, + off_t *dst_off_, + const size_t len, const unsigned int flags); } diff --git a/src/fs_copy_file_range_linux.icpp b/src/fs_copy_file_range_linux.icpp index 1bf8b185..b9bc1d21 100644 --- a/src/fs_copy_file_range_linux.icpp +++ b/src/fs_copy_file_range_linux.icpp @@ -34,30 +34,30 @@ static -int64_t -_copy_file_range_(int src_fd_, - int64_t *src_off_, - int tgt_fd_, - int64_t *tgt_off_, - const uint64_t len_, +ssize_t +_copy_file_range_(const int src_fd_, + off_t *src_off_, + const int dst_fd_, + off_t *dst_off_, + const size_t len_, const unsigned int flags_) { #ifdef SYS_copy_file_range int64_t rv; loff_t src_off; - loff_t tgt_off; + loff_t dst_off; loff_t *src_off_ptr; - loff_t *tgt_off_ptr; + loff_t *dst_off_ptr; src_off = ((src_off_ == NULL) ? 0 : *src_off_); - tgt_off = ((tgt_off_ == NULL) ? 0 : *tgt_off_); + dst_off = ((dst_off_ == NULL) ? 0 : *dst_off_); src_off_ptr = ((src_off_ == NULL) ? NULL : &src_off); - tgt_off_ptr = ((tgt_off_ == NULL) ? NULL : &tgt_off); + dst_off_ptr = ((dst_off_ == NULL) ? NULL : &dst_off); rv = ::syscall(SYS_copy_file_range, src_fd_, src_off_ptr, - tgt_fd_, - tgt_off_ptr, + dst_fd_, + dst_off_ptr, len_, flags_); @@ -65,8 +65,8 @@ _copy_file_range_(int src_fd_, { if(src_off_ != NULL) *src_off_ = src_off; - if(tgt_off_ != NULL) - *tgt_off_ = tgt_off; + if(dst_off_ != NULL) + *dst_off_ = dst_off; } return ::to_neg_errno(rv); @@ -75,18 +75,18 @@ _copy_file_range_(int src_fd_, #endif } -int64_t +ssize_t fs::copy_file_range(const int src_fd_, - int64_t *src_off_, - const int tgt_fd_, - int64_t *tgt_off_, - const uint64_t len_, + off_t *src_off_, + const int dst_fd_, + off_t *dst_off_, + const size_t len_, const unsigned int flags_) { return ::_copy_file_range_(src_fd_, src_off_, - tgt_fd_, - tgt_off_, + dst_fd_, + dst_off_, len_, flags_); } diff --git a/src/fs_copy_file_range_unsupported.icpp b/src/fs_copy_file_range_unsupported.icpp index a72fe655..aebd6e0c 100644 --- a/src/fs_copy_file_range_unsupported.icpp +++ b/src/fs_copy_file_range_unsupported.icpp @@ -28,18 +28,9 @@ ssize_t fs::copy_file_range(const int fd_in_, - int64_t *off_in_, - const int fd_out_, - int64_t *off_out_, - const size_t len_, - const unsigned int flags_) -{ - return -EOPNOTSUPP; -} - -ssize_t -fs::copy_file_range(const int fd_in_, + off_t *off_in_, const int fd_out_, + off_t *off_out_, const size_t len_, const unsigned int flags_) { diff --git a/src/fs_copyfile.cpp b/src/fs_copyfile.cpp index e6949a99..1a27bf48 100644 --- a/src/fs_copyfile.cpp +++ b/src/fs_copyfile.cpp @@ -164,6 +164,11 @@ fs::copyfile(const int src_fd_, return rv; } +// For FreeBSD +#ifndef O_NOATIME +#define O_NOATIME 0 +#endif + s64 fs::copyfile(const fs::path &src_filepath_, const fs::path &dst_filepath_, diff --git a/src/fs_getdents64.cpp b/src/fs_getdents64.cpp index 6dffbd16..ab012390 100644 --- a/src/fs_getdents64.cpp +++ b/src/fs_getdents64.cpp @@ -18,6 +18,8 @@ #include "to_neg_errno.hpp" +#include + #if defined __linux__ #include #include diff --git a/src/fs_mounts.cpp b/src/fs_mounts.cpp index b77350b6..c3f76116 100644 --- a/src/fs_mounts.cpp +++ b/src/fs_mounts.cpp @@ -2,9 +2,9 @@ #include +#ifdef __linux__ #include -#ifdef __linux__ void fs::mounts(fs::MountVec &mounts_) { @@ -29,9 +29,12 @@ fs::mounts(fs::MountVec &mounts_) ::endmntent(f); } + #else + void fs::mounts(fs::MountVec &mounts_) { } + #endif diff --git a/src/fs_sendfile.hpp b/src/fs_sendfile.hpp index ae2fb017..163cd631 100644 --- a/src/fs_sendfile.hpp +++ b/src/fs_sendfile.hpp @@ -16,6 +16,8 @@ #pragma once +#include + namespace fs { diff --git a/src/fuse_copy_file_range.cpp b/src/fuse_copy_file_range.cpp index ac72324e..cd9277d3 100644 --- a/src/fuse_copy_file_range.cpp +++ b/src/fuse_copy_file_range.cpp @@ -27,19 +27,19 @@ static ssize_t -_copy_file_range(const int fd_in_, - off_t offset_in_, - const int fd_out_, - off_t offset_out_, +_copy_file_range(const int src_fd_, + off_t src_off_, + const int dst_fd_, + off_t dst_off_, size_t size_, int flags_) { ssize_t rv; - rv = fs::copy_file_range(fd_in_, - &offset_in_, - fd_out_, - &offset_out_, + rv = fs::copy_file_range(src_fd_, + &src_off_, + dst_fd_, + &dst_off_, size_, flags_); @@ -47,20 +47,20 @@ _copy_file_range(const int fd_in_, } ssize_t -FUSE::copy_file_range(const fuse_file_info_t *ffi_in_, - off_t offset_in_, - const fuse_file_info_t *ffi_out_, - off_t offset_out_, - size_t size_, - int flags_) +FUSE::copy_file_range(const fuse_file_info_t *src_ffi_, + off_t src_off_, + const fuse_file_info_t *dst_ffi_, + off_t dst_off_, + const size_t size_, + const unsigned int flags_) { - FileInfo *fi_in = FileInfo::from_fh(ffi_in_->fh); - FileInfo *fi_out = FileInfo::from_fh(ffi_out_->fh); + FileInfo *src_fi = FileInfo::from_fh(src_ffi_->fh); + FileInfo *dst_fi = FileInfo::from_fh(dst_ffi_->fh); - return ::_copy_file_range(fi_in->fd, - offset_in_, - fi_out->fd, - offset_out_, + return ::_copy_file_range(src_fi->fd, + src_off_, + dst_fi->fd, + dst_off_, size_, flags_); } diff --git a/src/fuse_copy_file_range.hpp b/src/fuse_copy_file_range.hpp index 60a28ba3..4b7f7804 100644 --- a/src/fuse_copy_file_range.hpp +++ b/src/fuse_copy_file_range.hpp @@ -36,6 +36,6 @@ namespace FUSE off_t offset_in, const fuse_file_info_t *ffi_out, off_t offset_out, - size_t size, - int flags); + const size_t size, + const unsigned int flags); } diff --git a/src/fuse_readdir_cor_getdents.icpp b/src/fuse_readdir_cor_getdents.icpp index 55ef995e..4132078e 100644 --- a/src/fuse_readdir_cor_getdents.icpp +++ b/src/fuse_readdir_cor_getdents.icpp @@ -52,20 +52,20 @@ _readdir(const fs::path &branch_path_, int namelen; fs::dirent64 *d = reinterpret_cast(&buf->mem[pos]); - pos += d->d_reclen; + pos += d->reclen; - namelen = d->d_namelen(); + namelen = d->namelen(); - rv = names_.put(d->d_name,namelen); + rv = names_.put(d->name,namelen); if(rv == 0) continue; - rel_filepath.replace_filename(d->d_name); + rel_filepath.replace_filename(d->name); - d->d_ino = fs::inode::calc(branch_path_, - rel_filepath, - DTTOIF(d->d_type), - d->d_ino); + d->ino = fs::inode::calc(branch_path_, + rel_filepath, + DTTOIF(d->type), + d->ino); fuse_dirents_add(dirents_,d,namelen); } diff --git a/src/fuse_readdir_cosr_getdents.icpp b/src/fuse_readdir_cosr_getdents.icpp index c888ec28..40e3992d 100644 --- a/src/fuse_readdir_cosr_getdents.icpp +++ b/src/fuse_readdir_cosr_getdents.icpp @@ -101,20 +101,20 @@ _readdir(std::vector> &dh_futures_, int namelen; fs::dirent64 *d = reinterpret_cast(&buf->mem[pos]); - pos += d->d_reclen; + pos += d->reclen; - namelen = d->d_namelen(); + namelen = d->namelen(); - rv = names.put(d->d_name,namelen); + rv = names.put(d->name,namelen); if(rv == 0) continue; - rel_filepath.replace_filename(d->d_name); + rel_filepath.replace_filename(d->name); - d->d_ino = fs::inode::calc(*dirrv.branch_path, - rel_filepath, - DTTOIF(d->d_type), - d->d_ino); + d->ino = fs::inode::calc(*dirrv.branch_path, + rel_filepath, + DTTOIF(d->type), + d->ino); fuse_dirents_add(dirents_,d,namelen); } diff --git a/src/fuse_readdir_cosr_readdir.icpp b/src/fuse_readdir_cosr_readdir.icpp index 2c38a299..ec76060e 100644 --- a/src/fuse_readdir_cosr_readdir.icpp +++ b/src/fuse_readdir_cosr_readdir.icpp @@ -73,9 +73,9 @@ _opendir(ThreadPool &tp_, static inline int -_readdir(const std::vector> &dh_futures_, - const fs::path &rel_dirpath_, - fuse_dirents_t *dirents_) +_readdir(std::vector> &dh_futures_, + const fs::path &rel_dirpath_, + fuse_dirents_t *dirents_) { Err err; HashSet names; diff --git a/src/fuse_readdir_seq_getdents.icpp b/src/fuse_readdir_seq_getdents.icpp index e652ae4b..7cf29b27 100644 --- a/src/fuse_readdir_seq_getdents.icpp +++ b/src/fuse_readdir_seq_getdents.icpp @@ -57,20 +57,20 @@ _readdir(const Branches::Ptr &branches_, int namelen; fs::dirent64 *d = reinterpret_cast(&buf->mem[pos]); - pos += d->d_reclen; + pos += d->reclen; - namelen = d->d_namelen(); + namelen = d->namelen(); - rv = names.put(d->d_name,namelen); + rv = names.put(d->name,namelen); if(rv == 0) continue; - rel_filepath.replace_filename(d->d_name); + rel_filepath.replace_filename(d->name); - d->d_ino = fs::inode::calc(branch.path, - rel_filepath, - DTTOIF(d->d_type), - d->d_ino); + d->ino = fs::inode::calc(branch.path, + rel_filepath, + DTTOIF(d->type), + d->ino); fuse_dirents_add(dirents_,d,namelen); } diff --git a/src/fuse_readdir_seq_readdir.icpp b/src/fuse_readdir_seq_readdir.icpp index ab92f97d..c286a111 100644 --- a/src/fuse_readdir_seq_readdir.icpp +++ b/src/fuse_readdir_seq_readdir.icpp @@ -37,7 +37,7 @@ _readdir(const Branches::Ptr &branches_, fs::path rel_filepath; fs::path abs_dirpath; - fuse_dirents_reset(buf_); + fuse_dirents_reset(dirents_); rel_filepath = rel_dirpath_ / "dummy"; for(const auto &branch : *branches_) @@ -73,7 +73,7 @@ _readdir(const Branches::Ptr &branches_, DTTOIF(de->d_type), de->d_ino); - fuse_dirents_add(buf_,de,namelen); + fuse_dirents_add(dirents_,de,namelen); } } diff --git a/src/ioprio.cpp b/src/ioprio.cpp index 235259f0..80daf5a4 100644 --- a/src/ioprio.cpp +++ b/src/ioprio.cpp @@ -1,9 +1,10 @@ #include "ioprio.hpp" +#include + #ifdef __linux__ # include # include -# include #else #warning "ioprio not supported on this platform" #endif @@ -17,33 +18,33 @@ thread_local int ioprio::SetFrom::thread_prio = -1; bool _enabled = false; int -ioprio::get(const int which_, - const int who_) +ioprio::get(const int who_) { #ifdef SYS_ioprio_get int rv; + const int which = IOPRIO_WHO_PROCESS; - rv = syscall(SYS_ioprio_get,which_,who_); + rv = syscall(SYS_ioprio_get,which,who_); return ((rv == -1) ? -errno : rv); #else - return -ENOSUP; + return -EOPNOTSUPP; #endif } int -ioprio::set(const int which_, - const int who_, +ioprio::set(const int who_, const int ioprio_) { #ifdef SYS_ioprio_set int rv; + const int which = IOPRIO_WHO_PROCESS; - rv = syscall(SYS_ioprio_set,which_,who_,ioprio_); + rv = syscall(SYS_ioprio_set,which,who_,ioprio_); return ((rv == -1) ? -errno : rv); #else - return -ENOSUP; + return -EOPNOTSUPP; #endif } @@ -66,12 +67,12 @@ ioprio::SetFrom::SetFrom(const pid_t pid_) if(!_enabled) return; - client_prio = ioprio::get(IOPRIO_WHO_PROCESS,pid_); + client_prio = ioprio::get(pid_); if(client_prio < 0) return; if(client_prio == thread_prio) return; thread_prio = client_prio; - ioprio::set(IOPRIO_WHO_PROCESS,0,client_prio); + ioprio::set(0,client_prio); } diff --git a/src/ioprio.hpp b/src/ioprio.hpp index b70def19..7c20198d 100644 --- a/src/ioprio.hpp +++ b/src/ioprio.hpp @@ -8,8 +8,8 @@ namespace ioprio void enable(const bool); bool enabled(); - int get(const int which, const int who); - int set(const int which, const int who, const int ioprio); + int get(const int who); + int set(const int who, const int ioprio); struct SetFrom { diff --git a/src/tofrom_wrapper.hpp b/src/tofrom_wrapper.hpp index a559ce96..5eb1fe34 100644 --- a/src/tofrom_wrapper.hpp +++ b/src/tofrom_wrapper.hpp @@ -100,7 +100,7 @@ class ROToFromWrapper : public ToFromString { public: int - from_string(const std::string &s_) final + from_string(const std::string_view s_) final { return -EINVAL; }