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

View file

@ -140,12 +140,6 @@ struct fuse_operations
/** Change the size of a file */
int (*truncate) (const char *, off_t);
/** Change the access and/or modification times of a file
*
* Deprecated, use utimens() instead.
*/
int (*utime) (const char *, struct utimbuf *);
/** File open operation
*
* No creation (O_CREAT, O_EXCL) and by default also no
@ -165,35 +159,6 @@ struct fuse_operations
*/
int (*open) (const char *, fuse_file_info_t *);
/** Read data from an open file
*
* Read should return exactly the number of bytes requested except
* on EOF or error, otherwise the rest of the data will be
* substituted with zeroes. An exception to this is when the
* 'direct_io' mount option is specified, in which case the return
* value of the read system call will reflect the return value of
* this operation.
*
* Changed in version 2.2
*/
int (*read) (const fuse_file_info_t *,
char *,
size_t,
off_t);
/** Write data to an open file
*
* Write should return exactly the number of bytes requested
* except on error. An exception to this is when the 'direct_io'
* mount option is specified (see read operation).
*
* Changed in version 2.2
*/
int (*write) (const fuse_file_info_t *,
const char *,
size_t,
off_t);
/** Get file system statistics
*
* The 'f_frsize', 'f_favail', 'f_fsid' and 'f_flag' fields are ignored
@ -340,7 +305,7 @@ struct fuse_operations
*
* Introduced in version 2.3
*/
void (*destroy) (void *);
void (*destroy) (void);
/**
* Check file access permissions
@ -606,9 +571,6 @@ struct fuse_context
/** Thread ID of the calling process */
pid_t pid;
/** Private filesystem data */
void *private_data;
/** Umask of the calling process (introduced in version 2.8) */
mode_t umask;
};
@ -633,15 +595,13 @@ struct fuse_context
* @param argc the argument counter passed to the main() function
* @param argv the argument vector passed to the main() function
* @param op the file system operation
* @param user_data user data supplied in the context during the init() method
* @return 0 on success, nonzero on failure
*/
/*
int fuse_main(int argc, char *argv[], const struct fuse_operations *op,
void *user_data);
int fuse_main(int argc, char *argv[], const struct fuse_operations *op);
*/
#define fuse_main(argc, argv, op, user_data) \
fuse_main_real(argc, argv, op, sizeof(*(op)), user_data)
#define fuse_main(argc, argv, op) \
fuse_main_real(argc, argv, op, sizeof(*(op)))
/* ----------------------------------------------------------- *
* More detailed API *
@ -654,12 +614,10 @@ struct fuse_context
* @param args argument vector
* @param op the filesystem operations
* @param op_size the size of the fuse_operations structure
* @param user_data user data supplied in the context during the init() method
* @return the created FUSE handle
*/
struct fuse *fuse_new(struct fuse_chan *ch, struct fuse_args *args,
const struct fuse_operations *op, size_t op_size,
void *user_data);
const struct fuse_operations *op, size_t op_size);
/**
* Destroy the FUSE handle.
@ -729,8 +687,7 @@ int fuse_is_lib_option(const char *opt);
*
* Do not call this directly, use fuse_main()
*/
int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op,
size_t op_size, void *user_data);
int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op, size_t op_size);
/**
* Start the cleanup thread when using option "remember".
@ -813,8 +770,6 @@ int fuse_fs_read(struct fuse_fs *fs, char *buf, size_t size,
int fuse_fs_read_buf(struct fuse_fs *fs,
struct fuse_bufvec **bufp, size_t size, off_t off,
fuse_file_info_t *fi);
int fuse_fs_write(struct fuse_fs *fs, const char *buf,
size_t size, off_t off, fuse_file_info_t *fi);
int fuse_fs_write_buf(struct fuse_fs *fs,
struct fuse_bufvec *buf, off_t off,
fuse_file_info_t *fi);
@ -889,11 +844,9 @@ int fuse_notify_poll(fuse_pollhandle_t *ph);
*
* @param op the filesystem operations
* @param op_size the size of the fuse_operations structure
* @param user_data user data supplied in the context during the init() method
* @return a new filesystem object
*/
struct fuse_fs *fuse_fs_new(const struct fuse_operations *op, size_t op_size,
void *user_data);
struct fuse_fs *fuse_fs_new(const struct fuse_operations *op, size_t op_size);
/* ----------------------------------------------------------- *
* Advanced API for event handling, don't worry about this... *
@ -908,8 +861,7 @@ typedef void (*fuse_processor_t)(struct fuse *, struct fuse_cmd *, void *);
/** This is the part of fuse_main() before the event loop */
struct fuse *fuse_setup(int argc, char *argv[],
const struct fuse_operations *op, size_t op_size,
char **mountpoint,
void *user_data);
char **mountpoint);
/** This is the part of fuse_main() after the event loop */
void fuse_teardown(struct fuse *fuse, char *mountpoint);

View file

