aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2005-11-11 21:32:42 +0000
committerMiklos Szeredi <miklos@szeredi.hu>2005-11-11 21:32:42 +0000
commit3a77047661e345939e36f761db7a7a04ae632b76 (patch)
tree96f7fb8e682473dbe9739357040d94f7d9a1d9c2 /lib
parentbcc5385cc146c45bfe08e8351e3dcdd1d6354fee (diff)
downloadandroid_external_fuse-3a77047661e345939e36f761db7a7a04ae632b76.tar.gz
android_external_fuse-3a77047661e345939e36f761db7a7a04ae632b76.tar.bz2
android_external_fuse-3a77047661e345939e36f761db7a7a04ae632b76.zip
fix
Diffstat (limited to 'lib')
-rw-r--r--lib/fuse.c87
-rw-r--r--lib/fuse_lowlevel.c33
-rw-r--r--lib/fuse_versionscript14
-rw-r--r--lib/helper.c19
4 files changed, 116 insertions, 37 deletions
diff --git a/lib/fuse.c b/lib/fuse.c
index f3bec93..5c5eb0a 100644
--- a/lib/fuse.c
+++ b/lib/fuse.c
@@ -21,7 +21,6 @@
#include <limits.h>
#include <errno.h>
#include <assert.h>
-#include <stdint.h>
#include <pthread.h>
#include <sys/param.h>
#include <sys/uio.h>
@@ -106,7 +105,7 @@ struct fuse_dirhandle {
unsigned size;
unsigned needlen;
int filled;
- unsigned long fh;
+ uint64_t fh;
int error;
fuse_ino_t nodeid;
};
@@ -142,8 +141,8 @@ static struct node *get_node(struct fuse *f, fuse_ino_t nodeid)
{
struct node *node = get_node_nocheck(f, nodeid);
if (!node) {
- fprintf(stderr, "fuse internal error: node %lu not found\n",
- nodeid);
+ fprintf(stderr, "fuse internal error: node %llu not found\n",
+ (unsigned long long) nodeid);
abort();
}
return node;
@@ -203,8 +202,8 @@ static void unhash_name(struct fuse *f, struct node *node)
node->parent = 0;
return;
}
- fprintf(stderr, "fuse internal error: unable to unhash node: %lu\n",
- node->nodeid);
+ fprintf(stderr, "fuse internal error: unable to unhash node: %llu\n",
+ (unsigned long long) node->nodeid);
abort();
}
}
@@ -227,7 +226,7 @@ static int hash_name(struct fuse *f, struct node *node, fuse_ino_t parent,
static void delete_node(struct fuse *f, struct node *node)
{
if (f->flags & FUSE_DEBUG) {
- printf("delete: %lu\n", node->nodeid);
+ printf("delete: %llu\n", (unsigned long long) node->nodeid);
fflush(stdout);
}
assert(!node->name);
@@ -619,7 +618,7 @@ static void fuse_forget(fuse_req_t req, fuse_ino_t ino, unsigned long nlookup)
{
struct fuse *f = req_fuse(req);
if (f->flags & FUSE_DEBUG) {
- printf("FORGET %lu/%lu\n", ino, nlookup);
+ printf("FORGET %llu/%lu\n", (unsigned long long) ino, nlookup);
fflush(stdout);
}
forget_node(f, ino, nlookup);
@@ -1016,8 +1015,8 @@ static void fuse_create(fuse_req_t req, fuse_ino_t parent, const char *name,
err = f->op.create(path, mode, fi);
if (!err) {
if (f->flags & FUSE_DEBUG) {
- printf("CREATE[%lu] flags: 0x%x %s\n", fi->fh, fi->flags,
- path);
+ printf("CREATE[%llu] flags: 0x%x %s\n",
+ (unsigned long long) fi->fh, fi->flags, path);
fflush(stdout);
}
err = lookup_path(f, parent, name, path, &e, fi);
@@ -1073,13 +1072,20 @@ static void fuse_open(fuse_req_t req, fuse_ino_t ino,
if (path != NULL) {
if (!f->compat)
err = f->op.open(path, fi);
- else
+ else if (f->compat == 22) {
+ struct fuse_file_info_compat22 tmp;
+ memcpy(&tmp, fi, sizeof(tmp));
+ err = ((struct fuse_operations_compat22 *) &f->op)->open(path, &tmp);
+ memcpy(fi, &tmp, sizeof(tmp));
+ fi->fh = tmp.fh;
+ } else
err = ((struct fuse_operations_compat2 *) &f->op)->open(path, fi->flags);
}
}
if (!err) {
if (f->flags & FUSE_DEBUG) {
- printf("OPEN[%lu] flags: 0x%x\n", fi->fh, fi->flags);
+ printf("OPEN[%llu] flags: 0x%x\n", (unsigned long long) fi->fh,
+ fi->flags);
fflush(stdout);
}
@@ -1092,7 +1098,7 @@ static void fuse_open(fuse_req_t req, fuse_ino_t ino,
if (fuse_reply_open(req, fi) == -ENOENT) {
/* The open syscall was interrupted, so it must be cancelled */
if(f->op.release && path != NULL) {
- if (!f->compat)
+ if (!f->compat || f->compat >= 22)
f->op.release(path, fi);
else
((struct fuse_operations_compat2 *) &f->op)->release(path, fi->flags);
@@ -1129,7 +1135,8 @@ static void fuse_read(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off,
path = get_path(f, ino);
if (path != NULL) {
if (f->flags & FUSE_DEBUG) {
- printf("READ[%lu] %u bytes from %llu\n", fi->fh, size, off);
+ printf("READ[%llu] %u bytes from %llu\n",
+ (unsigned long long) fi->fh, size, off);
fflush(stdout);
}
@@ -1142,7 +1149,8 @@ static void fuse_read(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off,
if (res >= 0) {
if (f->flags & FUSE_DEBUG) {
- printf(" READ[%lu] %u bytes\n", fi->fh, res);
+ printf(" READ[%llu] %u bytes\n", (unsigned long long) fi->fh,
+ res);
fflush(stdout);
}
if ((size_t) res > size)
@@ -1166,8 +1174,9 @@ static void fuse_write(fuse_req_t req, fuse_ino_t ino, const char *buf,
path = get_path(f, ino);
if (path != NULL) {
if (f->flags & FUSE_DEBUG) {
- printf("WRITE%s[%lu] %u bytes to %llu\n",
- fi->writepage ? "PAGE" : "", fi->fh, size, off);
+ printf("WRITE%s[%llu] %u bytes to %llu\n",
+ fi->writepage ? "PAGE" : "", (unsigned long long) fi->fh,
+ size, off);
fflush(stdout);
}
@@ -1180,8 +1189,9 @@ static void fuse_write(fuse_req_t req, fuse_ino_t ino, const char *buf,
if (res >= 0) {
if (f->flags & FUSE_DEBUG) {
- printf(" WRITE%s[%lu] %u bytes\n",
- fi->writepage ? "PAGE" : "", fi->fh, res);
+ printf(" WRITE%s[%llu] %u bytes\n",
+ fi->writepage ? "PAGE" : "", (unsigned long long) fi->fh,
+ res);
fflush(stdout);
}
if ((size_t) res > size)
@@ -1203,7 +1213,7 @@ static void fuse_flush(fuse_req_t req, fuse_ino_t ino,
path = get_path(f, ino);
if (path != NULL) {
if (f->flags & FUSE_DEBUG) {
- printf("FLUSH[%lu]\n", fi->fh);
+ printf("FLUSH[%llu]\n", (unsigned long long) fi->fh);
fflush(stdout);
}
err = -ENOSYS;
@@ -1233,11 +1243,12 @@ static void fuse_release(fuse_req_t req, fuse_ino_t ino,
pthread_rwlock_rdlock(&f->tree_lock);
path = get_path(f, ino);
if (f->flags & FUSE_DEBUG) {
- printf("RELEASE[%lu] flags: 0x%x\n", fi->fh, fi->flags);
+ printf("RELEASE[%llu] flags: 0x%x\n", (unsigned long long) fi->fh,
+ fi->flags);
fflush(stdout);
}
if (f->op.release) {
- if (!f->compat)
+ if (!f->compat || f->compat >= 22)
f->op.release(path ? path : "-", fi);
else if (path)
((struct fuse_operations_compat2 *) &f->op)->release(path, fi->flags);
@@ -1265,7 +1276,7 @@ static void fuse_fsync(fuse_req_t req, fuse_ino_t ino, int datasync,
path = get_path(f, ino);
if (path != NULL) {
if (f->flags & FUSE_DEBUG) {
- printf("FSYNC[%lu]\n", fi->fh);
+ printf("FSYNC[%llu]\n", (unsigned long long) fi->fh);
fflush(stdout);
}
err = -ENOSYS;
@@ -1280,7 +1291,7 @@ static void fuse_fsync(fuse_req_t req, fuse_ino_t ino, int datasync,
static struct fuse_dirhandle *get_dirhandle(const struct fuse_file_info *llfi,
struct fuse_file_info *fi)
{
- struct fuse_dirhandle *dh = (struct fuse_dirhandle *) llfi->fh;
+ struct fuse_dirhandle *dh = (struct fuse_dirhandle *) (uintptr_t) llfi->fh;
memset(fi, 0, sizeof(struct fuse_file_info));
fi->fh = dh->fh;
return dh;
@@ -1305,7 +1316,7 @@ static void fuse_opendir(fuse_req_t req, fuse_ino_t ino,
dh->nodeid = ino;
mutex_init(&dh->lock);
- llfi->fh = (unsigned long) dh;
+ llfi->fh = (uintptr_t) dh;
if (f->op.opendir) {
struct fuse_file_info fi;
@@ -1319,8 +1330,15 @@ static void fuse_opendir(fuse_req_t req, fuse_ino_t ino,
pthread_rwlock_rdlock(&f->tree_lock);
path = get_path(f, ino);
if (path != NULL) {
- err = f->op.opendir(path, &fi);
- dh->fh = fi.fh;
+ if (!f->compat) {
+ err = f->op.opendir(path, &fi);
+ dh->fh = fi.fh;
+ } else {
+ struct fuse_file_info_compat22 tmp;
+ memcpy(&tmp, &fi, sizeof(tmp));
+ err = ((struct fuse_operations_compat22 *) &f->op)->opendir(path, &tmp);
+ dh->fh = tmp.fh;
+ }
}
if (!err) {
pthread_mutex_lock(&f->lock);
@@ -1565,9 +1583,9 @@ static void fuse_statfs(fuse_req_t req)
memset(&buf, 0, sizeof(buf));
if (f->op.statfs) {
- err = f->op.statfs("/", &buf);
- } else if (f->op.statfs_old) {
- if (!f->compat || f->compat > 11) {
+ if (!f->compat) {
+ err = f->op.statfs("/", &buf);
+ } else if (f->compat > 11) {
struct statfs oldbuf;
err = ((struct fuse_operations_compat22 *) &f->op)->statfs("/", &oldbuf);
if (!err)
@@ -2023,6 +2041,14 @@ struct fuse *fuse_new(int fd, const char *opts,
return fuse_new_common(fd, opts, op, op_size, 0);
}
+struct fuse *fuse_new_compat22(int fd, const char *opts,
+ const struct fuse_operations_compat22 *op,
+ size_t op_size)
+{
+ return fuse_new_common(fd, opts, (struct fuse_operations *) op,
+ op_size, 22);
+}
+
struct fuse *fuse_new_compat2(int fd, const char *opts,
const struct fuse_operations_compat2 *op)
{
@@ -2077,3 +2103,4 @@ __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@");
+__asm__(".symver fuse_new_compat22,fuse_new@FUSE_2.2");
diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c
index ad6b241..f2ac121 100644
--- a/lib/fuse_lowlevel.c
+++ b/lib/fuse_lowlevel.c
@@ -8,6 +8,7 @@
#include <config.h>
#include "fuse_lowlevel.h"
+#include "fuse_lowlevel_compat.h"
#include "fuse_kernel.h"
#include <stdio.h>
@@ -16,7 +17,6 @@
#include <unistd.h>
#include <limits.h>
#include <errno.h>
-#include <stdint.h>
#include <sys/statfs.h>
#define PARAM(inarg) (((char *)(inarg)) + sizeof(*(inarg)))
@@ -268,6 +268,16 @@ static void fill_open(struct fuse_open_out *arg,
arg->open_flags |= FOPEN_KEEP_CACHE;
}
+static void fill_open_compat(struct fuse_open_out *arg,
+ const struct fuse_file_info_compat *f)
+{
+ arg->fh = f->fh;
+ if (f->direct_io)
+ arg->open_flags |= FOPEN_DIRECT_IO;
+ if (f->keep_cache)
+ arg->open_flags |= FOPEN_KEEP_CACHE;
+}
+
int fuse_reply_entry(fuse_req_t req, const struct fuse_entry_param *e)
{
struct fuse_entry_out arg;
@@ -318,6 +328,16 @@ int fuse_reply_open(fuse_req_t req, const struct fuse_file_info *f)
return send_reply_ok(req, &arg, sizeof(arg));
}
+int fuse_reply_open_compat(fuse_req_t req,
+ const struct fuse_file_info_compat *f)
+{
+ struct fuse_open_out arg;
+
+ memset(&arg, 0, sizeof(arg));
+ fill_open_compat(&arg, f);
+ return send_reply_ok(req, &arg, sizeof(arg));
+}
+
int fuse_reply_write(fuse_req_t req, size_t count)
{
struct fuse_write_out arg;
@@ -400,6 +420,7 @@ static void do_setattr(fuse_req_t req, fuse_ino_t nodeid,
memset(&fi_store, 0, sizeof(fi_store));
fi = &fi_store;
fi->fh = arg->fh;
+ fi->fh_old = fi->fh;
}
req->f->op.setattr(req, nodeid, &stbuf, arg->valid, fi);
} else
@@ -523,6 +544,7 @@ static void do_read(fuse_req_t req, fuse_ino_t nodeid,
memset(&fi, 0, sizeof(fi));
fi.fh = arg->fh;
+ fi.fh_old = fi.fh;
req->f->op.read(req, nodeid, arg->size, arg->offset, &fi);
} else
fuse_reply_err(req, ENOSYS);
@@ -535,6 +557,7 @@ static void do_write(fuse_req_t req, fuse_ino_t nodeid,
memset(&fi, 0, sizeof(fi));
fi.fh = arg->fh;
+ fi.fh_old = fi.fh;
fi.writepage = arg->write_flags & 1;
if (req->f->op.write)
@@ -551,6 +574,7 @@ static void do_flush(fuse_req_t req, fuse_ino_t nodeid,
memset(&fi, 0, sizeof(fi));
fi.fh = arg->fh;
+ fi.fh_old = fi.fh;
if (req->f->op.flush)
req->f->op.flush(req, nodeid, &fi);
@@ -566,6 +590,7 @@ static void do_release(fuse_req_t req, fuse_ino_t nodeid,
memset(&fi, 0, sizeof(fi));
fi.flags = arg->flags;
fi.fh = arg->fh;
+ fi.fh_old = fi.fh;
if (req->f->op.release)
req->f->op.release(req, nodeid, &fi);
@@ -580,6 +605,7 @@ static void do_fsync(fuse_req_t req, fuse_ino_t nodeid,
memset(&fi, 0, sizeof(fi));
fi.fh = inarg->fh;
+ fi.fh_old = fi.fh;
if (req->f->op.fsync)
req->f->op.fsync(req, nodeid, inarg->fsync_flags & 1, &fi);
@@ -608,6 +634,7 @@ static void do_readdir(fuse_req_t req, fuse_ino_t nodeid,
memset(&fi, 0, sizeof(fi));
fi.fh = arg->fh;
+ fi.fh_old = fi.fh;
if (req->f->op.readdir)
req->f->op.readdir(req, nodeid, arg->size, arg->offset, &fi);
@@ -623,6 +650,7 @@ static void do_releasedir(fuse_req_t req, fuse_ino_t nodeid,
memset(&fi, 0, sizeof(fi));
fi.flags = arg->flags;
fi.fh = arg->fh;
+ fi.fh_old = fi.fh;
if (req->f->op.releasedir)
req->f->op.releasedir(req, nodeid, &fi);
@@ -637,6 +665,7 @@ static void do_fsyncdir(fuse_req_t req, fuse_ino_t nodeid,
memset(&fi, 0, sizeof(fi));
fi.fh = inarg->fh;
+ fi.fh_old = fi.fh;
if (req->f->op.fsyncdir)
req->f->op.fsyncdir(req, nodeid, inarg->fsync_flags & 1, &fi);
@@ -936,7 +965,6 @@ static void fuse_ll_destroy(void *data)
free(f);
}
-
struct fuse_session *fuse_lowlevel_new(const char *opts,
const struct fuse_lowlevel_ops *op,
size_t op_size, void *userdata)
@@ -979,3 +1007,4 @@ struct fuse_session *fuse_lowlevel_new(const char *opts,
}
__asm__(".symver fuse_reply_statfs_compat,fuse_reply_statfs@FUSE_2.4");
+__asm__(".symver fuse_reply_open_compat,fuse_reply_open@FUSE_2.4");
diff --git a/lib/fuse_versionscript b/lib/fuse_versionscript
index 9f17c99..f3f4e21 100644
--- a/lib/fuse_versionscript
+++ b/lib/fuse_versionscript
@@ -12,16 +12,13 @@ FUSE_2.2 {
fuse_main;
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;
@@ -47,7 +44,6 @@ FUSE_2.4 {
fuse_reply_entry;
fuse_reply_err;
fuse_reply_none;
- fuse_reply_open;
fuse_reply_readlink;
fuse_reply_write;
fuse_reply_xattr;
@@ -67,9 +63,17 @@ FUSE_2.4 {
FUSE_2.5 {
global:
- fuse_reply_statfs;
+ fuse_main_real;
+ fuse_main_real_compat22;
+ fuse_new;
+ fuse_new_compat22;
fuse_reply_create;
+ fuse_reply_open;
+ fuse_reply_open_compat;
+ fuse_reply_statfs;
fuse_reply_statfs_compat;
+ fuse_setup;
+ fuse_setup_compat22;
local:
*;
diff --git a/lib/helper.c b/lib/helper.c
index 89cd7a8..d8a522f 100644
--- a/lib/helper.c
+++ b/lib/helper.c
@@ -353,6 +353,15 @@ struct fuse *fuse_setup(int argc, char *argv[],
multithreaded, fd, 0);
}
+struct fuse *fuse_setup_compat22(int argc, char *argv[],
+ const struct fuse_operations_compat22 *op,
+ size_t op_size, char **mountpoint,
+ int *multithreaded, int *fd)
+{
+ return fuse_setup_common(argc, argv, (struct fuse_operations *) op,
+ op_size, mountpoint, multithreaded, fd, 22);
+}
+
struct fuse *fuse_setup_compat2(int argc, char *argv[],
const struct fuse_operations_compat2 *op,
char **mountpoint, int *multithreaded,
@@ -410,6 +419,14 @@ int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op,
return fuse_main_common(argc, argv, op, op_size, 0);
}
+int fuse_main_real_compat22(int argc, char *argv[],
+ const struct fuse_operations_compat22 *op,
+ size_t op_size)
+{
+ return fuse_main_common(argc, argv, (struct fuse_operations *) op,
+ op_size, 22);
+}
+
#undef fuse_main
int fuse_main(void)
{
@@ -432,5 +449,7 @@ int fuse_main_compat2(int argc, char *argv[],
}
__asm__(".symver fuse_setup_compat2,__fuse_setup@");
+__asm__(".symver fuse_setup_compat22,fuse_setup@FUSE_2.2");
__asm__(".symver fuse_teardown,__fuse_teardown@");
__asm__(".symver fuse_main_compat2,fuse_main@");
+__asm__(".symver fuse_main_real_compat22,fuse_main_real@FUSE_2.2");