Major cleanup of libfuse to remove unneeded features

* Remove request interrupt code. Required tracking of all requests unnecesssarily.
* Remove all debugging printing. Have plans to do full replacement.
* Remove deprecated functions.
* Remove unneeded error checking.
* Remove "userdata" which was unused.
* Remove allow_root feature.
This commit is contained in:
Antonio SJ Musumeci 2021-08-24 21:24:51 -04:00
parent 0547517a99
commit 43a6d66e3c
21 changed files with 479 additions and 1651 deletions

39
src/fuse_bmap.cpp Normal file
View file

@ -0,0 +1,39 @@
/*
ISC License
Copyright (c) 2021, Antonio SJ Musumeci <trapexit@spawn.link>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "errno.hpp"
#include <cstdint>
#include <stddef.h>
namespace FUSE
{
int
bmap(const char *fusepath_,
size_t blocksize_,
uint64_t *idx_)
{
(void)fusepath_;
(void)blocksize_;
(void)idx_;
return -ENOSYS;
}
}

29
src/fuse_bmap.hpp Normal file
View file

@ -0,0 +1,29 @@
/*
ISC License
Copyright (c) 2021, Antonio SJ Musumeci <trapexit@spawn.link>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#pragma once
#include "fuse.h"
namespace FUSE
{
int
bmap(const char *fusepath,
size_t blocksize,
uint64_t *idx);
}

View file

@ -17,7 +17,7 @@
namespace FUSE
{
void
destroy(void *)
destroy(void)
{
}

View file

@ -20,5 +20,5 @@
namespace FUSE
{
void
destroy(void *);
destroy(void);
}

33
src/fuse_lock.cpp Normal file
View file

@ -0,0 +1,33 @@
/*
ISC License
Copyright (c) 2021, Antonio SJ Musumeci <trapexit@spawn.link>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "errno.hpp"
#include "fuse.h"
namespace FUSE
{
int
lock(const fuse_file_info_t *ffi,
int cmd,
struct flock *flock)
{
return -ENOSYS;
}
}

29
src/fuse_lock.hpp Normal file
View file

@ -0,0 +1,29 @@
/*
ISC License
Copyright (c) 2021, Antonio SJ Musumeci <trapexit@spawn.link>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#pragma once
#include "fuse.h"
namespace FUSE
{
int
lock(const fuse_file_info_t *ffi,
int cmd,
struct flock *flock);
}

37
src/fuse_poll.cpp Normal file
View file

@ -0,0 +1,37 @@
/*
ISC License
Copyright (c) 2021, Antonio SJ Musumeci <trapexit@spawn.link>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "errno.hpp"
#include "fuse.h"
namespace FUSE
{
int
poll(const fuse_file_info_t *ffi_,
fuse_pollhandle_t *ph_,
unsigned *reventsp_)
{
(void)ffi_;
(void)ph_;
(void)reventsp_;
return -ENOSYS;
}
}

View file

@ -1,5 +1,7 @@
/*
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
ISC License
Copyright (c) 2021, Antonio SJ Musumeci <trapexit@spawn.link>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@ -22,14 +24,7 @@
namespace FUSE
{
int
read(const fuse_file_info_t *ffi,
char *buf,
size_t count,
off_t offset);
int
read_null(const fuse_file_info_t *ffi,
char *buf,
size_t count,
off_t offset);
poll(const fuse_file_info_t *ffi,
fuse_pollhandle_t *ph,
unsigned *reventsp);
}

View file

@ -1,88 +0,0 @@
/*
Copyright (c) 2016, Antonio SJ Musumeci <trapexit@spawn.link>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "errno.hpp"
#include "fileinfo.hpp"
#include "fs_read.hpp"
#include "fuse.h"
namespace l
{
static
inline
int
read_regular(const int fd_,
void *buf_,
const size_t count_,
const off_t offset_)
{
int rv;
rv = fs::pread(fd_,buf_,count_,offset_);
if(rv == -1)
return -errno;
if(rv == 0)
return 0;
return count_;
}
static
inline
int
read_direct_io(const int fd_,
void *buf_,
const size_t count_,
const off_t offset_)
{
int rv;
rv = fs::pread(fd_,buf_,count_,offset_);
if(rv == -1)
return -errno;
return rv;
}
}
namespace FUSE
{
int
read(const fuse_file_info_t *ffi_,
char *buf_,
size_t count_,
off_t offset_)
{
FileInfo *fi;
fi = reinterpret_cast<FileInfo*>(ffi_->fh);
if(ffi_->direct_io)
return l::read_direct_io(fi->fd,buf_,count_,offset_);
return l::read_regular(fi->fd,buf_,count_,offset_);
}
int
read_null(const fuse_file_info_t *ffi_,
char *buf_,
size_t count_,
off_t offset_)
{
return count_;
}
}

View file

@ -67,4 +67,32 @@ namespace FUSE
size_,
offset_);
}
int
read_buf_null(const fuse_file_info_t *ffi_,
fuse_bufvec **bufp_,
size_t size_,
off_t offset_)
{
void *mem;
struct fuse_bufvec *buf;
buf = (struct fuse_bufvec*)malloc(sizeof(struct fuse_bufvec));
if(buf == NULL)
return -ENOMEM;
mem = (void*)calloc(1,size_);
if(mem == NULL)
{
free(buf);
return -ENOMEM;
}
*buf = FUSE_BUFVEC_INIT(size_);
buf->buf[0].mem = mem;
*bufp_ = buf;
return 0;
}
}

View file

@ -28,4 +28,10 @@ namespace FUSE
struct fuse_bufvec **buf,
size_t size,
off_t offset);
int
read_buf_null(const fuse_file_info_t *ffi,
struct fuse_bufvec **buf,
size_t size,
off_t offset);
}

View file

@ -21,6 +21,7 @@
#include "strvec.hpp"
#include "fuse_access.hpp"
#include "fuse_bmap.hpp"
#include "fuse_chmod.hpp"
#include "fuse_chown.hpp"
#include "fuse_copy_file_range.hpp"
@ -43,12 +44,13 @@
#include "fuse_ioctl.hpp"
#include "fuse_link.hpp"
#include "fuse_listxattr.hpp"
#include "fuse_lock.hpp"
#include "fuse_mkdir.hpp"
#include "fuse_mknod.hpp"
#include "fuse_open.hpp"
#include "fuse_opendir.hpp"
#include "fuse_poll.hpp"
#include "fuse_prepare_hide.hpp"
#include "fuse_read.hpp"
#include "fuse_read_buf.hpp"
#include "fuse_readdir.hpp"
#include "fuse_readdir_plus.hpp"
@ -64,7 +66,6 @@
#include "fuse_truncate.hpp"
#include "fuse_unlink.hpp"
#include "fuse_utimens.hpp"
#include "fuse_write.hpp"
#include "fuse_write_buf.hpp"
#include "fuse.h"
@ -83,7 +84,7 @@ namespace l
const bool nullrw_)
{
ops_.access = FUSE::access;
ops_.bmap = NULL;
ops_.bmap = FUSE::bmap;
ops_.chmod = FUSE::chmod;
ops_.chown = FUSE::chown;
ops_.copy_file_range = FUSE::copy_file_range;
@ -93,7 +94,7 @@ namespace l
ops_.fchmod = FUSE::fchmod;
ops_.fchown = FUSE::fchown;
ops_.fgetattr = FUSE::fgetattr;
ops_.flock = NULL; // FUSE::flock;
ops_.flock = FUSE::flock;
ops_.flush = FUSE::flush;
ops_.free_hide = FUSE::free_hide;
ops_.fsync = FUSE::fsync;
@ -106,15 +107,14 @@ namespace l
ops_.ioctl = FUSE::ioctl;
ops_.link = FUSE::link;
ops_.listxattr = FUSE::listxattr;
ops_.lock = NULL;
ops_.lock = FUSE::lock;
ops_.mkdir = FUSE::mkdir;
ops_.mknod = FUSE::mknod;
ops_.open = FUSE::open;
ops_.opendir = FUSE::opendir;
ops_.poll = NULL;
ops_.poll = FUSE::poll;;
ops_.prepare_hide = FUSE::prepare_hide;
ops_.read = (nullrw_ ? FUSE::read_null : FUSE::read);
ops_.read_buf = (nullrw_ ? NULL : FUSE::read_buf);
ops_.read_buf = (nullrw_ ? FUSE::read_buf_null : FUSE::read_buf);
ops_.readdir = FUSE::readdir;
ops_.readdir_plus = FUSE::readdir_plus;
ops_.readlink = FUSE::readlink;
@ -128,9 +128,7 @@ namespace l
ops_.symlink = FUSE::symlink;
ops_.truncate = FUSE::truncate;
ops_.unlink = FUSE::unlink;
ops_.utime = NULL; /* deprecated; use utimens() */
ops_.utimens = FUSE::utimens;
ops_.write = (nullrw_ ? FUSE::write_null : FUSE::write);
ops_.write_buf = (nullrw_ ? FUSE::write_buf_null : FUSE::write_buf);
return;
@ -173,8 +171,7 @@ namespace l
return fuse_main(args.argc,
args.argv,
&ops,
NULL);
&ops);
}
}