mirror of
https://github.com/libfuse/libfuse.git
synced 2024-11-23 12:14:15 +08:00
cleanup
This commit is contained in:
parent
d59bb9d289
commit
f458b8c07b
@ -4,6 +4,8 @@
|
||||
|
||||
* More comments in fuse.h
|
||||
|
||||
* Get rid of double underscores
|
||||
|
||||
2004-12-04 Miklos Szeredi <miklos@szeredi.hu>
|
||||
|
||||
* Add -D_FILE_OFFSET_BITS=64 to cflags provided by pkg-config
|
||||
|
@ -285,7 +285,7 @@ struct fuse_context {
|
||||
int fuse_main(int argc, char *argv[], const struct fuse_operations *op);
|
||||
*/
|
||||
#define fuse_main(argc, argv, op) \
|
||||
__fuse_main(argc, argv, op, sizeof(*(op)))
|
||||
fuse_main_real(argc, argv, op, sizeof(*(op)))
|
||||
|
||||
/* ----------------------------------------------------------- *
|
||||
* More detailed API *
|
||||
@ -399,8 +399,8 @@ int fuse_is_lib_option(const char *opt);
|
||||
*
|
||||
* Do not call this directly, use fuse_main()
|
||||
*/
|
||||
int __fuse_main(int argc, char *argv[], const struct fuse_operations *op,
|
||||
size_t op_size);
|
||||
int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op,
|
||||
size_t op_size);
|
||||
|
||||
/* ----------------------------------------------------------- *
|
||||
* Advanced API for event handling, don't worry about this... *
|
||||
@ -413,29 +413,29 @@ struct fuse_cmd;
|
||||
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,
|
||||
struct fuse *fuse_setup(int argc, char *argv[],
|
||||
const struct fuse_operations *op, size_t op_size,
|
||||
char **mountpoint, int *multithreaded, int *fd);
|
||||
|
||||
/** This is the part of fuse_main() after the event loop */
|
||||
void __fuse_teardown(struct fuse *fuse, int fd, char *mountpoint);
|
||||
void fuse_teardown(struct fuse *fuse, int fd, char *mountpoint);
|
||||
|
||||
/** Read a single command. If none are read, return NULL */
|
||||
struct fuse_cmd *__fuse_read_cmd(struct fuse *f);
|
||||
struct fuse_cmd *fuse_read_cmd(struct fuse *f);
|
||||
|
||||
/** Process a single command */
|
||||
void __fuse_process_cmd(struct fuse *f, struct fuse_cmd *cmd);
|
||||
void fuse_process_cmd(struct fuse *f, struct fuse_cmd *cmd);
|
||||
|
||||
/** Multi threaded event loop, which calls the custom command
|
||||
processor function */
|
||||
int __fuse_loop_mt(struct fuse *f, fuse_processor_t proc, void *data);
|
||||
int fuse_loop_mt_proc(struct fuse *f, fuse_processor_t proc, void *data);
|
||||
|
||||
/** Return the exited flag, which indicates if fuse_exit() has been
|
||||
called */
|
||||
int __fuse_exited(struct fuse* f);
|
||||
int fuse_exited(struct fuse* f);
|
||||
|
||||
/** Set function which can be used to get the current context */
|
||||
void __fuse_set_getcontext_func(struct fuse_context *(*func)(void));
|
||||
void fuse_set_getcontext_func(struct fuse_context *(*func)(void));
|
||||
|
||||
/* ----------------------------------------------------------- *
|
||||
* Compatibility stuff *
|
||||
@ -443,26 +443,32 @@ void __fuse_set_getcontext_func(struct fuse_context *(*func)(void));
|
||||
|
||||
#if FUSE_USE_VERSION == 21 || FUSE_USE_VERSION == 11
|
||||
# include <fuse_compat.h>
|
||||
# define fuse_dirfil_t _fuse_dirfil_t_compat
|
||||
# define fuse_dirfil_t fuse_dirfil_t_compat
|
||||
# define __fuse_read_cmd fuse_read_cmd
|
||||
# define __fuse_process_cmd fuse_process_cmd
|
||||
# define __fuse_loop_mt fuse_loop_mt_proc
|
||||
# undef fuse_main
|
||||
# undef FUSE_MINOR_VERSION
|
||||
# undef FUSE_MAJOR_VERSION
|
||||
# if FUSE_USE_VERSION == 21
|
||||
# define FUSE_MAJOR_VERSION 2
|
||||
# define FUSE_MINOR_VERSION 1
|
||||
# define fuse_operations _fuse_operations_compat2
|
||||
# define fuse_main _fuse_main_compat2
|
||||
# define fuse_new _fuse_new_compat2
|
||||
# define __fuse_setup _fuse_setup_compat2
|
||||
# define fuse_operations fuse_operations_compat2
|
||||
# define fuse_main fuse_main_compat2
|
||||
# define fuse_new fuse_new_compat2
|
||||
# define __fuse_setup fuse_setup_compat2
|
||||
# define __fuse_teardown fuse_teardown
|
||||
# define __fuse_exited fuse_exited
|
||||
# define __fuse_set_getcontext_func fuse_set_getcontext_func
|
||||
# else
|
||||
# define FUSE_MAJOR_VERSION 1
|
||||
# define FUSE_MINOR_VERSION 1
|
||||
# define fuse_statfs _fuse_statfs_compat1
|
||||
# define fuse_operations _fuse_operations_compat1
|
||||
# define fuse_main _fuse_main_compat1
|
||||
# define fuse_new _fuse_new_compat1
|
||||
# define fuse_mount _fuse_mount_compat1
|
||||
# define FUSE_DEBUG _FUSE_DEBUG_COMPAT1
|
||||
# define fuse_statfs fuse_statfs_compat1
|
||||
# define fuse_operations fuse_operations_compat1
|
||||
# define fuse_main fuse_main_compat1
|
||||
# define fuse_new fuse_new_compat1
|
||||
# define fuse_mount fuse_mount_compat1
|
||||
# define FUSE_DEBUG FUSE_DEBUG_COMPAT1
|
||||
# endif
|
||||
#elif FUSE_USE_VERSION < 22
|
||||
# error Compatibility with API version other than 21 and 11 not supported
|
||||
|
@ -9,11 +9,11 @@
|
||||
/* these definitions provide source compatibility to prior versions.
|
||||
Do not include this file directly! */
|
||||
|
||||
typedef int (*_fuse_dirfil_t_compat) (fuse_dirh_t h, const char *name, int type);
|
||||
struct _fuse_operations_compat2 {
|
||||
typedef int (*fuse_dirfil_t_compat) (fuse_dirh_t h, const char *name, int type);
|
||||
struct fuse_operations_compat2 {
|
||||
int (*getattr) (const char *, struct stat *);
|
||||
int (*readlink) (const char *, char *, size_t);
|
||||
int (*getdir) (const char *, fuse_dirh_t, _fuse_dirfil_t_compat);
|
||||
int (*getdir) (const char *, fuse_dirh_t, fuse_dirfil_t_compat);
|
||||
int (*mknod) (const char *, mode_t, dev_t);
|
||||
int (*mkdir) (const char *, mode_t);
|
||||
int (*unlink) (const char *);
|
||||
@ -38,13 +38,13 @@ struct _fuse_operations_compat2 {
|
||||
int (*removexattr) (const char *, const char *);
|
||||
};
|
||||
|
||||
int _fuse_main_compat2(int argc, char *argv[], const struct _fuse_operations_compat2 *op);
|
||||
int fuse_main_compat2(int argc, char *argv[], const struct fuse_operations_compat2 *op);
|
||||
|
||||
struct fuse *_fuse_new_compat2(int fd, const char *opts, const struct _fuse_operations_compat2 *op);
|
||||
struct fuse *fuse_new_compat2(int fd, const char *opts, const struct fuse_operations_compat2 *op);
|
||||
|
||||
struct fuse *_fuse_setup_compat2(int argc, char *argv[], const struct _fuse_operations_compat2 *op, char **mountpoint, int *multithreaded, int *fd);
|
||||
struct fuse *fuse_setup_compat2(int argc, char *argv[], const struct fuse_operations_compat2 *op, char **mountpoint, int *multithreaded, int *fd);
|
||||
|
||||
struct _fuse_statfs_compat1 {
|
||||
struct fuse_statfs_compat1 {
|
||||
long block_size;
|
||||
long blocks;
|
||||
long blocks_free;
|
||||
@ -53,10 +53,10 @@ struct _fuse_statfs_compat1 {
|
||||
long namelen;
|
||||
};
|
||||
|
||||
struct _fuse_operations_compat1 {
|
||||
struct fuse_operations_compat1 {
|
||||
int (*getattr) (const char *, struct stat *);
|
||||
int (*readlink) (const char *, char *, size_t);
|
||||
int (*getdir) (const char *, fuse_dirh_t, _fuse_dirfil_t_compat);
|
||||
int (*getdir) (const char *, fuse_dirh_t, fuse_dirfil_t_compat);
|
||||
int (*mknod) (const char *, mode_t, dev_t);
|
||||
int (*mkdir) (const char *, mode_t);
|
||||
int (*unlink) (const char *);
|
||||
@ -71,15 +71,15 @@ struct _fuse_operations_compat1 {
|
||||
int (*open) (const char *, int);
|
||||
int (*read) (const char *, char *, size_t, off_t);
|
||||
int (*write) (const char *, const char *, size_t, off_t);
|
||||
int (*statfs) (struct _fuse_statfs_compat1 *);
|
||||
int (*statfs) (struct fuse_statfs_compat1 *);
|
||||
int (*release) (const char *, int);
|
||||
int (*fsync) (const char *, int);
|
||||
};
|
||||
|
||||
#define _FUSE_DEBUG_COMPAT1 (1 << 1)
|
||||
#define FUSE_DEBUG_COMPAT1 (1 << 1)
|
||||
|
||||
int _fuse_mount_compat1(const char *mountpoint, const char *args[]);
|
||||
int fuse_mount_compat1(const char *mountpoint, const char *args[]);
|
||||
|
||||
struct fuse *_fuse_new_compat1(int fd, int flags, const struct _fuse_operations_compat1 *op);
|
||||
struct fuse *fuse_new_compat1(int fd, int flags, const struct fuse_operations_compat1 *op);
|
||||
|
||||
void _fuse_main_compat1(int argc, char *argv[], const struct _fuse_operations_compat1 *op);
|
||||
void fuse_main_compat1(int argc, char *argv[], const struct fuse_operations_compat1 *op);
|
||||
|
106
lib/fuse.c
106
lib/fuse.c
@ -61,7 +61,6 @@ static const char *opname(enum fuse_opcode opcode)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static inline void dec_avail(struct fuse *f)
|
||||
{
|
||||
pthread_mutex_lock(&f->lock);
|
||||
@ -69,7 +68,7 @@ static inline void dec_avail(struct fuse *f)
|
||||
pthread_mutex_unlock(&f->lock);
|
||||
}
|
||||
|
||||
static struct node *__get_node(struct fuse *f, nodeid_t nodeid)
|
||||
static struct node *get_node_nocheck(struct fuse *f, nodeid_t nodeid)
|
||||
{
|
||||
size_t hash = nodeid % f->id_table_size;
|
||||
struct node *node;
|
||||
@ -83,7 +82,7 @@ static struct node *__get_node(struct fuse *f, nodeid_t nodeid)
|
||||
|
||||
static struct node *get_node(struct fuse *f, nodeid_t nodeid)
|
||||
{
|
||||
struct node *node = __get_node(f, nodeid);
|
||||
struct node *node = get_node_nocheck(f, nodeid);
|
||||
if (node != NULL)
|
||||
return node;
|
||||
|
||||
@ -116,7 +115,7 @@ static nodeid_t next_id(struct fuse *f)
|
||||
f->ctr++;
|
||||
if (!f->ctr)
|
||||
f->generation ++;
|
||||
} while (f->ctr == 0 || __get_node(f, f->ctr) != NULL);
|
||||
} while (f->ctr == 0 || get_node_nocheck(f, f->ctr) != NULL);
|
||||
return f->ctr;
|
||||
}
|
||||
|
||||
@ -137,7 +136,7 @@ static unsigned int name_hash(struct fuse *f, nodeid_t parent, const char *name)
|
||||
return (hash + parent) % f->name_table_size;
|
||||
}
|
||||
|
||||
static struct node *__lookup_node(struct fuse *f, nodeid_t parent,
|
||||
static struct node *lookup_node(struct fuse *f, nodeid_t parent,
|
||||
const char *name)
|
||||
{
|
||||
size_t hash = name_hash(f, parent, name);
|
||||
@ -150,22 +149,6 @@ static struct node *__lookup_node(struct fuse *f, nodeid_t parent,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct node *lookup_node(struct fuse *f, nodeid_t parent,
|
||||
const char *name)
|
||||
{
|
||||
struct node *node;
|
||||
|
||||
pthread_mutex_lock(&f->lock);
|
||||
node = __lookup_node(f, parent, name);
|
||||
pthread_mutex_unlock(&f->lock);
|
||||
if (node != NULL)
|
||||
return node;
|
||||
|
||||
fprintf(stderr, "fuse internal error: node %lu/%s not found\n", parent,
|
||||
name);
|
||||
abort();
|
||||
}
|
||||
|
||||
static int hash_name(struct fuse *f, struct node *node, nodeid_t parent,
|
||||
const char *name)
|
||||
{
|
||||
@ -212,7 +195,7 @@ static struct node *find_node(struct fuse *f, nodeid_t parent, char *name,
|
||||
rdev = attr->rdev;
|
||||
|
||||
pthread_mutex_lock(&f->lock);
|
||||
node = __lookup_node(f, parent, name);
|
||||
node = lookup_node(f, parent, name);
|
||||
if (node != NULL) {
|
||||
if (node->mode == mode && node->rdev == rdev &&
|
||||
(!(f->flags & FUSE_USE_INO) || node->ino == attr->ino)) {
|
||||
@ -270,7 +253,7 @@ static int path_lookup(struct fuse *f, const char *path, nodeid_t *nodeidp,
|
||||
err = 0;
|
||||
for (s = tmp; (name = strsep(&s, "/")) != NULL; ) {
|
||||
if (name[0]) {
|
||||
struct node *node = __lookup_node(f, nodeid, name);
|
||||
struct node *node = lookup_node(f, nodeid, name);
|
||||
if (node == NULL) {
|
||||
err = -ENOENT;
|
||||
break;
|
||||
@ -350,7 +333,7 @@ static void destroy_node(struct fuse *f, nodeid_t nodeid, int version)
|
||||
struct node *node;
|
||||
|
||||
pthread_mutex_lock(&f->lock);
|
||||
node = __get_node(f, nodeid);
|
||||
node = get_node_nocheck(f, nodeid);
|
||||
if (node && node->version == version && nodeid != FUSE_ROOT_ID) {
|
||||
unhash_name(f, node);
|
||||
unhash_id(f, node);
|
||||
@ -365,7 +348,7 @@ static void remove_node(struct fuse *f, nodeid_t dir, const char *name)
|
||||
struct node *node;
|
||||
|
||||
pthread_mutex_lock(&f->lock);
|
||||
node = __lookup_node(f, dir, name);
|
||||
node = lookup_node(f, dir, name);
|
||||
if (node == NULL) {
|
||||
fprintf(stderr, "fuse internal error: unable to remove node %lu/%s\n",
|
||||
dir, name);
|
||||
@ -383,8 +366,8 @@ static int rename_node(struct fuse *f, nodeid_t olddir, const char *oldname,
|
||||
int err = 0;
|
||||
|
||||
pthread_mutex_lock(&f->lock);
|
||||
node = __lookup_node(f, olddir, oldname);
|
||||
newnode = __lookup_node(f, newdir, newname);
|
||||
node = lookup_node(f, olddir, oldname);
|
||||
newnode = lookup_node(f, newdir, newname);
|
||||
if (node == NULL) {
|
||||
fprintf(stderr, "fuse internal error: unable to rename node %lu/%s\n",
|
||||
olddir, oldname);
|
||||
@ -488,8 +471,8 @@ static int send_reply_raw(struct fuse *f, char *outbuf, size_t outsize,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __send_reply(struct fuse *f, struct fuse_in_header *in, int error,
|
||||
void *arg, size_t argsize, int locked)
|
||||
static int do_send_reply(struct fuse *f, struct fuse_in_header *in, int error,
|
||||
void *arg, size_t argsize, int locked)
|
||||
{
|
||||
int res;
|
||||
char *outbuf;
|
||||
@ -525,9 +508,15 @@ static int __send_reply(struct fuse *f, struct fuse_in_header *in, int error,
|
||||
}
|
||||
|
||||
static int send_reply(struct fuse *f, struct fuse_in_header *in, int error,
|
||||
void *arg, size_t argsize)
|
||||
void *arg, size_t argsize)
|
||||
{
|
||||
return __send_reply(f, in, error, arg, argsize, 0);
|
||||
return do_send_reply(f, in, error, arg, argsize, 0);
|
||||
}
|
||||
|
||||
static int send_reply_locked(struct fuse *f, struct fuse_in_header *in,
|
||||
int error, void *arg, size_t argsize)
|
||||
{
|
||||
return do_send_reply(f, in, error, arg, argsize, 1);
|
||||
}
|
||||
|
||||
static int is_open(struct fuse *f, nodeid_t dir, const char *name)
|
||||
@ -535,7 +524,7 @@ static int is_open(struct fuse *f, nodeid_t dir, const char *name)
|
||||
struct node *node;
|
||||
int isopen = 0;
|
||||
pthread_mutex_lock(&f->lock);
|
||||
node = __lookup_node(f, dir, name);
|
||||
node = lookup_node(f, dir, name);
|
||||
if (node && node->open_count > 0)
|
||||
isopen = 1;
|
||||
pthread_mutex_unlock(&f->lock);
|
||||
@ -556,13 +545,18 @@ static char *hidden_name(struct fuse *f, nodeid_t dir, const char *oldname,
|
||||
return NULL;
|
||||
|
||||
do {
|
||||
node = lookup_node(f, dir, oldname);
|
||||
pthread_mutex_lock(&f->lock);
|
||||
node = lookup_node(f, dir, oldname);
|
||||
if (node == NULL) {
|
||||
fprintf(stderr, "fuse internal error: node %lu/%s not found\n",
|
||||
dir, oldname);
|
||||
abort();
|
||||
}
|
||||
do {
|
||||
f->hidectr ++;
|
||||
snprintf(newname, bufsize, ".fuse_hidden%08x%08x",
|
||||
(unsigned int) node->nodeid, f->hidectr);
|
||||
newnode = __lookup_node(f, dir, newname);
|
||||
newnode = lookup_node(f, dir, newname);
|
||||
} while(newnode);
|
||||
pthread_mutex_unlock(&f->lock);
|
||||
|
||||
@ -1089,7 +1083,7 @@ static void do_open(struct fuse *f, struct fuse_in_header *in,
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
res2 = __send_reply(f, in, res, &outarg, sizeof(outarg), 1);
|
||||
res2 = send_reply_locked(f, in, res, &outarg, sizeof(outarg));
|
||||
if(res2 == -ENOENT) {
|
||||
/* The open syscall was interrupted, so it must be cancelled */
|
||||
if(f->op.release.curr) {
|
||||
@ -1266,7 +1260,7 @@ static int default_statfs(struct statfs *buf)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void convert_statfs_compat(struct _fuse_statfs_compat1 *compatbuf,
|
||||
static void convert_statfs_compat(struct fuse_statfs_compat1 *compatbuf,
|
||||
struct statfs *statfs)
|
||||
{
|
||||
statfs->f_bsize = compatbuf->block_size;
|
||||
@ -1300,8 +1294,8 @@ static void do_statfs(struct fuse *f, struct fuse_in_header *in)
|
||||
if (!f->compat || f->compat > 11)
|
||||
res = f->op.statfs.curr("/", &buf);
|
||||
else {
|
||||
struct _fuse_statfs_compat1 compatbuf;
|
||||
memset(&compatbuf, 0, sizeof(struct _fuse_statfs_compat1));
|
||||
struct fuse_statfs_compat1 compatbuf;
|
||||
memset(&compatbuf, 0, sizeof(struct fuse_statfs_compat1));
|
||||
res = f->op.statfs.compat1(&compatbuf);
|
||||
if (res == 0)
|
||||
convert_statfs_compat(&compatbuf, &buf);
|
||||
@ -1517,7 +1511,7 @@ static void free_cmd(struct fuse_cmd *cmd)
|
||||
free(cmd);
|
||||
}
|
||||
|
||||
void __fuse_process_cmd(struct fuse *f, struct fuse_cmd *cmd)
|
||||
void fuse_process_cmd(struct fuse *f, struct fuse_cmd *cmd)
|
||||
{
|
||||
struct fuse_in_header *in = (struct fuse_in_header *) cmd->buf;
|
||||
void *inarg = cmd->buf + sizeof(struct fuse_in_header);
|
||||
@ -1641,12 +1635,12 @@ void __fuse_process_cmd(struct fuse *f, struct fuse_cmd *cmd)
|
||||
free_cmd(cmd);
|
||||
}
|
||||
|
||||
int __fuse_exited(struct fuse* f)
|
||||
int fuse_exited(struct fuse* f)
|
||||
{
|
||||
return f->exited;
|
||||
}
|
||||
|
||||
struct fuse_cmd *__fuse_read_cmd(struct fuse *f)
|
||||
struct fuse_cmd *fuse_read_cmd(struct fuse *f)
|
||||
{
|
||||
ssize_t res;
|
||||
struct fuse_cmd *cmd;
|
||||
@ -1670,7 +1664,7 @@ struct fuse_cmd *__fuse_read_cmd(struct fuse *f)
|
||||
res = read(f->fd, cmd->buf, FUSE_MAX_IN);
|
||||
if (res == -1) {
|
||||
free_cmd(cmd);
|
||||
if (__fuse_exited(f) || errno == EINTR)
|
||||
if (fuse_exited(f) || errno == EINTR)
|
||||
return NULL;
|
||||
|
||||
/* ENODEV means we got unmounted, so we silenty return failure */
|
||||
@ -1709,14 +1703,14 @@ int fuse_loop(struct fuse *f)
|
||||
while (1) {
|
||||
struct fuse_cmd *cmd;
|
||||
|
||||
if (__fuse_exited(f))
|
||||
if (fuse_exited(f))
|
||||
break;
|
||||
|
||||
cmd = __fuse_read_cmd(f);
|
||||
cmd = fuse_read_cmd(f);
|
||||
if (cmd == NULL)
|
||||
continue;
|
||||
|
||||
__fuse_process_cmd(f, cmd);
|
||||
fuse_process_cmd(f, cmd);
|
||||
}
|
||||
f->exited = 0;
|
||||
return 0;
|
||||
@ -1772,7 +1766,7 @@ struct fuse_context *fuse_get_context()
|
||||
return &context;
|
||||
}
|
||||
|
||||
void __fuse_set_getcontext_func(struct fuse_context *(*func)(void))
|
||||
void fuse_set_getcontext_func(struct fuse_context *(*func)(void))
|
||||
{
|
||||
fuse_getcontext = func;
|
||||
}
|
||||
@ -1944,21 +1938,21 @@ struct fuse *fuse_new(int fd, const char *opts,
|
||||
return fuse_new_common(fd, opts, op, op_size, 0);
|
||||
}
|
||||
|
||||
struct fuse *_fuse_new_compat2(int fd, const char *opts,
|
||||
const struct _fuse_operations_compat2 *op)
|
||||
struct fuse *fuse_new_compat2(int fd, const char *opts,
|
||||
const struct fuse_operations_compat2 *op)
|
||||
{
|
||||
return fuse_new_common(fd, opts, (struct fuse_operations *) op,
|
||||
sizeof(struct _fuse_operations_compat2), 21);
|
||||
sizeof(struct fuse_operations_compat2), 21);
|
||||
}
|
||||
|
||||
struct fuse *_fuse_new_compat1(int fd, int flags,
|
||||
const struct _fuse_operations_compat1 *op)
|
||||
struct fuse *fuse_new_compat1(int fd, int flags,
|
||||
const struct fuse_operations_compat1 *op)
|
||||
{
|
||||
char *opts = NULL;
|
||||
if (flags & _FUSE_DEBUG_COMPAT1)
|
||||
if (flags & FUSE_DEBUG_COMPAT1)
|
||||
opts = "debug";
|
||||
return fuse_new_common(fd, opts, (struct fuse_operations *) op,
|
||||
sizeof(struct _fuse_operations_compat1), 11);
|
||||
sizeof(struct fuse_operations_compat1), 11);
|
||||
}
|
||||
|
||||
void fuse_destroy(struct fuse *f)
|
||||
@ -1990,4 +1984,8 @@ void fuse_destroy(struct fuse *f)
|
||||
free(f);
|
||||
}
|
||||
|
||||
__asm__(".symver _fuse_new_compat2,fuse_new@");
|
||||
__asm__(".symver fuse_exited,__fuse_exited@");
|
||||
__asm__(".symver fuse_process_cmd,__fuse_process_cmd@");
|
||||
__asm__(".symver fuse_read_cmd,__fuse_read_cmd@");
|
||||
__asm__(".symver fuse_set_getcontext_func,__fuse_set_getcontext_func@");
|
||||
__asm__(".symver fuse_new_compat2,fuse_new@");
|
||||
|
@ -66,7 +66,7 @@ struct fuse_operations_i {
|
||||
struct fuse_file_info *);
|
||||
union {
|
||||
int (*curr) (const char *, struct statfs *);
|
||||
int (*compat1) (struct _fuse_statfs_compat1 *);
|
||||
int (*compat1) (struct fuse_statfs_compat1 *);
|
||||
} statfs;
|
||||
int (*flush) (const char *, struct fuse_file_info *);
|
||||
union {
|
||||
|
@ -53,10 +53,10 @@ static void *do_work(void *data)
|
||||
while (1) {
|
||||
struct fuse_cmd *cmd;
|
||||
|
||||
if (__fuse_exited(f))
|
||||
if (fuse_exited(f))
|
||||
break;
|
||||
|
||||
cmd = __fuse_read_cmd(w->f);
|
||||
cmd = fuse_read_cmd(w->f);
|
||||
if (cmd == NULL)
|
||||
continue;
|
||||
|
||||
@ -131,7 +131,7 @@ static int mt_create_context_key()
|
||||
fprintf(stderr, "fuse: failed to create thread specific key: %s\n",
|
||||
strerror(err));
|
||||
else
|
||||
__fuse_set_getcontext_func(mt_getcontext);
|
||||
fuse_set_getcontext_func(mt_getcontext);
|
||||
}
|
||||
if (!err)
|
||||
context_ref ++;
|
||||
@ -144,13 +144,13 @@ static void mt_delete_context_key()
|
||||
pthread_mutex_lock(&context_lock);
|
||||
context_ref--;
|
||||
if (!context_ref) {
|
||||
__fuse_set_getcontext_func(NULL);
|
||||
fuse_set_getcontext_func(NULL);
|
||||
pthread_key_delete(context_key);
|
||||
}
|
||||
pthread_mutex_unlock(&context_lock);
|
||||
}
|
||||
|
||||
int __fuse_loop_mt(struct fuse *f, fuse_processor_t proc, void *data)
|
||||
int fuse_loop_mt_proc(struct fuse *f, fuse_processor_t proc, void *data)
|
||||
{
|
||||
struct fuse_worker *w;
|
||||
int i;
|
||||
@ -187,5 +187,7 @@ int fuse_loop_mt(struct fuse *f)
|
||||
if (f == NULL)
|
||||
return -1;
|
||||
|
||||
return __fuse_loop_mt(f, (fuse_processor_t) __fuse_process_cmd, NULL);
|
||||
return fuse_loop_mt_proc(f, (fuse_processor_t) fuse_process_cmd, NULL);
|
||||
}
|
||||
|
||||
__asm__(".symver fuse_loop_mt_proc,__fuse_loop_mt@");
|
||||
|
@ -1,28 +1,28 @@
|
||||
FUSE_2.2 {
|
||||
global:
|
||||
__fuse_exited;
|
||||
__fuse_loop_mt;
|
||||
__fuse_main;
|
||||
__fuse_process_cmd;
|
||||
__fuse_read_cmd;
|
||||
__fuse_set_getcontext_func;
|
||||
__fuse_setup;
|
||||
__fuse_teardown;
|
||||
_fuse_setup_compat2;
|
||||
_fuse_main_compat1;
|
||||
_fuse_main_compat2;
|
||||
_fuse_mount_compat1;
|
||||
_fuse_new_compat1;
|
||||
_fuse_new_compat2;
|
||||
fuse_destroy;
|
||||
fuse_exit;
|
||||
fuse_exited;
|
||||
fuse_get_context;
|
||||
fuse_invalidate;
|
||||
fuse_is_lib_option;
|
||||
fuse_loop;
|
||||
fuse_loop_mt;
|
||||
fuse_loop_mt_proc;
|
||||
fuse_main_compat1;
|
||||
fuse_main_compat2;
|
||||
fuse_main_real;
|
||||
fuse_mount;
|
||||
fuse_mount_compat1;
|
||||
fuse_new;
|
||||
fuse_new_compat1;
|
||||
fuse_new_compat2;
|
||||
fuse_process_cmd;
|
||||
fuse_read_cmd;
|
||||
fuse_set_getcontext_func;
|
||||
fuse_setup;
|
||||
fuse_setup_compat2;
|
||||
fuse_teardown;
|
||||
fuse_unmount;
|
||||
local:
|
||||
*;
|
||||
|
37
lib/helper.c
37
lib/helper.c
@ -268,7 +268,7 @@ static struct fuse *fuse_setup_common(int argc, char *argv[],
|
||||
int res;
|
||||
|
||||
if (fuse_instance != NULL) {
|
||||
fprintf(stderr, "fuse: __fuse_setup() called twice\n");
|
||||
fprintf(stderr, "fuse: fuse_setup() called twice\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -314,7 +314,7 @@ static struct fuse *fuse_setup_common(int argc, char *argv[],
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct fuse *__fuse_setup(int argc, char *argv[],
|
||||
struct fuse *fuse_setup(int argc, char *argv[],
|
||||
const struct fuse_operations *op,
|
||||
size_t op_size, char **mountpoint,
|
||||
int *multithreaded, int *fd)
|
||||
@ -323,20 +323,20 @@ struct fuse *__fuse_setup(int argc, char *argv[],
|
||||
multithreaded, fd, 0);
|
||||
}
|
||||
|
||||
struct fuse *_fuse_setup_compat2(int argc, char *argv[],
|
||||
const struct _fuse_operations_compat2 *op,
|
||||
struct fuse *fuse_setup_compat2(int argc, char *argv[],
|
||||
const struct fuse_operations_compat2 *op,
|
||||
char **mountpoint, int *multithreaded,
|
||||
int *fd)
|
||||
{
|
||||
return fuse_setup_common(argc, argv, (struct fuse_operations *) op,
|
||||
sizeof(struct _fuse_operations_compat2),
|
||||
sizeof(struct fuse_operations_compat2),
|
||||
mountpoint, multithreaded, fd, 21);
|
||||
}
|
||||
|
||||
void __fuse_teardown(struct fuse *fuse, int fd, char *mountpoint)
|
||||
void fuse_teardown(struct fuse *fuse, int fd, char *mountpoint)
|
||||
{
|
||||
if (fuse_instance != fuse)
|
||||
fprintf(stderr, "fuse: __fuse_teardown() with unknown fuse object\n");
|
||||
fprintf(stderr, "fuse: fuse_teardown() with unknown fuse object\n");
|
||||
else
|
||||
fuse_instance = NULL;
|
||||
|
||||
@ -366,32 +366,33 @@ static int fuse_main_common(int argc, char *argv[],
|
||||
else
|
||||
res = fuse_loop(fuse);
|
||||
|
||||
__fuse_teardown(fuse, fd, mountpoint);
|
||||
fuse_teardown(fuse, fd, mountpoint);
|
||||
if (res == -1)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __fuse_main(int argc, char *argv[], const struct fuse_operations *op,
|
||||
size_t op_size)
|
||||
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, 0);
|
||||
}
|
||||
|
||||
void _fuse_main_compat1(int argc, char *argv[],
|
||||
const struct _fuse_operations_compat1 *op)
|
||||
void fuse_main_compat1(int argc, char *argv[],
|
||||
const struct fuse_operations_compat1 *op)
|
||||
{
|
||||
fuse_main_common(argc, argv, (struct fuse_operations *) op,
|
||||
sizeof(struct _fuse_operations_compat1), 11);
|
||||
sizeof(struct fuse_operations_compat1), 11);
|
||||
}
|
||||
|
||||
int _fuse_main_compat2(int argc, char *argv[],
|
||||
const struct _fuse_operations_compat2 *op)
|
||||
int fuse_main_compat2(int argc, char *argv[],
|
||||
const struct fuse_operations_compat2 *op)
|
||||
{
|
||||
return fuse_main_common(argc, argv, (struct fuse_operations *) op,
|
||||
sizeof(struct _fuse_operations_compat2), 21);
|
||||
sizeof(struct fuse_operations_compat2), 21);
|
||||
}
|
||||
|
||||
__asm__(".symver _fuse_setup_compat2,__fuse_setup@");
|
||||
__asm__(".symver _fuse_main_compat2,fuse_main@");
|
||||
__asm__(".symver fuse_setup_compat2,__fuse_setup@");
|
||||
__asm__(".symver fuse_teardown,__fuse_teardown@");
|
||||
__asm__(".symver fuse_main_compat2,fuse_main@");
|
||||
|
@ -126,7 +126,7 @@ int fuse_mount(const char *mountpoint, const char *opts)
|
||||
return rv;
|
||||
}
|
||||
|
||||
int _fuse_mount_compat1(const char *mountpoint, const char *args[])
|
||||
int fuse_mount_compat1(const char *mountpoint, const char *args[])
|
||||
{
|
||||
/* just ignore mount args for now */
|
||||
(void) args;
|
||||
|
@ -63,12 +63,12 @@ for this program. And anyway what's all this fuss about versioning the
|
||||
kernel interface? It is quite good as is. */
|
||||
#define _LINUX_CAPABILITY_VERSION 0x19980330
|
||||
|
||||
typedef struct __user_cap_header_struct {
|
||||
typedef struct user_cap_header_struct {
|
||||
unsigned int version;
|
||||
int pid;
|
||||
} *cap_user_header_t;
|
||||
|
||||
typedef struct __user_cap_data_struct {
|
||||
typedef struct user_cap_data_struct {
|
||||
unsigned int effective;
|
||||
unsigned int permitted;
|
||||
unsigned int inheritable;
|
||||
@ -81,13 +81,13 @@ int capset(cap_user_header_t header, cap_user_data_t data);
|
||||
|
||||
static uid_t oldfsuid;
|
||||
static gid_t oldfsgid;
|
||||
static struct __user_cap_data_struct oldcaps;
|
||||
static struct user_cap_data_struct oldcaps;
|
||||
|
||||
static int drop_privs(void)
|
||||
{
|
||||
int res;
|
||||
struct __user_cap_header_struct head;
|
||||
struct __user_cap_data_struct newcaps;
|
||||
struct user_cap_header_struct head;
|
||||
struct user_cap_data_struct newcaps;
|
||||
|
||||
head.version = _LINUX_CAPABILITY_VERSION;
|
||||
head.pid = 0;
|
||||
@ -119,7 +119,7 @@ static int drop_privs(void)
|
||||
|
||||
static void restore_privs(void)
|
||||
{
|
||||
struct __user_cap_header_struct head;
|
||||
struct user_cap_header_struct head;
|
||||
int res;
|
||||
|
||||
head.version = _LINUX_CAPABILITY_VERSION;
|
||||
|
Loading…
Reference in New Issue
Block a user