@ -1482,36 +1482,6 @@ const struct fuse_ctx *fuse_req_ctx(fuse_req_t req);
*/
int fuse_req_getgroups(fuse_req_t req, int size, gid_t list[]);
/**
* Callback function for an interrupt
*
* @param req interrupted request
* @param data user data
*/
typedef void (*fuse_interrupt_func_t)(fuse_req_t req, void *data);
/**
* Register/unregister callback for an interrupt
*
* If an interrupt has already happened, then the callback function is
* called from within this function, hence it's not possible for
* interrupts to be lost.
*
* @param req request handle
* @param func the callback function or NULL for unregister
* @param data user data passed to the callback function
*/
void fuse_req_interrupt_func(fuse_req_t req, fuse_interrupt_func_t func,
void *data);
/**
* Check if a request has already been interrupted
*
* @param req request handle
* @return 1 if the request has been interrupted, 0 otherwise
*/
int fuse_req_interrupted(fuse_req_t req);
/* ----------------------------------------------------------- *
* Filesystem setup *
* ----------------------------------------------------------- */

File diff suppressed because it is too large Load diff

View file

@ -35,23 +35,9 @@ struct fuse_req
{
struct fuse_ll *f;
uint64_t unique;
int ctr;
pthread_mutex_t lock;
struct fuse_ctx ctx;
struct fuse_chan *ch;
int interrupted;
unsigned int ioctl_64bit : 1;
union {
struct {
uint64_t unique;
} i;
struct {
fuse_interrupt_func_t func;
void *data;
} ni;
} u;
struct fuse_req *next;
struct fuse_req *prev;
};
struct fuse_notify_req
@ -66,7 +52,6 @@ struct fuse_notify_req
struct fuse_ll
{
int debug;
int allow_root;
int no_remote_posix_lock;
int no_remote_flock;
int big_writes;
@ -81,8 +66,6 @@ struct fuse_ll
void *userdata;
uid_t owner;
struct fuse_conn_info conn;
struct fuse_req list;
struct fuse_req interrupts;
pthread_mutex_t lock;
int got_destroy;
pthread_key_t pipe_key;
@ -100,7 +83,7 @@ struct fuse_cmd
struct fuse *fuse_new_common(struct fuse_chan *ch, struct fuse_args *args,
const struct fuse_operations *op,
size_t op_size, void *user_data);
size_t op_size);
struct fuse_chan *fuse_kern_chan_new(int fd);
@ -122,7 +105,6 @@ struct fuse *fuse_setup_common(int argc, char *argv[],
const struct fuse_operations *op,
size_t op_size,
char **mountpoint,
int *fd,
void *user_data);
int *fd);
int fuse_start_thread(pthread_t *thread_id, void *(*func)(void *), void *arg);

File diff suppressed because it is too large Load diff

View file

@ -290,8 +290,7 @@ struct fuse *fuse_setup_common(int argc, char *argv[],
const struct fuse_operations *op,
size_t op_size,
char **mountpoint,
int *fd,
void *user_data)
int *fd)
{
struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
struct fuse_chan *ch;
@ -309,7 +308,7 @@ struct fuse *fuse_setup_common(int argc, char *argv[],
goto err_free;
}
fuse = fuse_new_common(ch, &args, op, op_size, user_data);
fuse = fuse_new_common(ch, &args, op, op_size);
fuse_opt_free_args(&args);
if (fuse == NULL)
goto err_unmount;
@ -338,10 +337,10 @@ struct fuse *fuse_setup_common(int argc, char *argv[],
struct fuse *fuse_setup(int argc, char *argv[],
const struct fuse_operations *op, size_t op_size,
char **mountpoint, void *user_data)
char **mountpoint)
{
return fuse_setup_common(argc, argv, op, op_size, mountpoint,
NULL, user_data);
NULL);
}
static void fuse_teardown_common(struct fuse *fuse, char *mountpoint)
@ -360,8 +359,7 @@ void fuse_teardown(struct fuse *fuse, char *mountpoint)
}
static int fuse_main_common(int argc, char *argv[],
const struct fuse_operations *op, size_t op_size,
void *user_data)
const struct fuse_operations *op, size_t op_size)
{
struct fuse *fuse;
char *mountpoint;
@ -369,7 +367,7 @@ static int fuse_main_common(int argc, char *argv[],
fuse = fuse_setup_common(argc, argv, op, op_size,
&mountpoint,
NULL, user_data);
NULL);
if (fuse == NULL)
return 1;
@ -382,10 +380,12 @@ static int fuse_main_common(int argc, char *argv[],
return 0;
}
int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op,
size_t op_size, void *user_data)
int fuse_main_real(int argc,
char *argv[],
const struct fuse_operations *op,
size_t op_size)
{
return fuse_main_common(argc, argv, op, op_size, user_data);
return fuse_main_common(argc, argv, op, op_size);
}
#undef fuse_main

View file

