|
@ -16,6 +16,7 @@ |
|
|
#include "fuse_kernel.h" |
|
|
#include "fuse_kernel.h" |
|
|
#include "fuse_opt.h" |
|
|
#include "fuse_opt.h" |
|
|
#include "fuse_misc.h" |
|
|
#include "fuse_misc.h" |
|
|
|
|
|
#include "fuse_pollhandle.h" |
|
|
|
|
|
|
|
|
#include <stdio.h> |
|
|
#include <stdio.h> |
|
|
#include <stdlib.h> |
|
|
#include <stdlib.h> |
|
@ -42,13 +43,6 @@ |
|
|
const typeof( ((type*)0)->member ) *__mptr = (ptr); \ |
|
|
const typeof( ((type*)0)->member ) *__mptr = (ptr); \ |
|
|
(type *)( (char*)__mptr - offsetof(type,member) );}) |
|
|
(type *)( (char*)__mptr - offsetof(type,member) );}) |
|
|
|
|
|
|
|
|
struct fuse_pollhandle_t |
|
|
|
|
|
{ |
|
|
|
|
|
uint64_t kh; |
|
|
|
|
|
struct fuse_chan *ch; |
|
|
|
|
|
struct fuse_ll *f; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
static size_t pagesize; |
|
|
static size_t pagesize; |
|
|
static lfmp_t g_FMP_fuse_req; |
|
|
static lfmp_t g_FMP_fuse_req; |
|
|
|
|
|
|
|
@ -92,23 +86,6 @@ convert_stat(const struct stat *stbuf_, |
|
|
attr_->ctimensec = ST_CTIM_NSEC(stbuf_); |
|
|
attr_->ctimensec = ST_CTIM_NSEC(stbuf_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
|
|
|
void |
|
|
|
|
|
convert_attr(const struct fuse_setattr_in *attr_, |
|
|
|
|
|
struct stat *stbuf_) |
|
|
|
|
|
{ |
|
|
|
|
|
stbuf_->st_mode = attr_->mode; |
|
|
|
|
|
stbuf_->st_uid = attr_->uid; |
|
|
|
|
|
stbuf_->st_gid = attr_->gid; |
|
|
|
|
|
stbuf_->st_size = attr_->size; |
|
|
|
|
|
stbuf_->st_atime = attr_->atime; |
|
|
|
|
|
stbuf_->st_mtime = attr_->mtime; |
|
|
|
|
|
stbuf_->st_ctime = attr_->ctime; |
|
|
|
|
|
ST_ATIM_NSEC_SET(stbuf_,attr_->atimensec); |
|
|
|
|
|
ST_MTIM_NSEC_SET(stbuf_,attr_->mtimensec); |
|
|
|
|
|
ST_CTIM_NSEC_SET(stbuf_,attr_->ctimensec); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
size_t |
|
|
size_t |
|
|
iov_length(const struct iovec *iov, |
|
|
iov_length(const struct iovec *iov, |
|
@ -1009,478 +986,249 @@ fuse_reply_poll(fuse_req_t req, |
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_lookup(fuse_req_t req, |
|
|
do_lookup(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
char *name = (char*)inarg; |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.lookup(req,nodeid,name); |
|
|
|
|
|
|
|
|
req->f->op.lookup(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_forget(fuse_req_t req, |
|
|
do_forget(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
struct fuse_forget_in *arg = (struct fuse_forget_in*)inarg; |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.forget(req,nodeid,arg->nlookup); |
|
|
|
|
|
|
|
|
req->f->op.forget(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_batch_forget(fuse_req_t req, |
|
|
do_batch_forget(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
struct fuse_batch_forget_in *arg = (void *) inarg; |
|
|
|
|
|
struct fuse_forget_one *param = (void *) PARAM(arg); |
|
|
|
|
|
|
|
|
|
|
|
(void)nodeid; |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.forget_multi(req, |
|
|
|
|
|
arg->count, |
|
|
|
|
|
(struct fuse_forget_data*)param); |
|
|
|
|
|
|
|
|
req->f->op.forget_multi(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_getattr(fuse_req_t req, |
|
|
do_getattr(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
fuse_file_info_t *fip = NULL; |
|
|
|
|
|
fuse_file_info_t fi = {0}; |
|
|
|
|
|
|
|
|
|
|
|
if(req->f->conn.proto_minor >= 9) |
|
|
|
|
|
{ |
|
|
|
|
|
struct fuse_getattr_in *arg = (struct fuse_getattr_in*)inarg; |
|
|
|
|
|
|
|
|
|
|
|
if(arg->getattr_flags & FUSE_GETATTR_FH) |
|
|
|
|
|
{ |
|
|
|
|
|
fi.fh = arg->fh; |
|
|
|
|
|
fip = &fi; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.getattr(req, nodeid, fip); |
|
|
|
|
|
|
|
|
req->f->op.getattr(req, hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_setattr(fuse_req_t req_, |
|
|
do_setattr(fuse_req_t req_, |
|
|
uint64_t nodeid_, |
|
|
|
|
|
const void *inarg_) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
struct stat stbuf = {0}; |
|
|
|
|
|
fuse_file_info_t *fi; |
|
|
|
|
|
fuse_file_info_t fi_store; |
|
|
|
|
|
struct fuse_setattr_in *arg; |
|
|
|
|
|
|
|
|
|
|
|
fi = NULL; |
|
|
|
|
|
arg = (struct fuse_setattr_in*)inarg_; |
|
|
|
|
|
|
|
|
|
|
|
convert_attr(arg,&stbuf); |
|
|
|
|
|
|
|
|
|
|
|
if(arg->valid & FATTR_FH) |
|
|
|
|
|
{ |
|
|
|
|
|
arg->valid &= ~FATTR_FH; |
|
|
|
|
|
memset(&fi_store,0,sizeof(fi_store)); |
|
|
|
|
|
fi = &fi_store; |
|
|
|
|
|
fi->fh = arg->fh; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
arg->valid &= |
|
|
|
|
|
(FATTR_MODE | |
|
|
|
|
|
FATTR_UID | |
|
|
|
|
|
FATTR_GID | |
|
|
|
|
|
FATTR_SIZE | |
|
|
|
|
|
FATTR_ATIME | |
|
|
|
|
|
FATTR_MTIME | |
|
|
|
|
|
FATTR_CTIME | |
|
|
|
|
|
FATTR_ATIME_NOW | |
|
|
|
|
|
FATTR_MTIME_NOW); |
|
|
|
|
|
|
|
|
|
|
|
req_->f->op.setattr(req_,nodeid_,&stbuf,arg->valid,fi); |
|
|
|
|
|
|
|
|
req_->f->op.setattr(req_,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_access(fuse_req_t req, |
|
|
do_access(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
struct fuse_access_in *arg = (struct fuse_access_in *)inarg; |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.access(req, nodeid, arg->mask); |
|
|
|
|
|
|
|
|
req->f->op.access(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_readlink(fuse_req_t req, |
|
|
do_readlink(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
(void)inarg; |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.readlink(req, nodeid); |
|
|
|
|
|
|
|
|
req->f->op.readlink(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_mknod(fuse_req_t req, |
|
|
do_mknod(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
struct fuse_mknod_in *arg = (struct fuse_mknod_in *) inarg; |
|
|
|
|
|
char *name = PARAM(arg); |
|
|
|
|
|
|
|
|
|
|
|
if (req->f->conn.proto_minor >= 12) |
|
|
|
|
|
req->ctx.umask = arg->umask; |
|
|
|
|
|
else |
|
|
|
|
|
name = (char*)inarg + FUSE_COMPAT_MKNOD_IN_SIZE; |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.mknod(req, nodeid, name, arg->mode, arg->rdev); |
|
|
|
|
|
|
|
|
req->f->op.mknod(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_mkdir(fuse_req_t req, |
|
|
do_mkdir(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
struct fuse_mkdir_in *arg = (struct fuse_mkdir_in *) inarg; |
|
|
|
|
|
|
|
|
|
|
|
if(req->f->conn.proto_minor >= 12) |
|
|
|
|
|
req->ctx.umask = arg->umask; |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.mkdir(req, nodeid, PARAM(arg), arg->mode); |
|
|
|
|
|
|
|
|
req->f->op.mkdir(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_unlink(fuse_req_t req, |
|
|
do_unlink(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
char *name = (char*)inarg; |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.unlink(req,nodeid,name); |
|
|
|
|
|
|
|
|
req->f->op.unlink(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_rmdir(fuse_req_t req, |
|
|
do_rmdir(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
char *name = (char*)inarg; |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.rmdir(req, nodeid, name); |
|
|
|
|
|
|
|
|
req->f->op.rmdir(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_symlink(fuse_req_t req, |
|
|
do_symlink(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
char *name = (char*)inarg; |
|
|
|
|
|
char *linkname = (name + strlen(name) + 1); |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.symlink(req, linkname, nodeid, name); |
|
|
|
|
|
|
|
|
req->f->op.symlink(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_rename(fuse_req_t req, |
|
|
do_rename(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
struct fuse_rename_in *arg = (struct fuse_rename_in*)inarg; |
|
|
|
|
|
char *oldname = PARAM(arg); |
|
|
|
|
|
char *newname = oldname + strlen(oldname) + 1; |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.rename(req, nodeid, oldname, arg->newdir, newname); |
|
|
|
|
|
|
|
|
req->f->op.rename(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_link(fuse_req_t req, |
|
|
do_link(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
struct fuse_link_in *arg = (struct fuse_link_in*)inarg; |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.link(req,arg->oldnodeid,nodeid,PARAM(arg)); |
|
|
|
|
|
|
|
|
req->f->op.link(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_create(fuse_req_t req, |
|
|
do_create(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
struct fuse_create_in *arg = (struct fuse_create_in*)inarg; |
|
|
|
|
|
fuse_file_info_t fi = {0}; |
|
|
|
|
|
char *name = PARAM(arg); |
|
|
|
|
|
|
|
|
|
|
|
fi.flags = arg->flags; |
|
|
|
|
|
|
|
|
|
|
|
if (req->f->conn.proto_minor >= 12) |
|
|
|
|
|
req->ctx.umask = arg->umask; |
|
|
|
|
|
else |
|
|
|
|
|
name = (char*)inarg + sizeof(struct fuse_open_in); |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.create(req, nodeid, name, arg->mode, &fi); |
|
|
|
|
|
|
|
|
req->f->op.create(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_open(fuse_req_t req, |
|
|
do_open(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
fuse_file_info_t fi = {0}; |
|
|
|
|
|
struct fuse_open_in *arg = (struct fuse_open_in*)inarg; |
|
|
|
|
|
|
|
|
|
|
|
fi.flags = arg->flags; |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.open(req, nodeid, &fi); |
|
|
|
|
|
|
|
|
req->f->op.open(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_read(fuse_req_t req, |
|
|
do_read(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
{ |
|
|
|
|
|
fuse_file_info_t fi = {0}; |
|
|
|
|
|
struct fuse_read_in *arg = (struct fuse_read_in*)inarg; |
|
|
|
|
|
|
|
|
|
|
|
fi.fh = arg->fh; |
|
|
|
|
|
if (req->f->conn.proto_minor >= 9) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
fi.lock_owner = arg->lock_owner; |
|
|
|
|
|
fi.flags = arg->flags; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.read(req, nodeid, arg->size, arg->offset, &fi); |
|
|
|
|
|
|
|
|
req->f->op.read(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_write(fuse_req_t req, |
|
|
do_write(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
{ |
|
|
|
|
|
char *param; |
|
|
|
|
|
fuse_file_info_t fi = {0}; |
|
|
|
|
|
struct fuse_write_in *arg = (struct fuse_write_in*)inarg; |
|
|
|
|
|
|
|
|
|
|
|
fi.fh = arg->fh; |
|
|
|
|
|
fi.writepage = arg->write_flags & 1; |
|
|
|
|
|
|
|
|
|
|
|
if(req->f->conn.proto_minor < 9) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
param = ((char*)arg) + FUSE_COMPAT_WRITE_IN_SIZE; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
fi.lock_owner = arg->lock_owner; |
|
|
|
|
|
fi.flags = arg->flags; |
|
|
|
|
|
param = PARAM(arg); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.write(req,nodeid,param,arg->size,arg->offset,&fi); |
|
|
|
|
|
|
|
|
req->f->op.write(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_flush(fuse_req_t req, |
|
|
do_flush(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
fuse_file_info_t fi = {0}; |
|
|
|
|
|
struct fuse_flush_in *arg = (struct fuse_flush_in *) inarg; |
|
|
|
|
|
|
|
|
|
|
|
fi.fh = arg->fh; |
|
|
|
|
|
fi.flush = 1; |
|
|
|
|
|
if(req->f->conn.proto_minor >= 7) |
|
|
|
|
|
fi.lock_owner = arg->lock_owner; |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.flush(req,nodeid,&fi); |
|
|
|
|
|
|
|
|
req->f->op.flush(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_release(fuse_req_t req, |
|
|
do_release(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
fuse_file_info_t fi = {0}; |
|
|
|
|
|
struct fuse_release_in *arg = (struct fuse_release_in*)inarg; |
|
|
|
|
|
|
|
|
|
|
|
fi.flags = arg->flags; |
|
|
|
|
|
fi.fh = arg->fh; |
|
|
|
|
|
if(req->f->conn.proto_minor >= 8) |
|
|
|
|
|
{ |
|
|
|
|
|
fi.flush = (arg->release_flags & FUSE_RELEASE_FLUSH) ? 1 : 0; |
|
|
|
|
|
fi.lock_owner = arg->lock_owner; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(arg->release_flags & FUSE_RELEASE_FLOCK_UNLOCK) |
|
|
|
|
|
{ |
|
|
|
|
|
fi.flock_release = 1; |
|
|
|
|
|
fi.lock_owner = arg->lock_owner; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.release(req,nodeid,&fi); |
|
|
|
|
|
|
|
|
req->f->op.release(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_fsync(fuse_req_t req, |
|
|
do_fsync(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
fuse_file_info_t fi = {0}; |
|
|
|
|
|
struct fuse_fsync_in *arg = (struct fuse_fsync_in*)inarg; |
|
|
|
|
|
|
|
|
|
|
|
fi.fh = arg->fh; |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.fsync(req,nodeid,arg->fsync_flags & 1, &fi); |
|
|
|
|
|
|
|
|
req->f->op.fsync(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_opendir(fuse_req_t req, |
|
|
do_opendir(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
fuse_file_info_t fi = {0}; |
|
|
|
|
|
struct fuse_open_in *arg = (struct fuse_open_in*)inarg; |
|
|
|
|
|
|
|
|
|
|
|
fi.flags = arg->flags; |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.opendir(req,nodeid,&fi); |
|
|
|
|
|
|
|
|
req->f->op.opendir(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_readdir(fuse_req_t req, |
|
|
do_readdir(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
fuse_file_info_t fi = {0}; |
|
|
|
|
|
struct fuse_read_in *arg = (struct fuse_read_in*)inarg; |
|
|
|
|
|
|
|
|
|
|
|
fi.fh = arg->fh; |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.readdir(req,nodeid,arg->size,arg->offset,&fi); |
|
|
|
|
|
|
|
|
req->f->op.readdir(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_readdir_plus(fuse_req_t req_, |
|
|
do_readdir_plus(fuse_req_t req_, |
|
|
uint64_t nodeid_, |
|
|
|
|
|
const void *inarg_) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
const struct fuse_read_in *arg; |
|
|
|
|
|
fuse_file_info_t ffi = {0}; |
|
|
|
|
|
|
|
|
|
|
|
arg = (struct fuse_read_in*)inarg_; |
|
|
|
|
|
ffi.fh = arg->fh; |
|
|
|
|
|
|
|
|
|
|
|
req_->f->op.readdir_plus(req_,nodeid_,arg->size,arg->offset,&ffi); |
|
|
|
|
|
|
|
|
req_->f->op.readdir_plus(req_,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_releasedir(fuse_req_t req, |
|
|
do_releasedir(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
fuse_file_info_t fi = {0}; |
|
|
|
|
|
struct fuse_release_in *arg = (struct fuse_release_in*)inarg; |
|
|
|
|
|
|
|
|
|
|
|
fi.flags = arg->flags; |
|
|
|
|
|
fi.fh = arg->fh; |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.releasedir(req,nodeid,&fi); |
|
|
|
|
|
|
|
|
req->f->op.releasedir(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_fsyncdir(fuse_req_t req, |
|
|
do_fsyncdir(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
fuse_file_info_t fi = {0}; |
|
|
|
|
|
struct fuse_fsync_in *arg = (struct fuse_fsync_in*)inarg; |
|
|
|
|
|
|
|
|
|
|
|
fi.fh = arg->fh; |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.fsyncdir(req,nodeid,arg->fsync_flags & 1,&fi); |
|
|
|
|
|
|
|
|
req->f->op.fsyncdir(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_statfs(fuse_req_t req, |
|
|
do_statfs(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
(void)nodeid; |
|
|
|
|
|
(void)inarg; |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.statfs(req, nodeid); |
|
|
|
|
|
|
|
|
req->f->op.statfs(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_setxattr(fuse_req_t req, |
|
|
do_setxattr(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
struct fuse_setxattr_in *arg = (struct fuse_setxattr_in*)inarg; |
|
|
|
|
|
char *name = PARAM(arg); |
|
|
|
|
|
char *value = name + strlen(name) + 1; |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.setxattr(req, nodeid, name, value, arg->size, arg->flags); |
|
|
|
|
|
|
|
|
req->f->op.setxattr(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_getxattr(fuse_req_t req, |
|
|
do_getxattr(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
struct fuse_getxattr_in *arg = (struct fuse_getxattr_in*)inarg; |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.getxattr(req, nodeid, PARAM(arg), arg->size); |
|
|
|
|
|
|
|
|
req->f->op.getxattr(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_listxattr(fuse_req_t req, |
|
|
do_listxattr(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
struct fuse_getxattr_in *arg = (struct fuse_getxattr_in*)inarg; |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.listxattr(req, nodeid, arg->size); |
|
|
|
|
|
|
|
|
req->f->op.listxattr(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_removexattr(fuse_req_t req, |
|
|
do_removexattr(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
char *name = (char *) inarg; |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.removexattr(req, nodeid, name); |
|
|
|
|
|
|
|
|
req->f->op.removexattr(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
@ -1502,19 +1250,9 @@ convert_fuse_file_lock(struct fuse_file_lock *fl, |
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_getlk(fuse_req_t req, |
|
|
do_getlk(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
fuse_file_info_t fi = {0}; |
|
|
|
|
|
struct flock flock; |
|
|
|
|
|
struct fuse_lk_in *arg = (struct fuse_lk_in*)inarg; |
|
|
|
|
|
|
|
|
|
|
|
fi.fh = arg->fh; |
|
|
|
|
|
fi.lock_owner = arg->owner; |
|
|
|
|
|
|
|
|
|
|
|
convert_fuse_file_lock(&arg->lk, &flock); |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.getlk(req, nodeid, &fi, &flock); |
|
|
|
|
|
|
|
|
req->f->op.getlk(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
@ -1564,26 +1302,23 @@ do_setlk_common(fuse_req_t req, |
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_setlk(fuse_req_t req, |
|
|
do_setlk(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
do_setlk_common(req, nodeid, inarg, 0); |
|
|
|
|
|
|
|
|
do_setlk_common(req, hdr_->nodeid, &hdr_[1], 0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_setlkw(fuse_req_t req, |
|
|
do_setlkw(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
do_setlk_common(req, nodeid, inarg, 1); |
|
|
|
|
|
|
|
|
do_setlk_common(req, hdr_->nodeid, &hdr_[1], 1); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_interrupt(fuse_req_t req, |
|
|
do_interrupt(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
destroy_req(req); |
|
|
destroy_req(req); |
|
|
} |
|
|
} |
|
@ -1591,43 +1326,17 @@ do_interrupt(fuse_req_t req, |
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_bmap(fuse_req_t req, |
|
|
do_bmap(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
struct fuse_bmap_in *arg = (struct fuse_bmap_in*)inarg; |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.bmap(req,nodeid,arg->blocksize,arg->block); |
|
|
|
|
|
|
|
|
req->f->op.bmap(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_ioctl(fuse_req_t req, |
|
|
do_ioctl(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
{ |
|
|
|
|
|
fuse_file_info_t fi = {0}; |
|
|
|
|
|
struct fuse_ioctl_in *arg = (struct fuse_ioctl_in *) inarg; |
|
|
|
|
|
unsigned int flags = arg->flags; |
|
|
|
|
|
void *in_buf = arg->in_size ? PARAM(arg) : NULL; |
|
|
|
|
|
|
|
|
|
|
|
if((flags & FUSE_IOCTL_DIR) && !(req->f->conn.want & FUSE_CAP_IOCTL_DIR)) |
|
|
|
|
|
{ |
|
|
|
|
|
fuse_reply_err(req,ENOTTY); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fi.fh = arg->fh; |
|
|
|
|
|
|
|
|
|
|
|
if((sizeof(void *) == 4) && |
|
|
|
|
|
(req->f->conn.proto_minor >= 16) && |
|
|
|
|
|
!(flags & FUSE_IOCTL_32BIT)) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
req->ioctl_64bit = 1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.ioctl(req, nodeid, (unsigned long)arg->cmd, |
|
|
|
|
|
(void *)(uintptr_t)arg->arg, &fi, flags, |
|
|
|
|
|
in_buf, arg->in_size, arg->out_size); |
|
|
|
|
|
|
|
|
req->f->op.ioctl(req, hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void |
|
|
void |
|
@ -1639,57 +1348,29 @@ fuse_pollhandle_destroy(fuse_pollhandle_t *ph) |
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_poll(fuse_req_t req, |
|
|
do_poll(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
fuse_file_info_t fi = {0}; |
|
|
|
|
|
fuse_pollhandle_t *ph = NULL; |
|
|
|
|
|
struct fuse_poll_in *arg = (struct fuse_poll_in *) inarg; |
|
|
|
|
|
|
|
|
|
|
|
fi.fh = arg->fh; |
|
|
|
|
|
|
|
|
|
|
|
if(arg->flags & FUSE_POLL_SCHEDULE_NOTIFY) |
|
|
|
|
|
{ |
|
|
|
|
|
ph = malloc(sizeof(fuse_pollhandle_t)); |
|
|
|
|
|
if (ph == NULL) { |
|
|
|
|
|
fuse_reply_err(req, ENOMEM); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
ph->kh = arg->kh; |
|
|
|
|
|
ph->ch = req->ch; |
|
|
|
|
|
ph->f = req->f; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.poll(req,nodeid,&fi,ph); |
|
|
|
|
|
|
|
|
req->f->op.poll(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_fallocate(fuse_req_t req, |
|
|
do_fallocate(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
fuse_file_info_t fi = {0}; |
|
|
|
|
|
struct fuse_fallocate_in *arg = (struct fuse_fallocate_in *) inarg; |
|
|
|
|
|
|
|
|
|
|
|
fi.fh = arg->fh; |
|
|
|
|
|
|
|
|
|
|
|
req->f->op.fallocate(req, nodeid, arg->mode, arg->offset, arg->length, &fi); |
|
|
|
|
|
|
|
|
req->f->op.fallocate(req,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_init(fuse_req_t req, |
|
|
do_init(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
struct fuse_init_out outarg = {0}; |
|
|
struct fuse_init_out outarg = {0}; |
|
|
struct fuse_init_in *arg = (struct fuse_init_in *) inarg; |
|
|
|
|
|
|
|
|
struct fuse_init_in *arg = (struct fuse_init_in *) &hdr_[1]; |
|
|
struct fuse_ll *f = req->f; |
|
|
struct fuse_ll *f = req->f; |
|
|
size_t bufsize = fuse_chan_bufsize(req->ch); |
|
|
size_t bufsize = fuse_chan_bufsize(req->ch); |
|
|
|
|
|
|
|
|
(void)nodeid; |
|
|
|
|
|
|
|
|
|
|
|
if(f->debug) |
|
|
if(f->debug) |
|
|
debug_fuse_init_in(arg); |
|
|
debug_fuse_init_in(arg); |
|
|
|
|
|
|
|
@ -1873,14 +1554,10 @@ do_init(fuse_req_t req, |
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_destroy(fuse_req_t req, |
|
|
do_destroy(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
struct fuse_ll *f = req->f; |
|
|
struct fuse_ll *f = req->f; |
|
|
|
|
|
|
|
|
(void) nodeid; |
|
|
|
|
|
(void) inarg; |
|
|
|
|
|
|
|
|
|
|
|
f->got_destroy = 1; |
|
|
f->got_destroy = 1; |
|
|
f->op.destroy(f->userdata); |
|
|
f->op.destroy(f->userdata); |
|
|
|
|
|
|
|
@ -1920,8 +1597,7 @@ list_init_nreq(struct fuse_notify_req *nreq) |
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_notify_reply(fuse_req_t req, |
|
|
do_notify_reply(fuse_req_t req, |
|
|
uint64_t nodeid, |
|
|
|
|
|
const void *inarg) |
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
struct fuse_ll *f = req->f; |
|
|
struct fuse_ll *f = req->f; |
|
|
struct fuse_notify_req *nreq; |
|
|
struct fuse_notify_req *nreq; |
|
@ -1940,32 +1616,15 @@ do_notify_reply(fuse_req_t req, |
|
|
pthread_mutex_unlock(&f->lock); |
|
|
pthread_mutex_unlock(&f->lock); |
|
|
|
|
|
|
|
|
if(nreq != head) |
|
|
if(nreq != head) |
|
|
nreq->reply(nreq, req, nodeid, inarg); |
|
|
|
|
|
|
|
|
nreq->reply(nreq, req, hdr_->nodeid, &hdr_[1]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
|
void |
|
|
void |
|
|
do_copy_file_range(fuse_req_t req_, |
|
|
do_copy_file_range(fuse_req_t req_, |
|
|
uint64_t nodeid_in_, |
|
|
|
|
|
const void *arg_) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct fuse_in_header *hdr_) |
|
|
{ |
|
|
{ |
|
|
fuse_file_info_t ffi_in = {0}; |
|
|
|
|
|
fuse_file_info_t ffi_out = {0}; |
|
|
|
|
|
struct fuse_copy_file_range_in *arg = (struct fuse_copy_file_range_in*)arg_; |
|
|
|
|
|
|
|
|
|
|
|
ffi_in.fh = arg->fh_in; |
|
|
|
|
|
ffi_out.fh = arg->fh_out; |
|
|
|
|
|
|
|
|
|
|
|
req_->f->op.copy_file_range(req_, |
|
|
|
|
|
nodeid_in_, |
|
|
|
|
|
arg->off_in, |
|
|
|
|
|
&ffi_in, |
|
|
|
|
|
arg->nodeid_out, |
|
|
|
|
|
arg->off_out, |
|
|
|
|
|
&ffi_out, |
|
|
|
|
|
arg->len, |
|
|
|
|
|
arg->flags); |
|
|
|
|
|
|
|
|
req_->f->op.copy_file_range(req_,hdr_); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
static |
|
@ -2233,7 +1892,7 @@ fuse_req_ctx(fuse_req_t req) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static struct { |
|
|
static struct { |
|
|
void (*func)(fuse_req_t, uint64_t, const void *); |
|
|
|
|
|
|
|
|
void (*func)(fuse_req_t, struct fuse_in_header *); |
|
|
const char *name; |
|
|
const char *name; |
|
|
} fuse_ll_ops[] = |
|
|
} fuse_ll_ops[] = |
|
|
{ |
|
|
{ |
|
@ -2292,7 +1951,6 @@ fuse_ll_process_buf(void *data, |
|
|
{ |
|
|
{ |
|
|
struct fuse_ll *f = (struct fuse_ll*)data; |
|
|
struct fuse_ll *f = (struct fuse_ll*)data; |
|
|
struct fuse_in_header *in; |
|
|
struct fuse_in_header *in; |
|
|
const void *inarg; |
|
|
|
|
|
struct fuse_req *req; |
|
|
struct fuse_req *req; |
|
|
int err; |
|
|
int err; |
|
|
|
|
|
|
|
@ -2338,8 +1996,7 @@ fuse_ll_process_buf(void *data, |
|
|
if(in->opcode >= FUSE_MAXOP) |
|
|
if(in->opcode >= FUSE_MAXOP) |
|
|
goto reply_err; |
|
|
goto reply_err; |
|
|
|
|
|
|
|
|
inarg = (void*)&in[1]; |
|
|
|
|
|
fuse_ll_ops[in->opcode].func(req, in->nodeid, inarg); |
|
|
|
|
|
|
|
|
fuse_ll_ops[in->opcode].func(req, in); |
|
|
|
|
|
|
|
|
return; |
|
|
return; |
|
|
|
|
|
|
|
|