C++ Fuse Binding

Read the following article to learn how to use fusexx to write a FUSE module:
http://portal.itauth.com/2007/07/07/using-fusexx-c-binding-rewrite-fuse-...


fusexx.hpp

/*
 * fusexx: C++ bindings for FUSE
 * Copyright (C) 2007 John C. Matherly
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 */

#ifndef FUSEXX_H_
#define FUSEXX_H_

#define FUSE_USE_VERSION 26 // earlier versions have deprecated functions

// C++ Headers
#include <string> // memset

// C Headers
#include <fuse.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

namespace fusexx {
    /*
     * fuse
     * Manages all the fuse operations. A very simple interface to the C fuse_ops struct.
     */

    template <class T>
        class fuse {
                /*
                 * Public Methods
                 */

                public:
                        /*
                         * Main function of fusexx::fuse.
                         *
                         * Calls the fuse 'fuse_main' macro.
                         *
                         * @param argc the argument counter passed to the main() function
                       * @param argv the argument vector passed to the main() function
                       * @param user_data user data set in context for init() method
                       * @return 0 on success, nonzero on failure
                       */

                        static int main (int argc, char **argv, void *user_data, T *t) {
                                // Zero the operations struct
                                memset (&T::operations, 0, sizeof (struct fuse_operations));
                               
                                // Load the operations struct w/ pointers to the respective member functions
                                T::loadOperations ();
                               
                                // The 'self' variable will be the equivalent of the 'this' pointer
                                if (t == NULL)
                                        return -1;
                                T::self = t;
                               
                                // Execute fuse_main
                                return fuse_main (argc, argv, &T::operations, user_data);
                        }
                       
            static struct fuse_operations operations;
                       
                /*
                 * Overload these functions
                 */

                 public:
                        static int readlink (const char *, char *, size_t) { return 0; }
                    static int getattr (const char *, struct stat * ) { return 0; }
                    static int getdir (const char *, fuse_dirh_t, fuse_dirfil_t) { return 0; }
                    static int mknod (const char *, mode_t, dev_t) { return 0; }
                    static int mkdir (const char *, mode_t) { return 0; }
                    static int unlink (const char *) { return 0; }
                    static int rmdir (const char *) { return 0; }
                    static int symlink (const char *, const char *) { return 0; }
                    static int rename (const char *, const char *) { return 0; }
                    static int link (const char *, const char *) { return 0; }
                    static int chmod (const char *, mode_t) { return 0; }
                    static int chown (const char *, uid_t, gid_t) { return 0; }
                    static int truncate (const char *, off_t) { return 0; }
                    static int utime (const char *, struct utimbuf *) { return 0; }
                    static int open (const char *, struct fuse_file_info *) { return 0; }
                    static int read (const char *, char *, size_t, off_t, struct fuse_file_info *) { return 0; }
                    static int write (const char *, const char *, size_t, off_t,struct fuse_file_info *) { return 0; }
                    static int statfs (const char *, struct statvfs *) { return 0; }
                    static int flush (const char *, struct fuse_file_info *) { return 0; }
                    static int release (const char *, struct fuse_file_info *) { return 0; }
                    static int fsync (const char *, int, struct fuse_file_info *) { return 0; }
                    static int setxattr (const char *, const char *, const char *, size_t, int) { return 0; }
                    static int getxattr (const char *, const char *, char *, size_t) { return 0; }
                    static int listxattr (const char *, char *, size_t) { return 0; }
                    static int removexattr (const char *, const char *) { return 0; }
                    static int readdir (const char *, void *, fuse_fill_dir_t, off_t, struct fuse_file_info *) { return 0; }
                    static int opendir (const char *, struct fuse_file_info *) { return 0; }
                    static int releasedir (const char *, struct fuse_file_info *) { return 0; }
                    static int fsyncdir (const char *, int, struct fuse_file_info *) { return 0; }
                    static void *init (struct fuse_conn_info *conn) { return NULL; }
                    static void  destroy (void *) { }
                    static int access (const char *, int) { return 0; }
                    static int create (const char *, mode_t, struct fuse_file_info *) { return 0; }
                    static int ftruncate (const char *, off_t, struct fuse_file_info *) { return 0; }
                    static int fgetattr (const char *, struct stat *, struct fuse_file_info *) { return 0; }
                                