@ -28,7 +28,6 @@
#define FUSE_DEV_TRUNK "/dev/fuse"
enum {
KEY_ALLOW_ROOT,
KEY_RO,
KEY_HELP,
KEY_VERSION,
@ -37,7 +36,6 @@ enum {
struct mount_opts {
int allow_other;
int allow_root;
int ishelp;
char *kernel_opts;
};
@ -47,8 +45,6 @@ struct mount_opts {
static const struct fuse_opt fuse_mount_opts[] = {
{ "allow_other", offsetof(struct mount_opts, allow_other), 1 },
{ "allow_root", offsetof(struct mount_opts, allow_root), 1 },
FUSE_OPT_KEY("allow_root", KEY_ALLOW_ROOT),
FUSE_OPT_KEY("-r", KEY_RO),
FUSE_OPT_KEY("-h", KEY_HELP),
FUSE_OPT_KEY("--help", KEY_HELP),
@ -102,7 +98,6 @@ static const struct fuse_opt fuse_mount_opts[] = {
static void mount_help(void)
{
fprintf(stderr,
" -o allow_root allow access to root\n"
);
system(FUSERMOUNT_PROG " --help");
fputc('\n', stderr);
@ -119,12 +114,6 @@ static int fuse_mount_opt_proc(void *data, const char *arg, int key,
struct mount_opts *mo = data;
switch (key) {
case KEY_ALLOW_ROOT:
if (fuse_opt_add_opt(&mo->kernel_opts, "allow_other") == -1 ||
fuse_opt_add_arg(outargs, "-oallow_root") == -1)
return -1;
return 0;
case KEY_RO:
arg = "ro";
/* fall through */
@ -328,10 +317,6 @@ int fuse_kern_mount(const char *mountpoint, struct fuse_args *args)
fuse_opt_parse(args, &mo, fuse_mount_opts, fuse_mount_opt_proc) == -1)
return -1;
if (mo.allow_other && mo.allow_root) {
fprintf(stderr, "fuse: 'allow_other' and 'allow_root' options are mutually exclusive\n");
goto out;
}
if (mo.ishelp)
return 0;

View file

@ -55,7 +55,6 @@ enum {
KEY_FUSERMOUNT_OPT,
KEY_SUBTYPE_OPT,
KEY_MTAB_OPT,
KEY_ALLOW_ROOT,
KEY_RO,
KEY_HELP,
KEY_VERSION,
@ -63,7 +62,6 @@ enum {
struct mount_opts {
int allow_other;
int allow_root;
int ishelp;
int flags;
int nonempty;
@ -81,14 +79,12 @@ struct mount_opts {
static const struct fuse_opt fuse_mount_opts[] = {
FUSE_MOUNT_OPT("allow_other", allow_other),
FUSE_MOUNT_OPT("allow_root", allow_root),
FUSE_MOUNT_OPT("nonempty", nonempty),
FUSE_MOUNT_OPT("blkdev", blkdev),
FUSE_MOUNT_OPT("auto_unmount", auto_unmount),
FUSE_MOUNT_OPT("fsname=%s", fsname),
FUSE_MOUNT_OPT("subtype=%s", subtype),
FUSE_OPT_KEY("allow_other", KEY_KERN_OPT),
FUSE_OPT_KEY("allow_root", KEY_ALLOW_ROOT),
FUSE_OPT_KEY("nonempty", KEY_FUSERMOUNT_OPT),
FUSE_OPT_KEY("auto_unmount", KEY_FUSERMOUNT_OPT),
FUSE_OPT_KEY("blkdev", KEY_FUSERMOUNT_OPT),
@ -129,7 +125,6 @@ static void mount_help(void)
{
fprintf(stderr,
" -o allow_other allow access to other users\n"
" -o allow_root allow access to root\n"
" -o auto_unmount auto unmount on process termination\n"
" -o nonempty allow mounts over non-empty file/dir\n"
" -o default_permissions enable permission checking by kernel\n"
@ -208,12 +203,6 @@ static int fuse_mount_opt_proc(void *data, const char *arg, int key,
struct mount_opts *mo = data;
switch (key) {
case KEY_ALLOW_ROOT:
if (fuse_opt_add_opt(&mo->kernel_opts, "allow_other") == -1 ||
fuse_opt_add_arg(outargs, "-oallow_root") == -1)
return -1;
return 0;
case KEY_RO:
arg = "ro";
/* fall through */
@ -575,10 +564,6 @@ int fuse_kern_mount(const char *mountpoint, struct fuse_args *args)
fuse_opt_parse(args, &mo, fuse_mount_opts, fuse_mount_opt_proc) == -1)
return -1;
if (mo.allow_other && mo.allow_root) {
fprintf(stderr, "fuse: 'allow_other' and 'allow_root' options are mutually exclusive\n");
goto out;
}
res = 0;
if (mo.ishelp)
goto out;

View file

@ -782,9 +782,7 @@ static int do_mount(const char *mnt, char **typep, mode_t rootmode,
skip_option = 1;
}
}
if (getuid() != 0 && !user_allow_other &&
(opt_eq(s, len, "allow_other") ||
opt_eq(s, len, "allow_root"))) {
if (getuid() != 0 && !user_allow_other && opt_eq(s, len, "allow_other")) {
fprintf(stderr, "%s: option %.*s only allowed if 'user_allow_other' is set in /etc/fuse.conf\n", progname, len, s);
goto err;
}