int (*write) (const char *, const char *, size_t, off_t);
};
+/** Extra context that may be needed by some filesystems */
+struct fuse_context {
+ uid_t uid;
+ gid_t gid;
+};
+
/* FUSE flags: */
/** Enable debuging output */
*
* @param fd the control file descriptor
* @param flags any combination of the FUSE flags defined above, or 0
- * @return the created FUSE handle
- */
-struct fuse *fuse_new(int fd, int flags);
-
-/**
- * Set the filesystem operations.
- *
- * Operations which are initialised to NULL will return ENOSYS to the
- * calling process.
- *
- * @param f the FUSE handle
* @param op the operations
+ * @return the created FUSE handle
*/
-void fuse_set_operations(struct fuse *f, const struct fuse_operations *op);
+struct fuse *fuse_new(int fd, int flags, const struct fuse_operations *op);
/**
* FUSE event loop.
*/
void fuse_destroy(struct fuse *f);
+/**
+ * Get the current context
+ *
+ * The context is only valid for the duration of a filesystem
+ * operation, and thus must not be stored and used later.
+ *
+ * @param f the FUSE handle
+ * @return the context
+ */
+struct fuse_context *fuse_get_context(struct fuse *f);
+
/* ----------------------------------------------------------- *
* Miscellaneous helper fuctions *
* ----------------------------------------------------------- */
pthread_mutex_unlock(&f->lock);
}
-
static void convert_stat(struct stat *stbuf, struct fuse_attr *attr)
{
attr->mode = stbuf->st_mode;
}
static int do_chown(struct fuse *f, const char *path, struct fuse_attr *attr,
- int valid)
+ int valid)
{
int res;
uid_t uid = (valid & FATTR_UID) ? attr->uid : (uid_t) -1;
}
}
-struct fuse *fuse_new(int fd, int flags)
+struct fuse_context *fuse_get_context(struct fuse *f)
+{
+ if(f->getcontext)
+ return f->getcontext(f);
+ else
+ return &f->context;
+}
+
+struct fuse *fuse_new(int fd, int flags, const struct fuse_operations *op)
{
struct fuse *f;
struct node *root;
pthread_mutex_init(&f->lock, NULL);
f->numworker = 0;
f->numavail = 0;
+ f->op = *op;
+ f->getcontext = NULL;
+ f->context.uid = 0;
+ f->context.gid = 0;
root = (struct node *) calloc(1, sizeof(struct node));
root->mode = 0;
return f;
}
-void fuse_set_operations(struct fuse *f, const struct fuse_operations *op)
-{
- f->op = *op;
-}
-
void fuse_destroy(struct fuse *f)
{
size_t i;