                    static void loadOperations () {
                                operations.readlink = T::readlink;
                            operations.getattr = T::getattr;
                            operations.getdir = T::getdir;
                            operations.mknod = T::mknod;
                            operations.mkdir = T::mkdir;
                            operations.unlink = T::unlink;
                            operations.rmdir = T::rmdir;
                            operations.symlink = T::symlink;
                            operations.rename = T::rename;
                            operations.link = T::link;
                            operations.chmod = T::chmod;
                            operations.chown = T::chown;
                            operations.truncate = T::truncate;
                            operations.utime = T::utime;
                            operations.open = T::open;
                            operations.read = T::read;
                            operations.write = T::write;
                            operations.statfs = T::statfs;
                            operations.flush = T::flush;
                            operations.release = T::release;
                            operations.fsync = T::fsync;
                            operations.setxattr = T::setxattr;
                            operations.getxattr = T::getxattr;
                            operations.listxattr = T::listxattr;
                            operations.removexattr = T::removexattr;
                            operations.readdir = T::readdir;
                            operations.opendir = T::opendir;
                            operations.releasedir = T::releasedir;
                            operations.fsyncdir = T::fsyncdir;
                            operations.init = T::init;
                            operations.destroy = T::destroy;
                            operations.access = T::access;
                            operations.create = T::create;
                            operations.ftruncate = T::ftruncate;
                            operations.fgetattr = T::fgetattr;
                        }
                       
                        /*
                         * Protected variables
                         */

                protected:
                        // allow static methods to access object methods/ variables using 'self' instead of 'this'
                        static T *self;
        };
       
        template <class T> struct fuse_operations fuse<T> ::operations;
        template <class T> T * fuse<T> ::self;
}

#endif /*FUSEXX_H_*/

sky

Archlord is very famous now. My friends like to play it and buy Archlord gold. If you have money to buy Archlord money, you will find it is very useful. Earning archlord online Gold is not so hard. Try your best and then you can get it. I buy Archlord gold, just because I like it. So simple the cheap Archlord gold is.

情趣用品,情趣用品,情

情趣用品,情趣用品,情趣用品,情趣用品,情趣用品,情趣用品,情趣,情趣,情趣,情趣,情趣,情趣,情趣用品,情趣用品,情趣,情趣,A片,A片,A片,A片,A片,A片,情趣用品,A片,情趣用品,A片,情趣用品,a片,情趣用品,視訊聊天室,聊天室,視訊,ut聊天室,聊天室,視訊聊天室,成人電影,

A片,A片,AV女優,色情,成人,做愛,情色,AIO,視訊聊天室,SEX,聊天室,自拍,AV,情色,成人,情色,aio,sex,成人,情色,色情,情色電影,色情網站,av女優,av,自拍,成人,視訊聊天室,視訊交友網,AV女優,成人,聊天室,ut聊天室,av女優

免費A片,美女視訊,情色交友,免費AV,色情網站,辣妹視訊,美女交友,色情影片,成人影片,成人網站,H漫,18成人,成人圖片,成人漫畫,情色網,日本A片,免費A片下載,性愛

色情A片,A片下載,色情遊戲,色情影片,色情聊天室,情色電影,免費視訊,免費視訊聊天,免費視訊聊天室,一葉情貼圖片區,情色視訊,免費成人影片,視訊交友,視訊聊天,言情小說,愛情小說,AV片,A漫,av dvd,情色論壇,視訊美女,AV成人網,情色文學,成人交友,成人電影,成人貼圖,成人小說,成人文章,成人圖片區,成人遊戲,愛情公寓,情色貼圖,成人論壇,色情

av片,aio交友愛情館,豆豆聊天室,色情聊天室,尋夢園聊天室,080聊天室,080苗栗人聊天室,上班族聊天室,成人聊天室,中部人聊天室,一夜情聊天室,情色聊天室,情色視訊,美女視訊,辣妹視訊,視訊交友網,免費視訊聊天,視訊,免費視訊,美女交友,成人交友,聊天室交友,微風論壇,微風成人,情色貼圖,色情,微風,聊天室尋夢園,交友,視訊交友,視訊聊天,視訊辣妹,一夜情

dsa

In my heart, they are always excellent NosTale online gold From the time my parents buy me a computer, I like to surf on the internet, to see some website such as CCTV news, the fashion, the cars, the entertainment and so on. I will see these everyday. I think it is good to see some kinds of news. But generally to day, I will concentrate my mind on the entertainment news, because I usually play online games, so I will stop at this kind of news for a longer time. Perfect World Gold

wow gold

To wow power leveling and wow gold Web site to purchase World of Warcraft gold and power leveling and wow power leveling talk about faith is still cheap!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Copy the characters (respecting upper/lower case) from the image.