Created
January 5, 2015 14:50
-
-
Save retrage/1b5a641d260fe4296249 to your computer and use it in GitHub Desktop.
C++ header for fuse3. The original was created by Gerard J. Cerchio.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @(#) fusecpp.h - allow access to fuse from C++ | |
* | |
* Gerard J. Cerchio www.circlesoft.com | |
* | |
* modified for fuse3 | |
* by retrage01@gmail.com | |
* | |
*/ | |
#ifndef AFS_h_h | |
#define AFS_h_h | |
#include <string.h> | |
#include <fuse.h> | |
namespace fuse_cpp { | |
typedef int(*getattr) (const char *, struct stat *); | |
typedef int(*readlink) (const char *, char *, size_t); | |
typedef int(*mknod) (const char *, mode_t, dev_t); | |
typedef int(*mkdir) (const char *, mode_t); | |
typedef int(*unlink) (const char *); | |
typedef int(*rmdir) (const char *); | |
typedef int(*symlink) (const char *, const char *); | |
typedef int(*rename) (const char *, const char *, unsigned int); | |
typedef int(*link) (const char *, const char *); | |
typedef int(*chmod) (const char *, mode_t); | |
typedef int(*chown) (const char *, uid_t, gid_t); | |
typedef int(*truncate) (const char *, off_t); | |
typedef int(*open) (const char *, struct fuse_file_info *); | |
typedef int(*read) (const char *, char *, size_t, off_t, struct fuse_file_info *); | |
typedef int(*write) (const char *, const char *, size_t, off_t,struct fuse_file_info *); | |
typedef int(*statfs) (const char *, struct statvfs *); | |
typedef int(*flush) (const char *, struct fuse_file_info *); | |
typedef int(*release) (const char *, struct fuse_file_info *); | |
typedef int(*fsync) (const char *, int, struct fuse_file_info *); | |
typedef int(*setxattr) (const char *, const char *, const char *, size_t, int); | |
typedef int(*getxattr) (const char *, const char *, char *, size_t); | |
typedef int(*listxattr) (const char *, char *, size_t); | |
typedef int(*removexattr) (const char *, const char *); | |
typedef int(*opendir) (const char *, struct fuse_file_info *); | |
typedef int(*readdir) (const char *, void *, fuse_fill_dir_t, off_t, struct fuse_file_info *, enum fuse_readdir_flags); | |
typedef int(*releasedir) (const char *, struct fuse_file_info *); | |
typedef int(*fsyncdir) (const char *, int, struct fuse_file_info *); | |
typedef void *(*init) (struct fuse_conn_info *conn); | |
typedef void (*destroy) (void *); | |
typedef int(*access) (const char *, int); | |
typedef int(*create) (const char *, mode_t, struct fuse_file_info *); | |
typedef int(*ftruncate) (const char *, off_t, struct fuse_file_info *); | |
typedef int(*fgetattr) (const char *, struct stat *, struct fuse_file_info *); | |
typedef int(*lock) (const char *, struct fuse_file_info *, int cmd, struct flock *); | |
typedef int(* utimens) (const char *, const struct timespec tv[2]); | |
typedef int(*bmap) (const char *, size_t blocksize, uint64_t *idx); | |
typedef int(*ioctl) (const char *, int cmd, void *arg, struct fuse_file_info *, unsigned int flags, void *data); | |
typedef int(*poll) (const char *, struct fuse_file_info *, struct fuse_pollhandle *ph, unsigned *reventsp); | |
typedef int(*write_buf) (const char *, struct fuse_bufvec *buf, off_t off, struct fuse_file_info *); | |
typedef int(*read_buf) (const char *, struct fuse_bufvec **bufp, size_t size, off_t off, struct fuse_file_info *); | |
typedef int(*flock) (const char *, struct fuse_file_info *, int op); | |
typedef int(*fallocate) (const char *, int, off_t, off_t, struct fuse_file_info *); | |
/** | |
* FuseDispatcher: this is a C++ binding for the fuse system | |
* | |
* to use: declare the appropriate routine in a class as static to the above typedefs | |
* then before calling fuse_main, instantiate the the dispatcher and call the routines | |
* that you wish to field. Those not called will be handeled by the fuse defaults. | |
*/ | |
class FuseDispatcher | |
{ | |
struct fuse_operations theOps; | |
public: | |
FuseDispatcher() { memset( &theOps, 0, sizeof(struct fuse_operations) ); } | |
struct fuse_operations *get_fuseOps() { return &theOps; } | |
void set_getattr (getattr ptr) {theOps.getattr = ptr;} | |
void set_readlink (readlink ptr) {theOps.readlink = ptr;} | |
void set_mknod (mknod ptr) {theOps.mknod = ptr;} | |
void set_mkdir (mkdir ptr) {theOps.mkdir = ptr;} | |
void set_unlink (unlink ptr) {theOps.unlink = ptr;} | |
void set_rmdir (rmdir ptr) {theOps.rmdir = ptr;} | |
void set_symlink (symlink ptr) {theOps.symlink = ptr;} | |
void set_rename (rename ptr) {theOps.rename = ptr;} | |
void set_link (link ptr) {theOps.link = ptr;} | |
void set_chmod (chmod ptr) {theOps.chmod = ptr;} | |
void set_chown (chown ptr) {theOps.chown = ptr;} | |
void set_truncate (truncate ptr) {theOps.truncate = ptr;} | |
void set_open (open ptr) {theOps.open = ptr;} | |
void set_read (read ptr) {theOps.read = ptr;} | |
void set_write (write ptr) {theOps.write = ptr;} | |
void set_statfs (statfs ptr) {theOps.statfs = ptr;} | |
void set_flush (flush ptr) {theOps.flush = ptr;} | |
void set_release (release ptr) {theOps.release = ptr;} | |
void set_fsync (fsync ptr) {theOps.fsync = ptr;} | |
void set_setxattr (setxattr ptr) {theOps.setxattr = ptr;} | |
void set_getxattr (getxattr ptr) {theOps.getxattr = ptr;} | |
void set_listxattr (listxattr ptr) {theOps.listxattr = ptr;} | |
void set_removexattr (removexattr ptr) {theOps.removexattr = ptr;} | |
void set_opendir (opendir ptr) {theOps.opendir = ptr;} | |
void set_readdir (readdir ptr) {theOps.readdir = ptr;} | |
void set_releasedir (releasedir ptr) {theOps.releasedir = ptr;} | |
void set_fsyncdir (fsyncdir ptr) {theOps.fsyncdir = ptr;} | |
void set_init (init ptr) {theOps.init = ptr;} | |
void set_destroy (destroy ptr) {theOps.destroy = ptr;} | |
void set_access (access ptr) {theOps.access = ptr;} | |
void set_create (create ptr) {theOps.create = ptr;} | |
void set_ftruncate (ftruncate ptr) {theOps.ftruncate = ptr;} | |
void set_fgetattr (fgetattr ptr) {theOps.fgetattr = ptr;} | |
void set_lock (lock ptr) {theOps.lock = ptr;} | |
void set_utimens ( utimens ptr) {theOps.utimens = ptr;} | |
void set_bmap (bmap ptr) {theOps.bmap = ptr;} | |
void set_ioctl (ioctl ptr) {theOps.ioctl = ptr;} | |
void set_poll (poll ptr) {theOps.poll = ptr;} | |
void set_write_buf (write_buf ptr) {theOps.write_buf = ptr;} | |
void set_read_buf (read_buf ptr) {theOps.read_buf = ptr;} | |
void set_flock (flock ptr) {theOps.flock = ptr;} | |
void set_fallocate (fallocate ptr) {theOps.fallocate = ptr;} | |
}; | |
}; | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment