summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPino Toscano <toscano.pino@tiscali.it>2013-03-22 16:25:10 +0100
committerPino Toscano <toscano.pino@tiscali.it>2013-03-22 16:25:10 +0100
commit70bf9589f3718ee6162eb7f0320f44a743b80b6d (patch)
treee0d32cededd86db23f169af466b2efd51be8754f
parentdefdeff585f61dbc7cff2ea6cfa5cfc66288b6a5 (diff)
Remove support for FUSE compatibility < 25
While the default FUSE_USE_VERSION is 21, compatibility versions below 25 are rarely (if at all) used; keeping support for them is not worth, especially than they require a number of special casings all around (different fuse_operations and fuse_file_info). * src/fuse_i.h (fuse_ops_compat22, fuse_ops_compat2): Remove. (FUSE_OP_HAVE, FUSE_OP_CALL): Use only fuse_ops25. (FUSE_OP_HAVE22, FUSE_OP_CALL22): Remove. (NN_INFO, NN_INFO_APPLY): Use only info25. (struct netnode): Remove field 'compat22' in field union 'info'. * src/main.c (fuse_ops_compat22, fuse_ops_compat2, fuse_main_compat2) (fuse_main_compat2, fuse_main_real_compat22, fuse_new_compat2) (fuse_new_compat22, fuse_mount_compat22): Remove. * src/netfs.c (netfs_attempt_statfs, netfs_attempt_sync, netfs_attempt_write) (netfs_attempt_read, fuse_get_inode, get_dirents_getdir, get_dirents_readdir) (netfs_get_dirents): Use only FUSE_OP_CALL and FUSE_OP_HAVE. (get_dirents_getdir_helper_compat): Remove. * src/netnode.c (fuse_sync_filesystem): Use only FUSE_OP_CALL and NN_INFO.
-rw-r--r--src/fuse_i.h38
-rw-r--r--src/main.c87
-rw-r--r--src/netfs.c146
-rw-r--r--src/netnode.c7
4 files changed, 37 insertions, 241 deletions
diff --git a/src/fuse_i.h b/src/fuse_i.h
index 399b09437..f4d49faca 100644
--- a/src/fuse_i.h
+++ b/src/fuse_i.h
@@ -30,39 +30,14 @@
__LINE__)
/* pointer to the fuse_operations structure of this translator process */
-extern const struct fuse_operations_compat22 *fuse_ops_compat22;
-extern const struct fuse_operations_compat2 *fuse_ops_compat2;
extern const struct fuse_operations *fuse_ops25;
-#define FUSE_OP_HAVE(a) (fuse_ops25 ? \
- (fuse_ops25->a != NULL) \
- : ((fuse_ops_compat22) ? \
- (fuse_ops_compat22->a != NULL) : \
- (fuse_ops_compat2->a != NULL)))
-#define FUSE_OP_CALL(a,b...) (fuse_ops25 ? \
- (fuse_ops25->a(b)) : \
- ((fuse_ops_compat22) ? \
- (fuse_ops_compat22->a(b)) : \
- (fuse_ops_compat2->a(b))))
-
-#define FUSE_OP_HAVE22(a) (fuse_ops25 ? \
- (fuse_ops25->a != NULL) \
- : ((fuse_ops_compat22) ? \
- (fuse_ops_compat22->a != NULL) : 0))
-
-#define FUSE_OP_CALL22(a,b...) (fuse_ops25 ? \
- (fuse_ops25->a(b)) : \
- ((fuse_ops_compat22) ? \
- (fuse_ops_compat22->a(b)) : (0)))
-
-#define NN_INFO(dir) (fuse_ops25 ? \
- ((void *) &(dir)->nn->info.info25) \
- : ((void *) &(dir)->nn->info.compat22))
-
-#define NN_INFO_APPLY(node,key) do { \
- if(fuse_ops25) (node)->nn->info.info25.key; \
- else (node)->nn->info.compat22.key; \
- } while(0)
+#define FUSE_OP_HAVE(a) (fuse_ops25->a != NULL)
+#define FUSE_OP_CALL(a,b...) (fuse_ops25->a(b))
+
+#define NN_INFO(dir) ((void *) &(dir)->nn->info.info25)
+
+#define NN_INFO_APPLY(node,key) (node)->nn->info.info25.key
extern __thread struct fuse_context *libfuse_ctx;
@@ -83,7 +58,6 @@ struct netnode {
/* information about the opened file
*/
union {
- struct fuse_file_info_compat22 compat22;
struct fuse_file_info info25;
} info;
diff --git a/src/main.c b/src/main.c
index e9a402f7d..d6e082f89 100644
--- a/src/main.c
+++ b/src/main.c
@@ -33,8 +33,6 @@ int netfs_maxsymlinks = 12;
struct _libfuse_params libfuse_params = { 0 };
/* pointer to the fuse_operations structure of this translator process */
-const struct fuse_operations_compat22 *fuse_ops_compat22 = NULL;
-const struct fuse_operations_compat2 *fuse_ops_compat2 = NULL;
const struct fuse_operations *fuse_ops25 = NULL;
__thread struct fuse_context *libfuse_ctx;
@@ -249,35 +247,6 @@ fuse_parse_argv(int argc, char *argv[])
-/* Main function of FUSE. (compatibility one for old Fuse API) */
-int
-fuse_main_compat2(int argc, char *argv[],
- const struct fuse_operations_compat2 *op)
-{
- fuse_parse_argv(argc, argv);
-
- int fd = fuse_mount_compat22(argv[0], NULL);
- return (libfuse_params.disable_mt ? fuse_loop : fuse_loop_mt)
- (fuse_new_compat2(fd, NULL, op));
-}
-
-
-
-/* Main function of FUSE.
- * named fuse_main_real, since originial fuse.h defines a macro renaming it */
-int
-fuse_main_real_compat22(int argc, char *argv[],
- const struct fuse_operations_compat22 *op,
- size_t op_size)
-{
- fuse_parse_argv(argc, argv);
-
- int fd = fuse_mount_compat22(argv[0], NULL);
- return (libfuse_params.disable_mt ? fuse_loop : fuse_loop_mt)
- (fuse_new_compat22(fd, NULL, op, op_size));
-}
-
-
int
fuse_main_real(int argc, char *argv[], const struct fuse_operations *op,
size_t op_size)
@@ -299,28 +268,6 @@ int fuse_main(void)
/* Create a new FUSE filesystem, actually there's nothing for us to do
- * on the Hurd.
- *
- * (Compatibility function for the old Fuse API)
- */
-struct fuse *
-fuse_new_compat2(int fd, const char *opts,
- const struct fuse_operations_compat2 *op)
-{
- if(fd != FUSE_MAGIC)
- return NULL;
-
- if(fuse_parse_opts(opts))
- return NULL;
-
- fuse_ops_compat2 = op;
-
- return (void *) FUSE_MAGIC; /* we don't have a fuse structure, sorry. */
-}
-
-
-
-/* Create a new FUSE filesystem, actually there's nothing for us to do
* on the Hurd. Hmm.
*/
struct fuse *
@@ -350,31 +297,6 @@ fuse_new(int fd, struct fuse_args *args,
}
-/* Create a new FUSE filesystem, actually there's nothing for us to do
- * on the Hurd.
- */
-struct fuse *
-fuse_new_compat22(int fd, const char *opts,
- const struct fuse_operations_compat22 *op, size_t op_size)
-{
- (void) op_size; /* FIXME, see what the real Fuse library does with
- * this argument */
-
- if(fd != FUSE_MAGIC)
- return NULL;
-
- if(fuse_parse_opts(opts))
- return NULL;
-
- fuse_ops_compat22 = op;
-
- if(op->init)
- fsys_privdata = op->init();
-
- return (void *) FUSE_MAGIC; /* we don't have a fuse structure, sorry. */
-}
-
-
/* Create a new mountpoint for our fuse filesystem, i.e. do the netfs
* initialization stuff ...
*/
@@ -393,15 +315,6 @@ fuse_mount(const char *mountpoint, struct fuse_args *args)
}
-int
-fuse_mount_compat22(const char *mountpoint, const char *opts)
-{
- if(fuse_parse_opts(opts))
- return 0;
-
- return fuse_bootstrap(mountpoint);
-}
-
static int
fuse_bootstrap(const char *mountpoint)
{
diff --git a/src/netfs.c b/src/netfs.c
index 88ae22742..f8d0d3973 100644
--- a/src/netfs.c
+++ b/src/netfs.c
@@ -315,13 +315,13 @@ netfs_attempt_statfs (struct iouser *cred, struct node *node,
else if(FUSE_OP_HAVE(statfs))
{
+ struct statvfs stvfs;
+
refresh_context_struct(cred);
+ err = -FUSE_OP_CALL(statfs, node->nn->path, &stvfs);
- if(fuse_ops25)
+ if(! err)
{
- struct statvfs stvfs;
- err = -fuse_ops25->statfs(node->nn->path, &stvfs);
-
st->f_type = stvfs.__f_type;
st->f_bsize = stvfs.f_bsize;
st->f_blocks = stvfs.f_blocks;
@@ -335,15 +335,6 @@ netfs_attempt_statfs (struct iouser *cred, struct node *node,
st->f_frsize = stvfs.f_frsize;
st->f_flag = stvfs.f_flag;
}
-
- else if(fuse_ops_compat22)
- err = -fuse_ops_compat22->statfs(node->nn->path, st);
-
- else if(fuse_ops_compat2)
- err = -fuse_ops_compat2->statfs(node->nn->path, st);
-
- else
- assert(0);
}
else
@@ -590,15 +581,8 @@ netfs_attempt_sync (struct iouser *cred, struct node *node, int wait)
goto out;
}
- if(FUSE_OP_HAVE22(fsync))
- err = -FUSE_OP_CALL22(fsync, node->nn->path, 0, NN_INFO(node));
-
- else if(fuse_ops_compat2)
- err = -fuse_ops_compat2->fsync(node->nn->path, 0);
+ err = -FUSE_OP_CALL(fsync, node->nn->path, 0, NN_INFO(node));
- else
- assert(0);
-
if(! err)
node->nn->may_need_sync = 0;
@@ -1097,29 +1081,13 @@ error_t netfs_attempt_write (struct iouser *cred, struct node *node,
if(FUSE_OP_HAVE(open))
{
- if(FUSE_OP_HAVE22(open))
- err = FUSE_OP_CALL22(open, node->nn->path, NN_INFO(node));
-
- else if(fuse_ops_compat2)
- err = fuse_ops_compat2->open(node->nn->path,
- node->nn->info.compat22.flags);
-
- else
- assert(0);
+ err = FUSE_OP_CALL(open, node->nn->path, NN_INFO(node));
if(err) goto out;
}
- int sz;
- if(FUSE_OP_HAVE22(write))
- sz = FUSE_OP_CALL22(write, node->nn->path, data, *len, offset,
+ int sz = FUSE_OP_CALL(write, node->nn->path, data, *len, offset,
NN_INFO(node));
-
- else if(fuse_ops_compat2)
- sz = fuse_ops_compat2->write(node->nn->path, data, *len, offset);
-
- else
- assert(0);
/* FIXME: open, flush and release handling probably should be changed
* completely, I mean, we probably should do fuse_ops->open in
@@ -1128,21 +1096,11 @@ error_t netfs_attempt_write (struct iouser *cred, struct node *node,
*
* This way we wouldn't be able to report any errors back.
*/
- if(sz >= 0 && FUSE_OP_HAVE22(flush))
- err = FUSE_OP_CALL22(flush, node->nn->path, NN_INFO(node));
+ if(sz >= 0 && FUSE_OP_HAVE(flush))
+ err = FUSE_OP_CALL(flush, node->nn->path, NN_INFO(node));
if(FUSE_OP_HAVE(open) && FUSE_OP_HAVE(release))
- {
- if(FUSE_OP_HAVE22(release))
- FUSE_OP_CALL22(release, node->nn->path, NN_INFO(node));
-
- else if(fuse_ops_compat2)
- fuse_ops_compat2->release(node->nn->path,
- node->nn->info.compat22.flags);
-
- else
- assert(0);
- }
+ FUSE_OP_CALL(release, node->nn->path, NN_INFO(node));
if(sz < 0)
err = -sz;
@@ -1222,30 +1180,14 @@ error_t netfs_attempt_read (struct iouser *cred, struct node *node,
if(FUSE_OP_HAVE(open))
{
- if(FUSE_OP_HAVE22(open))
- err = FUSE_OP_CALL22(open, node->nn->path, NN_INFO(node));
-
- else if(fuse_ops_compat2)
- err = fuse_ops_compat2->open(node->nn->path,
- node->nn->info.compat22.flags);
-
- else
- assert(0);
+ err = FUSE_OP_CALL(open, node->nn->path, NN_INFO(node));
if(err) goto out;
}
- int sz;
- if(FUSE_OP_HAVE22(read))
- sz = FUSE_OP_CALL22(read, node->nn->path, data, *len, offset,
+ int sz = FUSE_OP_CALL(read, node->nn->path, data, *len, offset,
NN_INFO(node));
- else if(fuse_ops_compat2)
- sz = fuse_ops_compat2->read(node->nn->path, data, *len, offset);
-
- else
- assert(0);
-
/* FIXME: open, flush and release handling probably should be changed
* completely, I mean, we probably should do fuse_ops->open in
* the netfs_check_open_permissions function and leave it open
@@ -1253,21 +1195,11 @@ error_t netfs_attempt_read (struct iouser *cred, struct node *node,
*
* This way we wouldn't be able to report any errors back.
*/
- if(sz >= 0 && FUSE_OP_HAVE22(flush))
- err = FUSE_OP_CALL22(flush, node->nn->path, NN_INFO(node));
+ if(sz >= 0 && FUSE_OP_HAVE(flush))
+ err = FUSE_OP_CALL(flush, node->nn->path, NN_INFO(node));
if(FUSE_OP_HAVE(open) && FUSE_OP_HAVE(release))
- {
- if(FUSE_OP_HAVE22(release))
- FUSE_OP_CALL22(release, node->nn->path, NN_INFO(node));
-
- else if(fuse_ops_compat2)
- fuse_ops_compat2->release(node->nn->path,
- node->nn->info.compat22.flags);
-
- else
- assert(0);
- }
+ FUSE_OP_CALL(release, node->nn->path, NN_INFO(node));
if(sz < 0)
err = -sz;
@@ -1304,8 +1236,8 @@ fuse_get_inode(const char *name)
{
struct stat stat;
- assert(FUSE_OP_HAVE22(getattr));
- FUSE_OP_CALL22(getattr, name, &stat);
+ assert(FUSE_OP_HAVE(getattr));
+ FUSE_OP_CALL(getattr, name, &stat);
return stat.st_ino;
}
@@ -1406,18 +1338,6 @@ get_dirents_getdir_helper(fuse_dirh_t handle, const char *name,
}
-/* callback handler used by netfs_get_dirents to write our dirents
- * to the mmaped memory
- *
- * version for old api
- */
-static int
-get_dirents_getdir_helper_compat(fuse_dirh_t hdl, const char *name, int type)
-{
- return get_dirents_getdir_helper(hdl, name, type, 0);
-}
-
-
static error_t
get_dirents_getdir(struct node *dir, int first_entry, int num_entries,
char **data, mach_msg_type_number_t *data_len,
@@ -1455,15 +1375,7 @@ get_dirents_getdir(struct node *dir, int first_entry, int num_entries,
handle->parent = dir->nn;
handle->hdrpos = (struct dirent*) *data;
- if(FUSE_OP_HAVE22(getdir))
- FUSE_OP_CALL22(getdir, dir->nn->path, handle, get_dirents_getdir_helper);
-
- else if(fuse_ops_compat2)
- fuse_ops_compat2->getdir(dir->nn->path, handle,
- get_dirents_getdir_helper_compat);
-
- else
- assert(0);
+ FUSE_OP_CALL(getdir, dir->nn->path, handle, get_dirents_getdir_helper);
*data_len -= handle->size; /* subtract number of bytes left in the
* buffer from the length of the buffer we
@@ -1591,7 +1503,7 @@ get_dirents_readdir(struct node *dir, int first_entry, int num_entries,
error_t err;
FUNC_PROLOGUE_NODE("get_dirents_readdir", dir);
- assert(FUSE_OP_HAVE22(readdir));
+ assert(FUSE_OP_HAVE(readdir));
fuse_dirh_t handle;
if(! (handle = malloc(sizeof(struct fuse_dirhandle))))
@@ -1620,21 +1532,21 @@ get_dirents_readdir(struct node *dir, int first_entry, int num_entries,
handle->parent = dir->nn;
handle->hdrpos = (struct dirent*) *data;
- if(FUSE_OP_HAVE22(opendir)
- && (err = FUSE_OP_CALL22(opendir, dir->nn->path, NN_INFO(dir))))
+ if(FUSE_OP_HAVE(opendir)
+ && (err = FUSE_OP_CALL(opendir, dir->nn->path, NN_INFO(dir))))
goto out;
- if((err = FUSE_OP_CALL22(readdir, dir->nn->path, handle,
- get_dirents_readdir_helper,
- first_entry, NN_INFO(dir))))
+ if((err = FUSE_OP_CALL(readdir, dir->nn->path, handle,
+ get_dirents_readdir_helper,
+ first_entry, NN_INFO(dir))))
{
- if(FUSE_OP_HAVE22(releasedir))
- FUSE_OP_CALL22(releasedir, dir->nn->path, NN_INFO(dir));
+ if(FUSE_OP_HAVE(releasedir))
+ FUSE_OP_CALL(releasedir, dir->nn->path, NN_INFO(dir));
goto out;
}
- if(FUSE_OP_HAVE22(releasedir)
- && (err = FUSE_OP_CALL22(releasedir, dir->nn->path, NN_INFO(dir))))
+ if(FUSE_OP_HAVE(releasedir)
+ && (err = FUSE_OP_CALL(releasedir, dir->nn->path, NN_INFO(dir))))
goto out;
*data_len -= handle->size; /* subtract number of bytes left in the
@@ -1668,7 +1580,7 @@ netfs_get_dirents (struct iouser *cred, struct node *dir,
goto out;
- if(FUSE_OP_HAVE22(readdir))
+ if(FUSE_OP_HAVE(readdir))
err = get_dirents_readdir(dir, first_entry, num_entries, data, data_len,
data_entries);
diff --git a/src/netnode.c b/src/netnode.c
index de2ffecb1..de2923ca5 100644
--- a/src/netnode.c
+++ b/src/netnode.c
@@ -154,11 +154,8 @@ fuse_sync_filesystem(void)
{
if(he->nn->may_need_sync)
{
- err = -(fuse_ops_compat22 ?
- fuse_ops_compat22->fsync(he->nn->path, 0,
- &he->nn->info.compat22) :
- fuse_ops_compat2->fsync(he->nn->path, 0));
-
+ err = -FUSE_OP_CALL(fsync, he->nn->path, 0,
+ NN_INFO(he));
if(err)
goto out;
else