26#define FUSE_USE_VERSION 31 
   32#ifdef HAVE_LIBULOCKMGR 
   78static int xmp_getattr(
const char *path, 
struct stat *stbuf,
 
   86                res = fstat(fi->
fh, stbuf);
 
   88                res = lstat(path, stbuf);
 
   95static int xmp_access(
const char *path, 
int mask)
 
   99        res = access(path, mask);
 
  106static int xmp_readlink(
const char *path, 
char *buf, 
size_t size)
 
  110        res = readlink(path, buf, size - 1);
 
  120        struct dirent *entry;
 
  124static int xmp_opendir(
const char *path, 
struct fuse_file_info *fi)
 
  127        struct xmp_dirp *d = malloc(
sizeof(
struct xmp_dirp));
 
  131        d->dp = opendir(path);
 
  140        fi->
fh = (
unsigned long) d;
 
  146        return (
struct xmp_dirp *) (uintptr_t) fi->
fh;
 
  149static int xmp_readdir(
const char *path, 
void *buf, 
fuse_fill_dir_t filler,
 
  153        struct xmp_dirp *d = get_dirp(fi);
 
  156        if (offset != d->offset) {
 
  158                seekdir(d->dp, offset);
 
  162                seekdir(d->dp, offset-1);
 
  173                        d->entry = readdir(d->dp);
 
  178                if (flags & FUSE_READDIR_PLUS) {
 
  181                        res = fstatat(dirfd(d->dp), d->entry->d_name, &st,
 
  182                                      AT_SYMLINK_NOFOLLOW);
 
  184                                fill_flags |= FUSE_FILL_DIR_PLUS;
 
  187                if (!(fill_flags & FUSE_FILL_DIR_PLUS)) {
 
  188                        memset(&st, 0, 
sizeof(st));
 
  189                        st.st_ino = d->entry->d_ino;
 
  190                        st.st_mode = d->entry->d_type << 12;
 
  192                nextoff = telldir(d->dp);
 
  200                if (filler(buf, d->entry->d_name, &st, nextoff, fill_flags))
 
  210static int xmp_releasedir(
const char *path, 
struct fuse_file_info *fi)
 
  212        struct xmp_dirp *d = get_dirp(fi);
 
  219static int xmp_mknod(
const char *path, mode_t mode, dev_t rdev)
 
  224                res = mkfifo(path, mode);
 
  226                res = mknod(path, mode, rdev);
 
  233static int xmp_mkdir(
const char *path, mode_t mode)
 
  237        res = mkdir(path, mode);
 
  244static int xmp_unlink(
const char *path)
 
  255static int xmp_rmdir(
const char *path)
 
  266static int xmp_symlink(
const char *from, 
const char *to)
 
  270        res = symlink(from, to);
 
  277static int xmp_rename(
const char *from, 
const char *to, 
unsigned int flags)
 
  285        res = rename(from, to);
 
  292static int xmp_link(
const char *from, 
const char *to)
 
  296        res = link(from, to);
 
  303static int xmp_chmod(
const char *path, mode_t mode,
 
  309                res = fchmod(fi->
fh, mode);
 
  311                res = chmod(path, mode);
 
  318static int xmp_chown(
const char *path, uid_t uid, gid_t gid,
 
  324                res = fchown(fi->
fh, uid, gid);
 
  326                res = lchown(path, uid, gid);
 
  333static int xmp_truncate(
const char *path, off_t size,
 
  339                res = ftruncate(fi->
fh, size);
 
  341                res = truncate(path, size);
 
  350static int xmp_utimens(
const char *path, 
const struct timespec ts[2],
 
  357                res = futimens(fi->
fh, ts);
 
  359                res = utimensat(0, path, ts, AT_SYMLINK_NOFOLLOW);
 
  367static int xmp_create(
const char *path, mode_t mode, 
struct fuse_file_info *fi)
 
  371        fd = open(path, fi->
flags, mode);
 
  383        fd = open(path, fi->
flags);
 
  390        if (fi->
flags & O_DIRECT) {
 
  399static int xmp_read(
const char *path, 
char *buf, 
size_t size, off_t offset,
 
  405        res = pread(fi->
fh, buf, size, offset);
 
  412static int xmp_read_buf(
const char *path, 
struct fuse_bufvec **bufp,
 
  423        *src = FUSE_BUFVEC_INIT(size);
 
  434static int xmp_write(
const char *path, 
const char *
buf, 
size_t size,
 
  440        res = pwrite(fi->
fh, 
buf, size, offset);
 
  447static int xmp_write_buf(
const char *path, 
struct fuse_bufvec *
buf,
 
  461static int xmp_statfs(
const char *path, 
struct statvfs *stbuf)
 
  465        res = statvfs(path, stbuf);
 
  482        res = close(dup(fi->
fh));
 
  489static int xmp_release(
const char *path, 
struct fuse_file_info *fi)
 
  497static int xmp_fsync(
const char *path, 
int isdatasync,
 
  503#ifndef HAVE_FDATASYNC 
  507                res = fdatasync(fi->
fh);
 
  517#ifdef HAVE_POSIX_FALLOCATE 
  518static int xmp_fallocate(
const char *path, 
int mode,
 
  526        return -posix_fallocate(fi->
fh, offset, length);
 
  532static int xmp_setxattr(
const char *path, 
const char *name, 
const char *value,
 
  533                        size_t size, 
int flags)
 
  535        int res = lsetxattr(path, name, value, size, flags);
 
  541static int xmp_getxattr(
const char *path, 
const char *name, 
char *value,
 
  544        int res = lgetxattr(path, name, value, size);
 
  550static int xmp_listxattr(
const char *path, 
char *list, 
size_t size)
 
  552        int res = llistxattr(path, list, size);
 
  558static int xmp_removexattr(
const char *path, 
const char *name)
 
  560        int res = lremovexattr(path, name);
 
  567#ifdef HAVE_LIBULOCKMGR 
  568static int xmp_lock(
const char *path, 
struct fuse_file_info *fi, 
int cmd,
 
  578static int xmp_flock(
const char *path, 
struct fuse_file_info *fi, 
int op)
 
  583        res = flock(fi->
fh, op);
 
  590#ifdef HAVE_COPY_FILE_RANGE 
  591static ssize_t xmp_copy_file_range(
const char *path_in,
 
  593                                   off_t off_in, 
const char *path_out,
 
  595                                   off_t off_out, 
size_t len, 
int flags)
 
  601        res = copy_file_range(fi_in->
fh, &off_in, fi_out->
fh, &off_out, len,
 
  610static off_t xmp_lseek(
const char *path, off_t 
off, 
int whence, 
struct fuse_file_info *fi)
 
  615        res = lseek(fi->
fh, 
off, whence);
 
  624        .getattr        = xmp_getattr,
 
  625        .access         = xmp_access,
 
  626        .readlink       = xmp_readlink,
 
  627        .opendir        = xmp_opendir,
 
  628        .readdir        = xmp_readdir,
 
  629        .releasedir     = xmp_releasedir,
 
  632        .symlink        = xmp_symlink,
 
  633        .unlink         = xmp_unlink,
 
  635        .rename         = xmp_rename,
 
  639        .truncate       = xmp_truncate,
 
  641        .utimens        = xmp_utimens,
 
  643        .create         = xmp_create,
 
  646        .read_buf       = xmp_read_buf,
 
  648        .write_buf      = xmp_write_buf,
 
  649        .statfs         = xmp_statfs,
 
  651        .release        = xmp_release,
 
  653#ifdef HAVE_POSIX_FALLOCATE 
  654        .fallocate      = xmp_fallocate,
 
  657        .setxattr       = xmp_setxattr,
 
  658        .getxattr       = xmp_getxattr,
 
  659        .listxattr      = xmp_listxattr,
 
  660        .removexattr    = xmp_removexattr,
 
  662#ifdef HAVE_LIBULOCKMGR 
  666#ifdef HAVE_COPY_FILE_RANGE 
  667        .copy_file_range = xmp_copy_file_range,
 
  672int main(
int argc, 
char *argv[])
 
  675        return fuse_main(argc, 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)
size_t fuse_buf_size(const struct fuse_bufvec *bufv)
ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src, enum fuse_buf_copy_flags flags)
@ FUSE_BUF_SPLICE_NONBLOCK
enum fuse_buf_flags flags
int32_t parallel_direct_writes
uint32_t parallel_direct_writes
void *(* init)(struct fuse_conn_info *conn, struct fuse_config *cfg)