Browse Source

misc fixes for FreeBSD

pull/580/head
Antonio SJ Musumeci 6 years ago
parent
commit
940c323251
  1. 638
      libfuse/include/fuse_kernel.h
  2. 8
      src/fs_copy_file_range.hpp
  3. 62
      src/fs_copy_file_range_linux.icpp
  4. 10
      src/fs_copy_file_range_unsupported.icpp
  5. 4
      tools/install-build-pkgs

638
libfuse/include/fuse_kernel.h

@ -1,3 +1,4 @@
/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) */
/* /*
This file defines the kernel interface of FUSE This file defines the kernel interface of FUSE
Copyright (C) 2001-2008 Miklos Szeredi <miklos@szeredi.hu> Copyright (C) 2001-2008 Miklos Szeredi <miklos@szeredi.hu>
@ -83,13 +84,51 @@
* *
* 7.19 * 7.19
* - add FUSE_FALLOCATE * - add FUSE_FALLOCATE
*
* 7.20
* - add FUSE_AUTO_INVAL_DATA
*
* 7.21
* - add FUSE_READDIRPLUS
* - send the requested events in POLL request
*
* 7.22
* - add FUSE_ASYNC_DIO
*
* 7.23
* - add FUSE_WRITEBACK_CACHE
* - add time_gran to fuse_init_out
* - add reserved space to fuse_init_out
* - add FATTR_CTIME
* - add ctime and ctimensec to fuse_setattr_in
* - add FUSE_RENAME2 request
* - add FUSE_NO_OPEN_SUPPORT flag
*
* 7.24
* - add FUSE_LSEEK for SEEK_HOLE and SEEK_DATA support
*
* 7.25
* - add FUSE_PARALLEL_DIROPS
*
* 7.26
* - add FUSE_HANDLE_KILLPRIV
* - add FUSE_POSIX_ACL
*
* 7.27
* - add FUSE_ABORT_ERROR
*
* 7.28
* - add FUSE_COPY_FILE_RANGE
*/ */
#ifndef _LINUX_FUSE_H #ifndef _LINUX_FUSE_H
#define _LINUX_FUSE_H #define _LINUX_FUSE_H
#ifdef __KERNEL__
#include <linux/types.h> #include <linux/types.h>
#include <sys/types.h>
#else
#include <stdint.h>
#endif
/* /*
* Version negotiation: * Version negotiation:
@ -115,7 +154,7 @@
#define FUSE_KERNEL_VERSION 7 #define FUSE_KERNEL_VERSION 7
/** Minor version number of this interface */ /** Minor version number of this interface */
#define FUSE_KERNEL_MINOR_VERSION 19
#define FUSE_KERNEL_MINOR_VERSION 27
/** The node ID of the root inode */ /** The node ID of the root inode */
#define FUSE_ROOT_ID 1 #define FUSE_ROOT_ID 1
@ -124,42 +163,42 @@
userspace works under 64bit kernels */ userspace works under 64bit kernels */
struct fuse_attr { struct fuse_attr {
__u64 ino;
__u64 size;
__u64 blocks;
__u64 atime;
__u64 mtime;
__u64 ctime;
__u32 atimensec;
__u32 mtimensec;
__u32 ctimensec;
__u32 mode;
__u32 nlink;
__u32 uid;
__u32 gid;
__u32 rdev;
__u32 blksize;
__u32 padding;
uint64_t ino;
uint64_t size;
uint64_t blocks;
uint64_t atime;
uint64_t mtime;
uint64_t ctime;
uint32_t atimensec;
uint32_t mtimensec;
uint32_t ctimensec;
uint32_t mode;
uint32_t nlink;
uint32_t uid;
uint32_t gid;
uint32_t rdev;
uint32_t blksize;
uint32_t padding;
}; };
struct fuse_kstatfs { struct fuse_kstatfs {
__u64 blocks;
__u64 bfree;
__u64 bavail;
__u64 files;
__u64 ffree;
__u32 bsize;
__u32 namelen;
__u32 frsize;
__u32 padding;
__u32 spare[6];
uint64_t blocks;
uint64_t bfree;
uint64_t bavail;
uint64_t files;
uint64_t ffree;
uint32_t bsize;
uint32_t namelen;
uint32_t frsize;
uint32_t padding;
uint32_t spare[6];
}; };
struct fuse_file_lock { struct fuse_file_lock {
__u64 start;
__u64 end;
__u32 type;
__u32 pid; /* tgid */
uint64_t start;
uint64_t end;
uint32_t type;
uint32_t pid; /* tgid */
}; };
/** /**
@ -175,6 +214,7 @@ struct fuse_file_lock {
#define FATTR_ATIME_NOW (1 << 7) #define FATTR_ATIME_NOW (1 << 7)
#define FATTR_MTIME_NOW (1 << 8) #define FATTR_MTIME_NOW (1 << 8)
#define FATTR_LOCKOWNER (1 << 9) #define FATTR_LOCKOWNER (1 << 9)
#define FATTR_CTIME (1 << 10)
/** /**
* Flags returned by the OPEN request * Flags returned by the OPEN request
@ -190,10 +230,28 @@ struct fuse_file_lock {
/** /**
* INIT request/reply flags * INIT request/reply flags
* *
* FUSE_ASYNC_READ: asynchronous read requests
* FUSE_POSIX_LOCKS: remote locking for POSIX file locks * FUSE_POSIX_LOCKS: remote locking for POSIX file locks
* FUSE_FILE_OPS: kernel sends file handle for fstat, etc... (not yet supported)
* FUSE_ATOMIC_O_TRUNC: handles the O_TRUNC open flag in the filesystem
* FUSE_EXPORT_SUPPORT: filesystem handles lookups of "." and ".." * FUSE_EXPORT_SUPPORT: filesystem handles lookups of "." and ".."
* FUSE_BIG_WRITES: filesystem can handle write size larger than 4kB
* FUSE_DONT_MASK: don't apply umask to file mode on create operations * FUSE_DONT_MASK: don't apply umask to file mode on create operations
* FUSE_SPLICE_WRITE: kernel supports splice write on the device
* FUSE_SPLICE_MOVE: kernel supports splice move on the device
* FUSE_SPLICE_READ: kernel supports splice read on the device
* FUSE_FLOCK_LOCKS: remote locking for BSD style file locks * FUSE_FLOCK_LOCKS: remote locking for BSD style file locks
* FUSE_HAS_IOCTL_DIR: kernel supports ioctl on directories
* FUSE_AUTO_INVAL_DATA: automatically invalidate cached pages
* FUSE_DO_READDIRPLUS: do READDIRPLUS (READDIR+LOOKUP in one)
* FUSE_READDIRPLUS_AUTO: adaptive readdirplus
* FUSE_ASYNC_DIO: asynchronous direct I/O submission
* FUSE_WRITEBACK_CACHE: use writeback cache for buffered writes
* FUSE_NO_OPEN_SUPPORT: kernel supports zero-message opens
* FUSE_PARALLEL_DIROPS: allow parallel lookups and readdir
* FUSE_HANDLE_KILLPRIV: fs handles killing suid/sgid/cap on write/chown/trunc
* FUSE_POSIX_ACL: filesystem supports posix acls
* FUSE_ABORT_ERROR: reading the device after abort returns ECONNABORTED
*/ */
#define FUSE_ASYNC_READ (1 << 0) #define FUSE_ASYNC_READ (1 << 0)
#define FUSE_POSIX_LOCKS (1 << 1) #define FUSE_POSIX_LOCKS (1 << 1)
@ -202,7 +260,21 @@ struct fuse_file_lock {
#define FUSE_EXPORT_SUPPORT (1 << 4) #define FUSE_EXPORT_SUPPORT (1 << 4)
#define FUSE_BIG_WRITES (1 << 5) #define FUSE_BIG_WRITES (1 << 5)
#define FUSE_DONT_MASK (1 << 6) #define FUSE_DONT_MASK (1 << 6)
#define FUSE_SPLICE_WRITE (1 << 7)
#define FUSE_SPLICE_MOVE (1 << 8)
#define FUSE_SPLICE_READ (1 << 9)
#define FUSE_FLOCK_LOCKS (1 << 10) #define FUSE_FLOCK_LOCKS (1 << 10)
#define FUSE_HAS_IOCTL_DIR (1 << 11)
#define FUSE_AUTO_INVAL_DATA (1 << 12)
#define FUSE_DO_READDIRPLUS (1 << 13)
#define FUSE_READDIRPLUS_AUTO (1 << 14)
#define FUSE_ASYNC_DIO (1 << 15)
#define FUSE_WRITEBACK_CACHE (1 << 16)
#define FUSE_NO_OPEN_SUPPORT (1 << 17)
#define FUSE_PARALLEL_DIROPS (1 << 18)
#define FUSE_HANDLE_KILLPRIV (1 << 19)
#define FUSE_POSIX_ACL (1 << 20)
#define FUSE_ABORT_ERROR (1 << 21)
/** /**
* CUSE INIT request/reply flags * CUSE INIT request/reply flags
@ -268,50 +340,54 @@ struct fuse_file_lock {
#define FUSE_POLL_SCHEDULE_NOTIFY (1 << 0) #define FUSE_POLL_SCHEDULE_NOTIFY (1 << 0)
enum fuse_opcode { enum fuse_opcode {
FUSE_LOOKUP = 1,
FUSE_FORGET = 2, /* no reply */
FUSE_GETATTR = 3,
FUSE_SETATTR = 4,
FUSE_READLINK = 5,
FUSE_SYMLINK = 6,
FUSE_MKNOD = 8,
FUSE_MKDIR = 9,
FUSE_UNLINK = 10,
FUSE_RMDIR = 11,
FUSE_RENAME = 12,
FUSE_LINK = 13,
FUSE_OPEN = 14,
FUSE_READ = 15,
FUSE_WRITE = 16,
FUSE_STATFS = 17,
FUSE_RELEASE = 18,
FUSE_FSYNC = 20,
FUSE_SETXATTR = 21,
FUSE_GETXATTR = 22,
FUSE_LISTXATTR = 23,
FUSE_REMOVEXATTR = 24,
FUSE_FLUSH = 25,
FUSE_INIT = 26,
FUSE_OPENDIR = 27,
FUSE_READDIR = 28,
FUSE_RELEASEDIR = 29,
FUSE_FSYNCDIR = 30,
FUSE_GETLK = 31,
FUSE_SETLK = 32,
FUSE_SETLKW = 33,
FUSE_ACCESS = 34,
FUSE_CREATE = 35,
FUSE_INTERRUPT = 36,
FUSE_BMAP = 37,
FUSE_DESTROY = 38,
FUSE_IOCTL = 39,
FUSE_POLL = 40,
FUSE_NOTIFY_REPLY = 41,
FUSE_BATCH_FORGET = 42,
FUSE_FALLOCATE = 43,
FUSE_LOOKUP = 1,
FUSE_FORGET = 2, /* no reply */
FUSE_GETATTR = 3,
FUSE_SETATTR = 4,
FUSE_READLINK = 5,
FUSE_SYMLINK = 6,
FUSE_MKNOD = 8,
FUSE_MKDIR = 9,
FUSE_UNLINK = 10,
FUSE_RMDIR = 11,
FUSE_RENAME = 12,
FUSE_LINK = 13,
FUSE_OPEN = 14,
FUSE_READ = 15,
FUSE_WRITE = 16,
FUSE_STATFS = 17,
FUSE_RELEASE = 18,
FUSE_FSYNC = 20,
FUSE_SETXATTR = 21,
FUSE_GETXATTR = 22,
FUSE_LISTXATTR = 23,
FUSE_REMOVEXATTR = 24,
FUSE_FLUSH = 25,
FUSE_INIT = 26,
FUSE_OPENDIR = 27,
FUSE_READDIR = 28,
FUSE_RELEASEDIR = 29,
FUSE_FSYNCDIR = 30,
FUSE_GETLK = 31,
FUSE_SETLK = 32,
FUSE_SETLKW = 33,
FUSE_ACCESS = 34,
FUSE_CREATE = 35,
FUSE_INTERRUPT = 36,
FUSE_BMAP = 37,
FUSE_DESTROY = 38,
FUSE_IOCTL = 39,
FUSE_POLL = 40,
FUSE_NOTIFY_REPLY = 41,
FUSE_BATCH_FORGET = 42,
FUSE_FALLOCATE = 43,
FUSE_READDIRPLUS = 44,
FUSE_RENAME2 = 45,
FUSE_LSEEK = 46,
FUSE_COPY_FILE_RANGE = 47,
/* CUSE specific operations */ /* CUSE specific operations */
CUSE_INIT = 4096,
CUSE_INIT = 4096,
}; };
enum fuse_notify_code { enum fuse_notify_code {
@ -330,143 +406,149 @@ enum fuse_notify_code {
#define FUSE_COMPAT_ENTRY_OUT_SIZE 120 #define FUSE_COMPAT_ENTRY_OUT_SIZE 120
struct fuse_entry_out { struct fuse_entry_out {
__u64 nodeid; /* Inode ID */
__u64 generation; /* Inode generation: nodeid:gen must
be unique for the fs's lifetime */
__u64 entry_valid; /* Cache timeout for the name */
__u64 attr_valid; /* Cache timeout for the attributes */
__u32 entry_valid_nsec;
__u32 attr_valid_nsec;
uint64_t nodeid; /* Inode ID */
uint64_t generation; /* Inode generation: nodeid:gen must
be unique for the fs's lifetime */
uint64_t entry_valid; /* Cache timeout for the name */
uint64_t attr_valid; /* Cache timeout for the attributes */
uint32_t entry_valid_nsec;
uint32_t attr_valid_nsec;
struct fuse_attr attr; struct fuse_attr attr;
}; };
struct fuse_forget_in { struct fuse_forget_in {
__u64 nlookup;
uint64_t nlookup;
}; };
struct fuse_forget_one { struct fuse_forget_one {
__u64 nodeid;
__u64 nlookup;
uint64_t nodeid;
uint64_t nlookup;
}; };
struct fuse_batch_forget_in { struct fuse_batch_forget_in {
__u32 count;
__u32 dummy;
uint32_t count;
uint32_t dummy;
}; };
struct fuse_getattr_in { struct fuse_getattr_in {
__u32 getattr_flags;
__u32 dummy;
__u64 fh;
uint32_t getattr_flags;
uint32_t dummy;
uint64_t fh;
}; };
#define FUSE_COMPAT_ATTR_OUT_SIZE 96 #define FUSE_COMPAT_ATTR_OUT_SIZE 96
struct fuse_attr_out { struct fuse_attr_out {
__u64 attr_valid; /* Cache timeout for the attributes */
__u32 attr_valid_nsec;
__u32 dummy;
uint64_t attr_valid; /* Cache timeout for the attributes */
uint32_t attr_valid_nsec;
uint32_t dummy;
struct fuse_attr attr; struct fuse_attr attr;
}; };
#define FUSE_COMPAT_MKNOD_IN_SIZE 8 #define FUSE_COMPAT_MKNOD_IN_SIZE 8
struct fuse_mknod_in { struct fuse_mknod_in {
__u32 mode;
__u32 rdev;
__u32 umask;
__u32 padding;
uint32_t mode;
uint32_t rdev;
uint32_t umask;
uint32_t padding;
}; };
struct fuse_mkdir_in { struct fuse_mkdir_in {
__u32 mode;
__u32 umask;
uint32_t mode;
uint32_t umask;
}; };
struct fuse_rename_in { struct fuse_rename_in {
__u64 newdir;
uint64_t newdir;
};
struct fuse_rename2_in {
uint64_t newdir;
uint32_t flags;
uint32_t padding;
}; };
struct fuse_link_in { struct fuse_link_in {
__u64 oldnodeid;
uint64_t oldnodeid;
}; };
struct fuse_setattr_in { struct fuse_setattr_in {
__u32 valid;
__u32 padding;
__u64 fh;
__u64 size;
__u64 lock_owner;
__u64 atime;
__u64 mtime;
__u64 unused2;
__u32 atimensec;
__u32 mtimensec;
__u32 unused3;
__u32 mode;
__u32 unused4;
__u32 uid;
__u32 gid;
__u32 unused5;
uint32_t valid;
uint32_t padding;
uint64_t fh;
uint64_t size;
uint64_t lock_owner;
uint64_t atime;
uint64_t mtime;
uint64_t ctime;
uint32_t atimensec;
uint32_t mtimensec;
uint32_t ctimensec;
uint32_t mode;
uint32_t unused4;
uint32_t uid;
uint32_t gid;
uint32_t unused5;
}; };
struct fuse_open_in { struct fuse_open_in {
__u32 flags;
__u32 unused;
uint32_t flags;
uint32_t unused;
}; };
struct fuse_create_in { struct fuse_create_in {
__u32 flags;
__u32 mode;
__u32 umask;
__u32 padding;
uint32_t flags;
uint32_t mode;
uint32_t umask;
uint32_t padding;
}; };
struct fuse_open_out { struct fuse_open_out {
__u64 fh;
__u32 open_flags;
__u32 padding;
uint64_t fh;
uint32_t open_flags;
uint32_t padding;
}; };
struct fuse_release_in { struct fuse_release_in {
__u64 fh;
__u32 flags;
__u32 release_flags;
__u64 lock_owner;
uint64_t fh;
uint32_t flags;
uint32_t release_flags;
uint64_t lock_owner;
}; };
struct fuse_flush_in { struct fuse_flush_in {
__u64 fh;
__u32 unused;
__u32 padding;
__u64 lock_owner;
uint64_t fh;
uint32_t unused;
uint32_t padding;
uint64_t lock_owner;
}; };
struct fuse_read_in { struct fuse_read_in {
__u64 fh;
__u64 offset;
__u32 size;
__u32 read_flags;
__u64 lock_owner;
__u32 flags;
__u32 padding;
uint64_t fh;
uint64_t offset;
uint32_t size;
uint32_t read_flags;
uint64_t lock_owner;
uint32_t flags;
uint32_t padding;
}; };
#define FUSE_COMPAT_WRITE_IN_SIZE 24 #define FUSE_COMPAT_WRITE_IN_SIZE 24
struct fuse_write_in { struct fuse_write_in {
__u64 fh;
__u64 offset;
__u32 size;
__u32 write_flags;
__u64 lock_owner;
__u32 flags;
__u32 padding;
uint64_t fh;
uint64_t offset;
uint32_t size;
uint32_t write_flags;
uint64_t lock_owner;
uint32_t flags;
uint32_t padding;
}; };
struct fuse_write_out { struct fuse_write_out {
__u32 size;
__u32 padding;
uint32_t size;
uint32_t padding;
}; };
#define FUSE_COMPAT_STATFS_SIZE 48 #define FUSE_COMPAT_STATFS_SIZE 48
@ -476,32 +558,32 @@ struct fuse_statfs_out {
}; };
struct fuse_fsync_in { struct fuse_fsync_in {
__u64 fh;
__u32 fsync_flags;
__u32 padding;
uint64_t fh;
uint32_t fsync_flags;
uint32_t padding;
}; };
struct fuse_setxattr_in { struct fuse_setxattr_in {
__u32 size;
__u32 flags;
uint32_t size;
uint32_t flags;
}; };
struct fuse_getxattr_in { struct fuse_getxattr_in {
__u32 size;
__u32 padding;
uint32_t size;
uint32_t padding;
}; };
struct fuse_getxattr_out { struct fuse_getxattr_out {
__u32 size;
__u32 padding;
uint32_t size;
uint32_t padding;
}; };
struct fuse_lk_in { struct fuse_lk_in {
__u64 fh;
__u64 owner;
uint64_t fh;
uint64_t owner;
struct fuse_file_lock lk; struct fuse_file_lock lk;
__u32 lk_flags;
__u32 padding;
uint32_t lk_flags;
uint32_t padding;
}; };
struct fuse_lk_out { struct fuse_lk_out {
@ -509,179 +591,219 @@ struct fuse_lk_out {
}; };
struct fuse_access_in { struct fuse_access_in {
__u32 mask;
__u32 padding;
uint32_t mask;
uint32_t padding;
}; };
struct fuse_init_in { struct fuse_init_in {
__u32 major;
__u32 minor;
__u32 max_readahead;
__u32 flags;
uint32_t major;
uint32_t minor;
uint32_t max_readahead;
uint32_t flags;
}; };
#define FUSE_COMPAT_INIT_OUT_SIZE 8
#define FUSE_COMPAT_22_INIT_OUT_SIZE 24
struct fuse_init_out { struct fuse_init_out {
__u32 major;
__u32 minor;
__u32 max_readahead;
__u32 flags;
__u16 max_background;
__u16 congestion_threshold;
__u32 max_write;
uint32_t major;
uint32_t minor;
uint32_t max_readahead;
uint32_t flags;
uint16_t max_background;
uint16_t congestion_threshold;
uint32_t max_write;
uint32_t time_gran;
uint32_t unused[9];
}; };
#define CUSE_INIT_INFO_MAX 4096 #define CUSE_INIT_INFO_MAX 4096
struct cuse_init_in { struct cuse_init_in {
__u32 major;
__u32 minor;
__u32 unused;
__u32 flags;
uint32_t major;
uint32_t minor;
uint32_t unused;
uint32_t flags;
}; };
struct cuse_init_out { struct cuse_init_out {
__u32 major;
__u32 minor;
__u32 unused;
__u32 flags;
__u32 max_read;
__u32 max_write;
__u32 dev_major; /* chardev major */
__u32 dev_minor; /* chardev minor */
__u32 spare[10];
uint32_t major;
uint32_t minor;
uint32_t unused;
uint32_t flags;
uint32_t max_read;
uint32_t max_write;
uint32_t dev_major; /* chardev major */
uint32_t dev_minor; /* chardev minor */
uint32_t spare[10];
}; };
struct fuse_interrupt_in { struct fuse_interrupt_in {
__u64 unique;
uint64_t unique;
}; };
struct fuse_bmap_in { struct fuse_bmap_in {
__u64 block;
__u32 blocksize;
__u32 padding;
uint64_t block;
uint32_t blocksize;
uint32_t padding;
}; };
struct fuse_bmap_out { struct fuse_bmap_out {
__u64 block;
uint64_t block;
}; };
struct fuse_ioctl_in { struct fuse_ioctl_in {
__u64 fh;
__u32 flags;
__u32 cmd;
__u64 arg;
__u32 in_size;
__u32 out_size;
uint64_t fh;
uint32_t flags;
uint32_t cmd;
uint64_t arg;
uint32_t in_size;
uint32_t out_size;
}; };
struct fuse_ioctl_iovec { struct fuse_ioctl_iovec {
__u64 base;
__u64 len;
uint64_t base;
uint64_t len;
}; };
struct fuse_ioctl_out { struct fuse_ioctl_out {
__s32 result;
__u32 flags;
__u32 in_iovs;
__u32 out_iovs;
int32_t result;
uint32_t flags;
uint32_t in_iovs;
uint32_t out_iovs;
}; };
struct fuse_poll_in { struct fuse_poll_in {
__u64 fh;
__u64 kh;
__u32 flags;
__u32 padding;
uint64_t fh;
uint64_t kh;
uint32_t flags;
uint32_t events;
}; };
struct fuse_poll_out { struct fuse_poll_out {
__u32 revents;
__u32 padding;
uint32_t revents;
uint32_t padding;
}; };
struct fuse_notify_poll_wakeup_out { struct fuse_notify_poll_wakeup_out {
__u64 kh;
uint64_t kh;
}; };
struct fuse_fallocate_in { struct fuse_fallocate_in {
__u64 fh;
__u64 offset;
__u64 length;
__u32 mode;
__u32 padding;
uint64_t fh;
uint64_t offset;
uint64_t length;
uint32_t mode;
uint32_t padding;
}; };
struct fuse_in_header { struct fuse_in_header {
__u32 len;
__u32 opcode;
__u64 unique;
__u64 nodeid;
__u32 uid;
__u32 gid;
__u32 pid;
__u32 padding;
uint32_t len;
uint32_t opcode;
uint64_t unique;
uint64_t nodeid;
uint32_t uid;
uint32_t gid;
uint32_t pid;
uint32_t padding;
}; };
struct fuse_out_header { struct fuse_out_header {
__u32 len;
__s32 error;
__u64 unique;
uint32_t len;
int32_t error;
uint64_t unique;
}; };
struct fuse_dirent { struct fuse_dirent {
__u64 ino;
__u64 off;
__u32 namelen;
__u32 type;
uint64_t ino;
uint64_t off;
uint32_t namelen;
uint32_t type;
char name[]; char name[];
}; };
#define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name) #define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name)
#define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1))
#define FUSE_DIRENT_ALIGN(x) \
(((x) + sizeof(uint64_t) - 1) & ~(sizeof(uint64_t) - 1))
#define FUSE_DIRENT_SIZE(d) \ #define FUSE_DIRENT_SIZE(d) \
FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen) FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)
struct fuse_direntplus {
struct fuse_entry_out entry_out;
struct fuse_dirent dirent;
};
#define FUSE_NAME_OFFSET_DIRENTPLUS \
offsetof(struct fuse_direntplus, dirent.name)
#define FUSE_DIRENTPLUS_SIZE(d) \
FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET_DIRENTPLUS + (d)->dirent.namelen)
struct fuse_notify_inval_inode_out { struct fuse_notify_inval_inode_out {
__u64 ino;
__s64 off;
__s64 len;
uint64_t ino;
int64_t off;
int64_t len;
}; };
struct fuse_notify_inval_entry_out { struct fuse_notify_inval_entry_out {
__u64 parent;
__u32 namelen;
__u32 padding;
uint64_t parent;
uint32_t namelen;
uint32_t padding;
}; };
struct fuse_notify_delete_out { struct fuse_notify_delete_out {
__u64 parent;
__u64 child;
__u32 namelen;
__u32 padding;
uint64_t parent;
uint64_t child;
uint32_t namelen;
uint32_t padding;
}; };
struct fuse_notify_store_out { struct fuse_notify_store_out {
__u64 nodeid;
__u64 offset;
__u32 size;
__u32 padding;
uint64_t nodeid;
uint64_t offset;
uint32_t size;
uint32_t padding;
}; };
struct fuse_notify_retrieve_out { struct fuse_notify_retrieve_out {
__u64 notify_unique;
__u64 nodeid;
__u64 offset;
__u32 size;
__u32 padding;
uint64_t notify_unique;
uint64_t nodeid;
uint64_t offset;
uint32_t size;
uint32_t padding;
}; };
/* Matches the size of fuse_write_in */ /* Matches the size of fuse_write_in */
struct fuse_notify_retrieve_in { struct fuse_notify_retrieve_in {
__u64 dummy1;
__u64 offset;
__u32 size;
__u32 dummy2;
__u64 dummy3;
__u64 dummy4;
uint64_t dummy1;
uint64_t offset;
uint32_t size;
uint32_t dummy2;
uint64_t dummy3;
uint64_t dummy4;
};
/* Device ioctls: */
#define FUSE_DEV_IOC_CLONE _IOR(229, 0, uint32_t)
struct fuse_lseek_in {
uint64_t fh;
uint64_t offset;
uint32_t whence;
uint32_t padding;
};
struct fuse_lseek_out {
uint64_t offset;
};
struct fuse_copy_file_range_in {
uint64_t fh_in;
uint64_t off_in;
uint64_t nodeid_out;
uint64_t fh_out;
uint64_t off_out;
uint64_t len;
uint64_t flags;
}; };
#endif /* _LINUX_FUSE_H */ #endif /* _LINUX_FUSE_H */

