* 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
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 *
*
* 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... *
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 *
#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
/* 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 *);
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;
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 *);
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);
}
}
-
static inline void dec_avail(struct fuse *f)
{
pthread_mutex_lock(&f->lock);
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;
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;
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;
}
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);
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)
{
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)) {
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;
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);
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);
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);
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;
}
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 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 __send_reply(f, in, error, arg, argsize, 0);
+ return do_send_reply(f, in, error, arg, argsize, 1);
}
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);
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);
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) {
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;
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);
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);
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;
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 */
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;
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;
}
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)
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@");
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 {
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;
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 ++;
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;
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@");
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:
*;
int res;
if (fuse_instance != NULL) {
- fprintf(stderr, "fuse: __fuse_setup() called twice\n");
+ fprintf(stderr, "fuse: fuse_setup() called twice\n");
return NULL;
}
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)
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;
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@");
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;
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;
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;
static void restore_privs(void)
{
- struct __user_cap_header_struct head;
+ struct user_cap_header_struct head;
int res;
head.version = _LINUX_CAPABILITY_VERSION;