26 #define FUSE_USE_VERSION 31    36 #define _XOPEN_SOURCE 700    48 #include <sys/socket.h>    53 #include <sys/xattr.h>    56 #include "passthrough_helpers.h"    78 static int xmp_getattr(
const char *path, 
struct stat *stbuf,
    84         res = lstat(path, stbuf);
    91 static int xmp_access(
const char *path, 
int mask)
   102 static int xmp_readlink(
const char *path, 
char *buf, 
size_t size)
   106         res = 
readlink(path, buf, size - 1);
   115 static int xmp_readdir(
const char *path, 
void *buf, 
fuse_fill_dir_t filler,
   130         while ((de = readdir(dp)) != NULL) {
   132                 memset(&st, 0, 
sizeof(st));
   133                 st.st_ino = de->d_ino;
   134                 st.st_mode = de->d_type << 12;
   143 static int xmp_mknod(
const char *path, mode_t mode, dev_t rdev)
   147         res = mknod_wrapper(AT_FDCWD, path, NULL, mode, rdev);
   154 static int xmp_mkdir(
const char *path, mode_t mode)
   158         res = mkdir(path, mode);
   165 static int xmp_unlink(
const char *path)
   176 static int xmp_rmdir(
const char *path)
   187 static int xmp_symlink(
const char *from, 
const char *to)
   191         res = symlink(from, to);
   198 static int xmp_rename(
const char *from, 
const char *to, 
unsigned int flags)
   205         res = rename(from, to);
   212 static int xmp_link(
const char *from, 
const char *to)
   216         res = link(from, to);
   223 static int xmp_chmod(
const char *path, mode_t mode,
   229         res = chmod(path, mode);
   236 static int xmp_chown(
const char *path, uid_t uid, gid_t gid,
   242         res = lchown(path, uid, gid);
   249 static int xmp_truncate(
const char *path, off_t size,
   255                 res = ftruncate(fi->
fh, size);
   257                 res = truncate(path, size);
   264 #ifdef HAVE_UTIMENSAT   265 static int xmp_utimens(
const char *path, 
const struct timespec ts[2],
   272         res = utimensat(0, path, ts, AT_SYMLINK_NOFOLLOW);
   280 static int xmp_create(
const char *path, mode_t mode,
   285         res = open(path, fi->
flags, mode);
   297         res = open(path, fi->
flags);
   305 static int xmp_read(
const char *path, 
char *buf, 
size_t size, off_t offset,
   312                 fd = open(path, O_RDONLY);
   319         res = pread(fd, buf, size, offset);
   328 static int xmp_write(
const char *path, 
const char *buf, 
size_t size,
   336                 fd = open(path, O_WRONLY);
   343         res = pwrite(fd, buf, size, offset);
   352 static int xmp_statfs(
const char *path, 
struct statvfs *stbuf)
   356         res = statvfs(path, stbuf);
   363 static int xmp_release(
const char *path, 
struct fuse_file_info *fi)
   370 static int xmp_fsync(
const char *path, 
int isdatasync,
   382 #ifdef HAVE_POSIX_FALLOCATE   383 static int xmp_fallocate(
const char *path, 
int mode,
   395                 fd = open(path, O_WRONLY);
   402         res = -posix_fallocate(fd, offset, length);
   412 static int xmp_setxattr(
const char *path, 
const char *name, 
const char *value,
   413                         size_t size, 
int flags)
   415         int res = lsetxattr(path, name, value, size, flags);
   421 static int xmp_getxattr(
const char *path, 
const char *name, 
char *value,
   424         int res = lgetxattr(path, name, value, size);
   430 static int xmp_listxattr(
const char *path, 
char *list, 
size_t size)
   432         int res = llistxattr(path, list, size);
   438 static int xmp_removexattr(
const char *path, 
const char *name)
   440         int res = lremovexattr(path, name);
   447 #ifdef HAVE_COPY_FILE_RANGE   448 static ssize_t xmp_copy_file_range(
const char *path_in,
   450                                    off_t offset_in, 
const char *path_out,
   452                                    off_t offset_out, 
size_t len, 
int flags)
   458                 fd_in = open(path_in, O_RDONLY);
   466                 fd_out = open(path_out, O_WRONLY);
   475         res = copy_file_range(fd_in, &offset_in, fd_out, &offset_out, len,
   489 static off_t xmp_lseek(
const char *path, off_t off, 
int whence, 
struct fuse_file_info *fi)
   495                 fd = open(path, O_RDONLY);
   502         res = lseek(fd, off, whence);
   513         .getattr        = xmp_getattr,
   514         .access         = xmp_access,
   515         .readlink       = xmp_readlink,
   516         .readdir        = xmp_readdir,
   519         .symlink        = xmp_symlink,
   520         .unlink         = xmp_unlink,
   522         .rename         = xmp_rename,
   526         .truncate       = xmp_truncate,
   527 #ifdef HAVE_UTIMENSAT   528         .utimens        = xmp_utimens,
   531         .create         = xmp_create,
   534         .statfs         = xmp_statfs,
   535         .release        = xmp_release,
   537 #ifdef HAVE_POSIX_FALLOCATE   538         .fallocate      = xmp_fallocate,
   541         .setxattr       = xmp_setxattr,
   542         .getxattr       = xmp_getxattr,
   543         .listxattr      = xmp_listxattr,
   544         .removexattr    = xmp_removexattr,
   546 #ifdef HAVE_COPY_FILE_RANGE   547         .copy_file_range = xmp_copy_file_range,
   552 int main(
int argc, 
char *argv[])
   555         return fuse_main(argc, argv, &xmp_oper, NULL);
 
void *(* init)(struct fuse_conn_info *conn, struct fuse_config *cfg)
#define fuse_main(argc, argv, op, private_data)
int(* readlink)(const char *, char *, size_t)
int(* fuse_fill_dir_t)(void *buf, const char *name, const struct stat *stbuf, off_t off, enum fuse_fill_dir_flags flags)
int(* access)(const char *, int)