8
src/fs_copy_file_range.hpp

@ -18,17 +18,17 @@
#pragma once #pragma once
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h> #include <sys/types.h>
#include <cstddef>
namespace fs namespace fs
{ {
ssize_t ssize_t
copy_file_range(const int fd_in_, copy_file_range(const int fd_in_,
loff_t *off_in_,
int64_t *off_in_,
const int fd_out_, const int fd_out_,
loff_t *off_out_,
int64_t *off_out_,
const size_t len_, const size_t len_,
const unsigned int flags_); const unsigned int flags_);

62
src/fs_copy_file_range_linux.icpp

@ -23,49 +23,67 @@
#include "errno.hpp" #include "errno.hpp"
#include <fcntl.h> #include <fcntl.h>
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <sys/syscall.h> #include <sys/syscall.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
static
loff_t
copy_file_range_(int fd_in_,
loff_t *off_in_,
int fd_out_,
loff_t *off_out_,
size_t len_,
unsigned int flags_)
namespace l
{ {
static
ssize_t
copy_file_range_(int fd_in_,
int64_t *off_in_,
int fd_out_,
int64_t *off_out_,
size_t len_,
unsigned int flags_)
{
#ifdef SYS_copy_file_range #ifdef SYS_copy_file_range
return ::syscall(SYS_copy_file_range,
ssize_t rv;
loff_t off_in;
loff_t off_out;
off_in = *off_in_;
off_out = *off_out_;
rv = ::syscall(SYS_copy_file_range,
fd_in_, fd_in_,
off_in_,
&off_in,
fd_out_, fd_out_,
off_out_,
&off_out,
len_, len_,
flags_); flags_);
if(rv != -1)
{
*off_in_ = off_in;
*off_out_ = off_out;
}
return rv;
#else #else
return (errno=EOPNOTSUPP,-1);
return (errno=EOPNOTSUPP,-1);
#endif #endif
}
} }
namespace fs namespace fs
{ {
ssize_t ssize_t
copy_file_range(const int fd_in_, copy_file_range(const int fd_in_,
loff_t *off_in_,
int64_t *off_in_,
const int fd_out_, const int fd_out_,
loff_t *off_out_,
int64_t *off_out_,
const size_t len_, const size_t len_,
const unsigned int flags_) const unsigned int flags_)
{ {
return ::copy_file_range_(fd_in_,
off_in_,
fd_out_,
off_out_,
len_,
flags_);
return l::copy_file_range_(fd_in_,
off_in_,
fd_out_,
off_out_,
len_,
flags_);
} }
ssize_t ssize_t
@ -74,8 +92,8 @@ namespace fs
const size_t len_, const size_t len_,
const unsigned int flags_) const unsigned int flags_)
{ {
loff_t off_in;
loff_t off_out;
int64_t off_in;
int64_t off_out;
off_in = 0; off_in = 0;
off_out = 0; off_out = 0;

10
src/fs_copy_file_range_unsupported.icpp

@ -16,15 +16,19 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
#include <cstddef>
#include "errno.h"
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
namespace fs namespace fs
{ {
ssize_t ssize_t
copy_file_range(const int fd_in_, copy_file_range(const int fd_in_,
loff_t *off_in_,
int64_t *off_in_,
const int fd_out_, const int fd_out_,
loff_t *off_out_,
int64_t *off_out_,
const size_t len_, const size_t len_,
const unsigned int flags_) const unsigned int flags_)
{ {

4
tools/install-build-pkgs

@ -22,4 +22,8 @@ elif [ -e /sbin/apk ]; then
apk add \ apk add \
abuild git gcc g++ make autoconf \ abuild git gcc g++ make autoconf \
automake libtool gettext-dev linux-headers automake libtool gettext-dev linux-headers
elif [ -e /usr/sbin/pkg ]; then
pkg install \
git gmake gcc autoconf automake libtool \
gettext-tools
fi fi
Loading…
Cancel
Save