summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStefan Siegl <stesie@brokenpipe.de>2006-04-13 22:52:47 +0000
committerStefan Siegl <stesie@brokenpipe.de>2006-04-13 22:52:47 +0000
commit5147e9e1b0e63b00b4fb7a04720da591a5f6c024 (patch)
treeadc11c0bff93d1fe5eb2bccc467ee044886fc1af /src
parentc2552b393a785f7ba9872215695ff3a22cbdfd5f (diff)
pulled in headers from fuse 2.5.3 and added examples. fuse_ops variable renamed to fuse_ops_compat22 (to make room for 2.5 api functions).
Diffstat (limited to 'src')
-rw-r--r--src/fuse_i.h20
-rw-r--r--src/main.c51
-rw-r--r--src/netfs.c90
-rw-r--r--src/netnode.c7
4 files changed, 104 insertions, 64 deletions
diff --git a/src/fuse_i.h b/src/fuse_i.h
index e6fd4e43e..81d46d405 100644
--- a/src/fuse_i.h
+++ b/src/fuse_i.h
@@ -17,7 +17,7 @@
#ifdef FUSE_USE_VERSION
# include "fuse.h"
#else
-# define FUSE_USE_VERSION 23
+# define FUSE_USE_VERSION 25
# include "fuse.h"
# include "fuse_compat.h"
#endif
@@ -30,13 +30,15 @@
__LINE__)
/* pointer to the fuse_operations structure of this translator process */
-extern const struct fuse_operations *fuse_ops;
-extern const struct fuse_operations_compat2 *fuse_ops_compat;
+extern const struct fuse_operations_compat22 *fuse_ops_compat22;
+extern const struct fuse_operations_compat2 *fuse_ops_compat2;
-#define FUSE_OP_HAVE(a) ((fuse_ops) ? \
- (fuse_ops->a != NULL) : (fuse_ops_compat->a != NULL))
-#define FUSE_OP_CALL(a,b...) ((fuse_ops) ? \
- (fuse_ops->a(b)) : (fuse_ops_compat->a(b)))
+#define FUSE_OP_HAVE(a) ((fuse_ops_compat22) ? \
+ (fuse_ops_compat22->a != NULL) : \
+ (fuse_ops_compat2->a != NULL))
+#define FUSE_OP_CALL(a,b...) ((fuse_ops_compat22) ? \
+ (fuse_ops_compat22->a(b)) : \
+ (fuse_ops_compat2->a(b)))
/*****************************************************************************
*** netnodes (in memory representation of libfuse's files or directories) ***
@@ -53,7 +55,9 @@ struct netnode {
/* information about the opened file
*/
- struct fuse_file_info info;
+ union {
+ struct fuse_file_info_compat22 compat22;
+ } info;
/* pointer to our parent's netnode, if any */
struct netnode *parent;
diff --git a/src/main.c b/src/main.c
index 291c795b1..c2ca44d88 100644
--- a/src/main.c
+++ b/src/main.c
@@ -32,8 +32,8 @@ int netfs_maxsymlinks = 12;
struct _libfuse_params libfuse_params = { 0 };
/* pointer to the fuse_operations structure of this translator process */
-const struct fuse_operations *fuse_ops = NULL;
-const struct fuse_operations_compat2 *fuse_ops_compat = NULL;
+const struct fuse_operations_compat22 *fuse_ops_compat22 = NULL;
+const struct fuse_operations_compat2 *fuse_ops_compat2 = NULL;
/* the port where to write out debug messages to, NULL to omit these */
FILE *debug_port = NULL;
@@ -230,7 +230,7 @@ fuse_main_compat2(int argc, char *argv[],
{
fuse_parse_argv(argc, argv);
- int fd = fuse_mount(NULL, NULL);
+ int fd = fuse_mount_compat22(NULL, NULL);
return (libfuse_params.disable_mt ? fuse_loop : fuse_loop_mt)
(fuse_new_compat2(fd, NULL, op));
}
@@ -240,17 +240,25 @@ fuse_main_compat2(int argc, char *argv[],
/* Main function of FUSE.
* named fuse_main_real, since originial fuse.h defines a macro renaming it */
int
-fuse_main_real(int argc, char *argv[],
- const struct fuse_operations *op, size_t op_size)
+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(NULL, NULL);
+ int fd = fuse_mount_compat22(NULL, NULL);
return (libfuse_params.disable_mt ? fuse_loop : fuse_loop_mt)
- (fuse_new(fd, NULL, op, op_size));
+ (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)
+{
+ assert(0);
+}
+
/* Create a new FUSE filesystem, actually there's nothing for us to do
* on the Hurd.
@@ -267,7 +275,7 @@ fuse_new_compat2(int fd, const char *opts,
if(fuse_parse_opts(opts))
return NULL;
- fuse_ops_compat = op;
+ fuse_ops_compat2 = op;
return (void *) FUSE_MAGIC; /* we don't have a fuse structure, sorry. */
}
@@ -275,12 +283,23 @@ fuse_new_compat2(int fd, const char *opts,
/* Create a new FUSE filesystem, actually there's nothing for us to do
- * on the Hurd.
+ * on the Hurd. Hmm.
*/
struct fuse *
-fuse_new(int fd, const char *opts,
+fuse_new(int fd, struct fuse_args *args,
const struct fuse_operations *op, size_t op_size)
{
+ assert(0);
+}
+
+
+/* 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 */
@@ -290,18 +309,24 @@ fuse_new(int fd, const char *opts,
if(fuse_parse_opts(opts))
return NULL;
- fuse_ops = op;
+ fuse_ops_compat22 = op;
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 ...
*/
int
-fuse_mount(const char *mountpoint, const char *opts)
+fuse_mount(const char *mountpoint, struct fuse_args *args)
+{
+ assert(0);
+}
+
+
+int
+fuse_mount_compat22(const char *mountpoint, const char *opts)
{
(void) mountpoint; /* we don't care for the specified mountpoint, as
* we need to be set up using settrans ... */
diff --git a/src/netfs.c b/src/netfs.c
index 0fdb5c4a6..dd6ca32e2 100644
--- a/src/netfs.c
+++ b/src/netfs.c
@@ -369,8 +369,8 @@ netfs_check_open_permissions (struct iouser *user, struct node *node,
* into memory. */
if(! err)
{
- node->nn->info.flags = flags;
- if(flags & O_EXEC) node->nn->info.flags |= O_RDONLY;
+ node->nn->info.compat22.flags = flags;
+ if(flags & O_EXEC) node->nn->info.compat22.flags |= O_RDONLY;
}
out:
@@ -510,10 +510,11 @@ netfs_attempt_sync (struct iouser *cred, struct node *node, int wait)
goto out;
}
- if(fuse_ops)
- err = -fuse_ops->fsync(node->nn->path, 0, &node->nn->info);
+ if(fuse_ops_compat22)
+ err = -fuse_ops_compat22->fsync(node->nn->path, 0,
+ &node->nn->info.compat22);
else
- err = -fuse_ops_compat->fsync(node->nn->path, 0);
+ err = -fuse_ops_compat2->fsync(node->nn->path, 0);
if(! err)
node->nn->may_need_sync = 0;
@@ -1009,15 +1010,17 @@ error_t netfs_attempt_write (struct iouser *cred, struct node *node,
goto out;
}
- node->nn->info.writepage = 0; /* cannot distinct on the Hurd :( */
+ node->nn->info.compat22.writepage = 0; /* cannot distinct on the Hurd :( */
- if(fuse_ops && fuse_ops->open)
- if((err = fuse_ops->open(node->nn->path, &node->nn->info)))
+ if(fuse_ops_compat22 && fuse_ops_compat22->open)
+ if((err = fuse_ops_compat22->open(node->nn->path,
+ &node->nn->info.compat22)))
goto out;
- int sz = fuse_ops ?
- (fuse_ops->write(node->nn->path, data, *len, offset, &node->nn->info)) :
- (fuse_ops_compat->write(node->nn->path, data, *len, offset));
+ int sz = fuse_ops_compat22 ?
+ (fuse_ops_compat22->write(node->nn->path, data, *len,
+ offset, &node->nn->info.compat22)) :
+ (fuse_ops_compat2->write(node->nn->path, data, *len, offset));
/* FIXME: open, flush and release handling probably should be changed
* completely, I mean, we probably should do fuse_ops->open in
@@ -1026,11 +1029,12 @@ 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_ops && fuse_ops->flush)
- err = fuse_ops->flush(node->nn->path, &node->nn->info);
+ if(sz >= 0 && fuse_ops_compat22 && fuse_ops_compat22->flush)
+ err = fuse_ops_compat22->flush(node->nn->path, &node->nn->info.compat22);
- if(fuse_ops && fuse_ops->open && fuse_ops->release)
- fuse_ops->release(node->nn->path, &node->nn->info);
+ if(fuse_ops_compat22 && fuse_ops_compat22->open
+ && fuse_ops_compat22->release)
+ fuse_ops_compat22->release(node->nn->path, &node->nn->info.compat22);
if(sz < 0)
err = -sz;
@@ -1108,13 +1112,15 @@ error_t netfs_attempt_read (struct iouser *cred, struct node *node,
goto out;
}
- if(fuse_ops && fuse_ops->open)
- if((err = fuse_ops->open(node->nn->path, &node->nn->info)))
+ if(fuse_ops_compat22 && fuse_ops_compat22->open)
+ if((err = fuse_ops_compat22->open(node->nn->path,
+ &node->nn->info.compat22)))
goto out;
- int sz = fuse_ops ?
- (fuse_ops->read(node->nn->path, data, *len, offset, &node->nn->info)) :
- (fuse_ops_compat->read(node->nn->path, data, *len, offset));
+ int sz = fuse_ops_compat22 ?
+ (fuse_ops_compat22->read(node->nn->path, data, *len,
+ offset, &node->nn->info.compat22)) :
+ (fuse_ops_compat2->read(node->nn->path, data, *len, offset));
/* FIXME: open, flush and release handling probably should be changed
* completely, I mean, we probably should do fuse_ops->open in
@@ -1123,11 +1129,12 @@ 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_ops && fuse_ops->flush)
- err = fuse_ops->flush(node->nn->path, &node->nn->info);
+ if(sz >= 0 && fuse_ops_compat22 && fuse_ops_compat22->flush)
+ err = fuse_ops_compat22->flush(node->nn->path, &node->nn->info.compat22);
- if(fuse_ops && fuse_ops->open && fuse_ops->release)
- fuse_ops->release(node->nn->path, &node->nn->info);
+ if(fuse_ops_compat22 && fuse_ops_compat22->open
+ && fuse_ops_compat22->release)
+ fuse_ops_compat22->release(node->nn->path, &node->nn->info.compat22);
if(sz < 0)
err = -sz;
@@ -1164,10 +1171,10 @@ fuse_get_inode(const char *name)
{
struct stat stat;
- assert(fuse_ops);
- assert(fuse_ops->getattr);
+ assert(fuse_ops_compat22);
+ assert(fuse_ops_compat22->getattr);
- fuse_ops->getattr(name, &stat);
+ fuse_ops_compat22->getattr(name, &stat);
return stat.st_ino;
}
@@ -1316,10 +1323,11 @@ get_dirents_getdir(struct node *dir, int first_entry, int num_entries,
handle->parent = dir->nn;
handle->hdrpos = (struct dirent*) *data;
- if(fuse_ops)
- fuse_ops->getdir(dir->nn->path, handle, get_dirents_getdir_helper);
+ if(fuse_ops_compat22)
+ fuse_ops_compat22->getdir(dir->nn->path, handle,
+ get_dirents_getdir_helper);
else
- fuse_ops_compat->getdir(dir->nn->path, handle,
+ fuse_ops_compat2->getdir(dir->nn->path, handle,
get_dirents_getdir_helper_compat);
@@ -1449,7 +1457,7 @@ get_dirents_readdir(struct node *dir, int first_entry, int num_entries,
error_t err;
FUNC_PROLOGUE_NODE("get_dirents_readdir", dir);
- if(! (fuse_ops && fuse_ops->readdir))
+ if(! (fuse_ops_compat22 && fuse_ops_compat22->readdir))
FUNC_RETURN(EOPNOTSUPP);
fuse_dirh_t handle;
@@ -1479,20 +1487,22 @@ get_dirents_readdir(struct node *dir, int first_entry, int num_entries,
handle->parent = dir->nn;
handle->hdrpos = (struct dirent*) *data;
- if(fuse_ops->opendir
- && (err = fuse_ops->opendir(dir->nn->path, &dir->nn->info)))
+ if(fuse_ops_compat22->opendir
+ && (err = fuse_ops_compat22->opendir(dir->nn->path,
+ &dir->nn->info.compat22)))
goto out;
- if((err = fuse_ops->readdir(dir->nn->path, handle,
- get_dirents_readdir_helper, first_entry,
- &dir->nn->info)))
+ if((err = fuse_ops_compat22->readdir(dir->nn->path, handle,
+ get_dirents_readdir_helper,
+ first_entry, &dir->nn->info.compat22)))
{
- fuse_ops->releasedir(dir->nn->path, &dir->nn->info);
+ fuse_ops_compat22->releasedir(dir->nn->path, &dir->nn->info.compat22);
goto out;
}
- if(fuse_ops->releasedir
- && (err = fuse_ops->releasedir(dir->nn->path, &dir->nn->info)))
+ if(fuse_ops_compat22->releasedir
+ && (err = fuse_ops_compat22->releasedir(dir->nn->path,
+ &dir->nn->info.compat22)))
goto out;
*data_len -= handle->size; /* subtract number of bytes left in the
@@ -1526,7 +1536,7 @@ netfs_get_dirents (struct iouser *cred, struct node *dir,
goto out;
- if(fuse_ops && fuse_ops->readdir)
+ if(fuse_ops_compat22 && fuse_ops_compat22->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 9727097c1..dc9055262 100644
--- a/src/netnode.c
+++ b/src/netnode.c
@@ -152,9 +152,10 @@ fuse_sync_filesystem(void)
{
if(he->nn->may_need_sync)
{
- err = -(fuse_ops ?
- fuse_ops->fsync(he->nn->path, 0, &he->nn->info) :
- fuse_ops_compat->fsync(he->nn->path, 0));
+ err = -(fuse_ops_compat22 ?
+ fuse_ops_compat22->fsync(he->nn->path, 0,
+ &he->nn->info.compat22) :
+ fuse_ops_compat2->fsync(he->nn->path, 0));
if(err)
goto out;