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;
 
   76static int xmp_getattr(
const char *path, 
struct stat *stbuf,
 
   82        res = lstat(path, stbuf);
 
   89static int xmp_access(
const char *path, 
int mask)
 
   93        res = access(path, mask);
 
  100static int xmp_readlink(
const char *path, 
char *buf, 
size_t size)
 
  104        res = readlink(path, buf, size - 1);
 
  113static int xmp_readdir(
const char *path, 
void *buf, 
fuse_fill_dir_t filler,
 
  128        while ((de = readdir(dp)) != NULL) {
 
  130                memset(&st, 0, 
sizeof(st));
 
  131                st.st_ino = de->d_ino;
 
  132                st.st_mode = de->d_type << 12;
 
  133                if (filler(buf, de->d_name, &st, 0, fill_dir_plus))
 
  141static int xmp_mknod(
const char *path, mode_t mode, dev_t rdev)
 
  145        res = mknod_wrapper(AT_FDCWD, path, NULL, mode, rdev);
 
  152static int xmp_mkdir(
const char *path, mode_t mode)
 
  156        res = mkdir(path, mode);
 
  163static int xmp_unlink(
const char *path)
 
  174static int xmp_rmdir(
const char *path)
 
  185static int xmp_symlink(
const char *from, 
const char *to)
 
  189        res = symlink(from, to);
 
  196static int xmp_rename(
const char *from, 
const char *to, 
unsigned int flags)
 
  203        res = rename(from, to);
 
  210static int xmp_link(
const char *from, 
const char *to)
 
  214        res = link(from, to);
 
  221static int xmp_chmod(
const char *path, mode_t mode,
 
  227        res = chmod(path, mode);
 
  234static int xmp_chown(
const char *path, uid_t uid, gid_t gid,
 
  240        res = lchown(path, uid, gid);
 
  247static int xmp_truncate(
const char *path, off_t size,
 
  253                res = ftruncate(fi->
fh, size);
 
  255                res = truncate(path, size);
 
  263static int xmp_utimens(
const char *path, 
const struct timespec ts[2],
 
  270        res = utimensat(0, path, ts, AT_SYMLINK_NOFOLLOW);
 
  278static int xmp_create(
const char *path, mode_t mode,
 
  283        res = open(path, fi->
flags, mode);
 
  295        res = open(path, fi->
flags);
 
  303static int xmp_read(
const char *path, 
char *buf, 
size_t size, off_t offset,
 
  310                fd = open(path, O_RDONLY);
 
  317        res = pread(fd, buf, size, offset);
 
  326static int xmp_write(
const char *path, 
const char *buf, 
size_t size,
 
  334                fd = open(path, O_WRONLY);
 
  341        res = pwrite(fd, buf, size, offset);
 
  350static int xmp_statfs(
const char *path, 
struct statvfs *stbuf)
 
  354        res = statvfs(path, stbuf);
 
  361static int xmp_release(
const char *path, 
struct fuse_file_info *fi)
 
  368static int xmp_fsync(
const char *path, 
int isdatasync,
 
  380#ifdef HAVE_POSIX_FALLOCATE 
  381static int xmp_fallocate(
const char *path, 
int mode,
 
  393                fd = open(path, O_WRONLY);
 
  400        res = -posix_fallocate(fd, offset, length);
 
  410static int xmp_setxattr(
const char *path, 
const char *name, 
const char *value,
 
  411                        size_t size, 
int flags)
 
  413        int res = lsetxattr(path, name, value, size, flags);
 
  419static int xmp_getxattr(
const char *path, 
const char *name, 
char *value,
 
  422        int res = lgetxattr(path, name, value, size);
 
  428static int xmp_listxattr(
const char *path, 
char *list, 
size_t size)
 
  430        int res = llistxattr(path, list, size);
 
  436static int xmp_removexattr(
const char *path, 
const char *name)
 
  438        int res = lremovexattr(path, name);
 
  445#ifdef HAVE_COPY_FILE_RANGE 
  446static ssize_t xmp_copy_file_range(
const char *path_in,
 
  448                                   off_t offset_in, 
const char *path_out,
 
  450                                   off_t offset_out, 
size_t len, 
int flags)
 
  456                fd_in = open(path_in, O_RDONLY);
 
  464                fd_out = open(path_out, O_WRONLY);
 
  473        res = copy_file_range(fd_in, &offset_in, fd_out, &offset_out, len,
 
  487static off_t xmp_lseek(
const char *path, off_t off, 
int whence, 
struct fuse_file_info *fi)
 
  493                fd = open(path, O_RDONLY);
 
  500        res = lseek(fd, off, whence);
 
  511        .getattr        = xmp_getattr,
 
  512        .access         = xmp_access,
 
  513        .readlink       = xmp_readlink,
 
  514        .readdir        = xmp_readdir,
 
  517        .symlink        = xmp_symlink,
 
  518        .unlink         = xmp_unlink,
 
  520        .rename         = xmp_rename,
 
  524        .truncate       = xmp_truncate,
 
  526        .utimens        = xmp_utimens,
 
  529        .create         = xmp_create,
 
  532        .statfs         = xmp_statfs,
 
  533        .release        = xmp_release,
 
  535#ifdef HAVE_POSIX_FALLOCATE 
  536        .fallocate      = xmp_fallocate,
 
  539        .setxattr       = xmp_setxattr,
 
  540        .getxattr       = xmp_getxattr,
 
  541        .listxattr      = xmp_listxattr,
 
  542        .removexattr    = xmp_removexattr,
 
  544#ifdef HAVE_COPY_FILE_RANGE 
  545        .copy_file_range = xmp_copy_file_range,
 
  550int main(
int argc, 
char *argv[])
 
  552        enum { MAX_ARGS = 10 };
 
  554        char *new_argv[MAX_ARGS];
 
  558        for (i=0, new_argc=0; (i<argc) && (new_argc<MAX_ARGS); i++) {
 
  559                if (!strcmp(argv[i], 
"--plus")) {
 
  562                        new_argv[new_argc++] = argv[i];
 
  565        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)
#define fuse_main(argc, argv, op, private_data)
void *(* init)(struct fuse_conn_info *conn, struct fuse_config *cfg)