+2004-11-26 Miklos Szeredi <miklos@szeredi.hu>
+
+ * libfuse API change: open, read, write, flush, fsync and release
+ are passed a 'struct fuse_file_info' pointer containing the open
+ flags (open and release), and the file handle. Verion changed to
+ 3.0.
+
2004-11-23 Miklos Szeredi <miklos@szeredi.hu>
* More cleanups in the kernel
-AC_INIT(fuse, 2.1-pre1)
+AC_INIT(fuse, 3.0-pre0)
AM_INIT_AUTOMAKE
AM_CONFIG_HEADER(include/config.h)
}
-static int xmp_open(const char *path, int flags)
+static int xmp_open(const char *path, struct fuse_file_info *fi)
{
int res;
- res = open(path, flags);
+ res = open(path, fi->flags);
if(res == -1)
return -errno;
return 0;
}
-static int xmp_read(const char *path, char *buf, size_t size, off_t offset)
+static int xmp_read(const char *path, char *buf, size_t size, off_t offset,
+ struct fuse_file_info *fi)
{
int fd;
int res;
+ (void) fi;
fd = open(path, O_RDONLY);
if(fd == -1)
return -errno;
}
static int xmp_write(const char *path, const char *buf, size_t size,
- off_t offset)
+ off_t offset, struct fuse_file_info *fi)
{
int fd;
int res;
+ (void) fi;
fd = open(path, O_WRONLY);
if(fd == -1)
return -errno;
return 0;
}
-static int xmp_release(const char *path, int flags)
+static int xmp_release(const char *path, struct fuse_file_info *fi)
{
/* Just a stub. This method is optional and can safely be left
unimplemented */
-
+
(void) path;
- (void) flags;
+ (void) fi;
return 0;
}
-static int xmp_fsync(const char *path, int isdatasync)
+static int xmp_fsync(const char *path, int isdatasync,
+ struct fuse_file_info *fi)
{
/* Just a stub. This method is optional and can safely be left
unimplemented */
(void) path;
(void) isdatasync;
+ (void) fi;
return 0;
}
return 0;
}
-static int hello_open(const char *path, int flags)
+static int hello_open(const char *path, struct fuse_file_info *fi)
{
if(strcmp(path, hello_path) != 0)
return -ENOENT;
- if((flags & 3) != O_RDONLY)
+ if((fi->flags & 3) != O_RDONLY)
return -EACCES;
return 0;
}
-static int hello_read(const char *path, char *buf, size_t size, off_t offset)
+static int hello_read(const char *path, char *buf, size_t size, off_t offset,
+ struct fuse_file_info *fi)
{
size_t len;
+ (void) fi;
if(strcmp(path, hello_path) != 0)
return -ENOENT;
return 0;
}
-static int null_open(const char *path, int UNUSED(flags))
+static int null_open(const char *path, struct fuse_file_info *UNUSED(fi))
{
if(strcmp(path, "/") != 0)
return -ENOENT;
}
static int null_read(const char *path, char *UNUSED(buf), size_t size,
- off_t UNUSED(offset))
+ off_t UNUSED(offset), struct fuse_file_info *UNUSED(fi))
{
if(strcmp(path, "/") != 0)
return -ENOENT;
}
static int null_write(const char *path, const char *UNUSED(buf), size_t size,
- off_t UNUSED(offset))
+ off_t UNUSED(offset), struct fuse_file_info *UNUSED(fi))
{
if(strcmp(path, "/") != 0)
return -ENOENT;
/* This file defines the library interface of FUSE */
/** Major version of FUSE library interface */
-#define FUSE_MAJOR_VERSION 2
+#define FUSE_MAJOR_VERSION 3
/** Minor version of FUSE library interface */
-#define FUSE_MINOR_VERSION 1
+#define FUSE_MINOR_VERSION 0
/* This interface uses 64 bit off_t */
#if _FILE_OFFSET_BITS != 64
typedef int (*fuse_dirfil_t) (fuse_dirh_t h, const char *name, int type,
ino_t ino);
+/** Information about open files */
+struct fuse_file_info {
+ /** Open flags. Available in open() and release() */
+ int flags;
+
+ /** File handle. May be filled in by filesystem in open().
+ Available in all other file operations */
+ unsigned long fh;
+};
+
/**
* The file system operations:
*
int (*chown) (const char *, uid_t, gid_t);
int (*truncate) (const char *, off_t);
int (*utime) (const char *, struct utimbuf *);
- 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 (*open) (const char *, struct fuse_file_info *);
+ int (*read) (const char *, char *, size_t, off_t,
+ struct fuse_file_info *);
+ int (*write) (const char *, const char *, size_t, off_t,
+ struct fuse_file_info *);
int (*statfs) (const char *, struct statfs *);
- int (*flush) (const char *);
- int (*release) (const char *, int);
- int (*fsync) (const char *, int);
+ int (*flush) (const char *, struct fuse_file_info *);
+ int (*release) (const char *, struct fuse_file_info *);
+ int (*fsync) (const char *, int, struct fuse_file_info *);
int (*setxattr) (const char *, const char *, const char *, size_t, int);
int (*getxattr) (const char *, const char *, char *, size_t);
int (*listxattr) (const char *, char *, size_t);
int __fuse_exited(struct fuse* f);
void __fuse_set_getcontext_func(struct fuse_context *(*func)(void));
-
-/* ----------------------------------------------------------- *
- * Compatibility cruft *
- * ----------------------------------------------------------- */
-
-#ifdef FUSE_DIRFIL_COMPAT
-typedef int (*fuse_dirfil_old_t) (fuse_dirh_t h, const char *name, int type);
-#define fuse_dirfil_t fuse_dirfil_old_t
-#endif
-
#ifdef __cplusplus
}
#endif
-AC_INIT(fuse-kernel, 2.1-pre1)
+AC_INIT(fuse-kernel, 3.0-pre0)
AC_CONFIG_HEADERS([config.h])
AC_PROG_INSTALL
mount.c \
fuse_i.h
-libfuse_la_LDFLAGS = -lpthread -version-number 2:1:0
+libfuse_la_LDFLAGS = -lpthread -version-number 3:0:0
int res;
char *path;
struct fuse_open_out outarg;
+ struct fuse_file_info fi;
+ memset(&fi, 0, sizeof(fi));
+ fi.flags = arg->flags;
res = -ENOENT;
path = get_path(f, in->nodeid);
if (path != NULL) {
res = -ENOSYS;
if (f->op.open)
- res = f->op.open(path, arg->flags);
+ res = f->op.open(path, &fi);
}
if (res == 0) {
int res2;
races with rename/unlink, against which the kernel can't
protect */
pthread_mutex_lock(&f->lock);
- f->fh_ctr ++;
- outarg.fh = f->fh_ctr;
+ outarg.fh = fi.fh;
if (f->flags & FUSE_DEBUG) {
printf("OPEN[%lu] flags: 0x%x\n", outarg.fh, arg->flags);
fflush(stdout);
if(res2 == -ENOENT) {
/* The open syscall was interrupted, so it must be cancelled */
if(f->op.release)
- f->op.release(path, arg->flags);
+ f->op.release(path, &fi);
} else
get_node(f, in->nodeid)->open_count ++;
pthread_mutex_unlock(&f->lock);
{
char *path;
int res;
+ struct fuse_file_info fi;
+ memset(&fi, 0, sizeof(fi));
+ fi.fh = arg->fh;
res = -ENOENT;
path = get_path(f, in->nodeid);
if (path != NULL) {
}
res = -ENOSYS;
if (f->op.flush)
- res = f->op.flush(path);
+ res = f->op.flush(path, &fi);
free(path);
}
send_reply(f, in, res, NULL, 0);
{
struct node *node;
char *path;
+ struct fuse_file_info fi;
+
+ memset(&fi, 0, sizeof(fi));
+ fi.flags = arg->flags;
+ fi.fh = arg->fh;
pthread_mutex_lock(&f->lock);
node = get_node(f, in->nodeid);
fflush(stdout);
}
if (f->op.release)
- f->op.release(path, arg->flags);
+ f->op.release(path, &fi);
if(node->is_hidden && node->open_count == 0)
/* can now clean up this hidden file */
char *buf = outbuf + sizeof(struct fuse_out_header);
size_t size;
size_t outsize;
+ struct fuse_file_info fi;
+ memset(&fi, 0, sizeof(fi));
+ fi.fh = arg->fh;
+
res = -ENOENT;
path = get_path(f, in->nodeid);
if (path != NULL) {
res = -ENOSYS;
if (f->op.read)
- res = f->op.read(path, buf, arg->size, arg->offset);
+ res = f->op.read(path, buf, arg->size, arg->offset, &fi);
free(path);
}
int res;
char *path;
struct fuse_write_out outarg;
+ struct fuse_file_info fi;
+
+ memset(&fi, 0, sizeof(fi));
+ fi.fh = arg->fh;
res = -ENOENT;
path = get_path(f, in->nodeid);
res = -ENOSYS;
if (f->op.write)
- res = f->op.write(path, PARAM(arg), arg->size, arg->offset);
+ res = f->op.write(path, PARAM(arg), arg->size, arg->offset, &fi);
free(path);
}
{
int res;
char *path;
+ struct fuse_file_info fi;
+
+ memset(&fi, 0, sizeof(fi));
+ fi.fh = inarg->fh;
res = -ENOENT;
path = get_path(f, in->nodeid);
}
res = -ENOSYS;
if (f->op.fsync)
- res = f->op.fsync(path, inarg->datasync);
+ res = f->op.fsync(path, inarg->datasync, &fi);
free(path);
}
send_reply(f, in, res, NULL, 0);
nodeid_t ctr;
unsigned int generation;
unsigned int hidectr;
- unsigned long fh_ctr;
pthread_mutex_t lock;
int numworker;
int numavail;