|
@ -36,18 +36,18 @@ using std::string; |
|
|
static |
|
|
static |
|
|
int |
|
|
int |
|
|
_write_buf_controlfile(const string controlfile, |
|
|
_write_buf_controlfile(const string controlfile, |
|
|
struct fuse_bufvec *buf, |
|
|
|
|
|
struct fuse_file_info *fi) |
|
|
|
|
|
|
|
|
struct fuse_bufvec &src, |
|
|
|
|
|
struct fuse_file_info &fi) |
|
|
{ |
|
|
{ |
|
|
int rv; |
|
|
int rv; |
|
|
size_t size; |
|
|
size_t size; |
|
|
struct fuse_bufvec dst; |
|
|
struct fuse_bufvec dst; |
|
|
|
|
|
|
|
|
size = fuse_buf_size(buf); |
|
|
|
|
|
|
|
|
size = fuse_buf_size(&src); |
|
|
dst = FUSE_BUFVEC_INIT(size); |
|
|
dst = FUSE_BUFVEC_INIT(size); |
|
|
dst.buf->mem = malloc(size); |
|
|
dst.buf->mem = malloc(size); |
|
|
|
|
|
|
|
|
rv = fuse_buf_copy(&dst,buf,(fuse_buf_copy_flags)0); |
|
|
|
|
|
|
|
|
rv = fuse_buf_copy(&dst,&src,(fuse_buf_copy_flags)0); |
|
|
if(rv < 0) |
|
|
if(rv < 0) |
|
|
{ |
|
|
{ |
|
|
free(dst.buf->mem); |
|
|
free(dst.buf->mem); |
|
@ -58,7 +58,7 @@ _write_buf_controlfile(const string controlfile, |
|
|
(const char*)dst.buf->mem, |
|
|
(const char*)dst.buf->mem, |
|
|
size, |
|
|
size, |
|
|
0, |
|
|
0, |
|
|
fi); |
|
|
|
|
|
|
|
|
&fi); |
|
|
free(dst.buf->mem); |
|
|
free(dst.buf->mem); |
|
|
|
|
|
|
|
|
return rv; |
|
|
return rv; |
|
@ -67,19 +67,19 @@ _write_buf_controlfile(const string controlfile, |
|
|
static |
|
|
static |
|
|
int |
|
|
int |
|
|
_write_buf(const int fd, |
|
|
_write_buf(const int fd, |
|
|
struct fuse_bufvec *buf, |
|
|
|
|
|
|
|
|
struct fuse_bufvec &src, |
|
|
const off_t offset) |
|
|
const off_t offset) |
|
|
{ |
|
|
{ |
|
|
size_t size = fuse_buf_size(buf); |
|
|
|
|
|
struct fuse_bufvec dest = FUSE_BUFVEC_INIT(size); |
|
|
|
|
|
|
|
|
size_t size = fuse_buf_size(&src); |
|
|
|
|
|
struct fuse_bufvec dst = FUSE_BUFVEC_INIT(size); |
|
|
const fuse_buf_copy_flags cpflags = |
|
|
const fuse_buf_copy_flags cpflags = |
|
|
(fuse_buf_copy_flags)(FUSE_BUF_SPLICE_MOVE|FUSE_BUF_SPLICE_NONBLOCK); |
|
|
(fuse_buf_copy_flags)(FUSE_BUF_SPLICE_MOVE|FUSE_BUF_SPLICE_NONBLOCK); |
|
|
|
|
|
|
|
|
dest.buf->flags = (fuse_buf_flags)(FUSE_BUF_IS_FD|FUSE_BUF_FD_SEEK); |
|
|
|
|
|
dest.buf->fd = fd; |
|
|
|
|
|
dest.buf->pos = offset; |
|
|
|
|
|
|
|
|
dst.buf->flags = (fuse_buf_flags)(FUSE_BUF_IS_FD|FUSE_BUF_FD_SEEK); |
|
|
|
|
|
dst.buf->fd = fd; |
|
|
|
|
|
dst.buf->pos = offset; |
|
|
|
|
|
|
|
|
return fuse_buf_copy(&dest,buf,cpflags); |
|
|
|
|
|
|
|
|
return fuse_buf_copy(&dst,&src,cpflags); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
namespace mergerfs |
|
|
namespace mergerfs |
|
@ -88,7 +88,7 @@ namespace mergerfs |
|
|
{ |
|
|
{ |
|
|
int |
|
|
int |
|
|
write_buf(const char *fusepath, |
|
|
write_buf(const char *fusepath, |
|
|
struct fuse_bufvec *buf, |
|
|
|
|
|
|
|
|
struct fuse_bufvec *src, |
|
|
off_t offset, |
|
|
off_t offset, |
|
|
struct fuse_file_info *fi) |
|
|
struct fuse_file_info *fi) |
|
|
{ |
|
|
{ |
|
@ -96,11 +96,11 @@ namespace mergerfs |
|
|
|
|
|
|
|
|
if(fusepath == config.controlfile) |
|
|
if(fusepath == config.controlfile) |
|
|
return _write_buf_controlfile(config.controlfile, |
|
|
return _write_buf_controlfile(config.controlfile, |
|
|
buf, |
|
|
|
|
|
fi); |
|
|
|
|
|
|
|
|
*src, |
|
|
|
|
|
*fi); |
|
|
|
|
|
|
|
|
return _write_buf(((FileInfo*)fi->fh)->fd, |
|
|
return _write_buf(((FileInfo*)fi->fh)->fd, |
|
|
buf, |
|
|
|
|
|
|
|
|
*src, |
|
|
offset); |
|
|
offset); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|