26#define FUSE_USE_VERSION 31 
   32#define _XOPEN_SOURCE 700 
   44#include <sys/socket.h> 
   52#include "passthrough_helpers.h" 
   54static int fill_dir_plus = 0;
 
   85static int xmp_getattr(
const char *path, 
struct stat *stbuf,
 
   91        res = lstat(path, stbuf);
 
   98static int xmp_access(
const char *path, 
int mask)
 
  102        res = access(path, mask);
 
  109static int xmp_readlink(
const char *path, 
char *buf, 
size_t size)
 
  113        res = readlink(path, buf, size - 1);
 
  122static int xmp_readdir(
const char *path, 
void *buf, 
fuse_fill_dir_t filler,
 
  137        while ((de = readdir(dp)) != NULL) {
 
  140                        fstatat(dirfd(dp), de->d_name, &st,
 
  141                                AT_SYMLINK_NOFOLLOW);
 
  143                        memset(&st, 0, 
sizeof(st));
 
  144                        st.st_ino = de->d_ino;
 
  145                        st.st_mode = de->d_type << 12;
 
  147                if (filler(buf, de->d_name, &st, 0, fill_dir_plus))
 
  155static int xmp_mknod(
const char *path, mode_t mode, dev_t rdev)
 
  159        res = mknod_wrapper(AT_FDCWD, path, NULL, mode, rdev);
 
  166static int xmp_mkdir(
const char *path, mode_t mode)
 
  170        res = mkdir(path, mode);
 
  177static int xmp_unlink(
const char *path)
 
  188static int xmp_rmdir(
const char *path)
 
  199static int xmp_symlink(
const char *from, 
const char *to)
 
  203        res = symlink(from, to);
 
  210static int xmp_rename(
const char *from, 
const char *to, 
unsigned int flags)
 
  217        res = rename(from, to);
 
  224static int xmp_link(
const char *from, 
const char *to)
 
  228        res = link(from, to);
 
  235static int xmp_chmod(
const char *path, mode_t mode,
 
  241        res = chmod(path, mode);
 
  248static int xmp_chown(
const char *path, uid_t uid, gid_t gid,
 
  254        res = lchown(path, uid, gid);
 
  261static int xmp_truncate(
const char *path, off_t size,
 
  267                res = ftruncate(fi->
fh, size);
 
  269                res = truncate(path, size);
 
  277static int xmp_utimens(
const char *path, 
const struct timespec ts[2],
 
  284        res = utimensat(0, path, ts, AT_SYMLINK_NOFOLLOW);
 
  292static int xmp_create(
const char *path, mode_t mode,
 
  297        res = open(path, fi->
flags, mode);
 
  309        res = open(path, fi->
flags);
 
  316        if (fi->
flags & O_DIRECT) {
 
  325static int xmp_read(
const char *path, 
char *buf, 
size_t size, off_t offset,
 
  332                fd = open(path, O_RDONLY);
 
  339        res = pread(fd, buf, size, offset);
 
  348static int xmp_write(
const char *path, 
const char *buf, 
size_t size,
 
  356                fd = open(path, O_WRONLY);
 
  363        res = pwrite(fd, buf, size, offset);
 
  372static int xmp_statfs(
const char *path, 
struct statvfs *stbuf)
 
  376        res = statvfs(path, stbuf);
 
  383static int xmp_release(
const char *path, 
struct fuse_file_info *fi)
 
  390static int xmp_fsync(
const char *path, 
int isdatasync,
 
  402#ifdef HAVE_POSIX_FALLOCATE 
  403static int xmp_fallocate(
const char *path, 
int mode,
 
  415                fd = open(path, O_WRONLY);
 
  422        res = -posix_fallocate(fd, offset, length);
 
  432static int xmp_setxattr(
const char *path, 
const char *name, 
const char *value,
 
  433                        size_t size, 
int flags)
 
  435        int res = lsetxattr(path, name, value, size, flags);
 
  441static int xmp_getxattr(
const char *path, 
const char *name, 
char *value,
 
  444        int res = lgetxattr(path, name, value, size);
 
  450static int xmp_listxattr(
const char *path, 
char *list, 
size_t size)
 
  452        int res = llistxattr(path, list, size);
 
  458static int xmp_removexattr(
const char *path, 
const char *name)
 
  460        int res = lremovexattr(path, name);
 
  467#ifdef HAVE_COPY_FILE_RANGE 
  468static ssize_t xmp_copy_file_range(
const char *path_in,
 
  470                                   off_t offset_in, 
const char *path_out,
 
  472                                   off_t offset_out, 
size_t len, 
int flags)
 
  478                fd_in = open(path_in, O_RDONLY);
 
  486                fd_out = open(path_out, O_WRONLY);
 
  495        res = copy_file_range(fd_in, &offset_in, fd_out, &offset_out, len,
 
  509static off_t xmp_lseek(
const char *path, off_t off, 
int whence, 
struct fuse_file_info *fi)
 
  515                fd = open(path, O_RDONLY);
 
  522        res = lseek(fd, off, whence);
 
  533        .getattr        = xmp_getattr,
 
  534        .access         = xmp_access,
 
  535        .readlink       = xmp_readlink,
 
  536        .readdir        = xmp_readdir,
 
  539        .symlink        = xmp_symlink,
 
  540        .unlink         = xmp_unlink,
 
  542        .rename         = xmp_rename,
 
  546        .truncate       = xmp_truncate,
 
  548        .utimens        = xmp_utimens,
 
  551        .create         = xmp_create,
 
  554        .statfs         = xmp_statfs,
 
  555        .release        = xmp_release,
 
  557#ifdef HAVE_POSIX_FALLOCATE 
  558        .fallocate      = xmp_fallocate,
 
  561        .setxattr       = xmp_setxattr,
 
  562        .getxattr       = xmp_getxattr,
 
  563        .listxattr      = xmp_listxattr,
 
  564        .removexattr    = xmp_removexattr,
 
  566#ifdef HAVE_COPY_FILE_RANGE 
  567        .copy_file_range = xmp_copy_file_range,
 
  572int main(
int argc, 
char *argv[])
 
  574        enum { MAX_ARGS = 10 };
 
  576        char *new_argv[MAX_ARGS];
 
  580        for (i=0, new_argc=0; (i<argc) && (new_argc<MAX_ARGS); i++) {
 
  581                if (!strcmp(argv[i], 
"--plus")) {
 
  582                        fill_dir_plus = FUSE_FILL_DIR_PLUS;
 
  584                        new_argv[new_argc++] = argv[i];
 
  587        return fuse_main(new_argc, new_argv, &xmp_oper, NULL);
 
int(* fuse_fill_dir_t)(void *buf, const char *name, const struct stat *stbuf, off_t off, enum fuse_fill_dir_flags flags)
int32_t parallel_direct_writes
uint32_t parallel_direct_writes
void *(* init)(struct fuse_conn_info *conn, struct fuse_config *cfg)