21 #define FUSE_USE_VERSION 34 
   23 #include <fuse_lowlevel.h> 
   32 static const char *hello_str = 
"Hello World!\n";
 
   33 static const char *hello_name = 
"hello";
 
   35 static int hello_stat(
fuse_ino_t ino, 
struct stat *stbuf)
 
   40                 stbuf->st_mode = S_IFDIR | 0755;
 
   45                 stbuf->st_mode = S_IFREG | 0444;
 
   47                 stbuf->st_size = strlen(hello_str);
 
   63         memset(&stbuf, 0, 
sizeof(stbuf));
 
   64         if (hello_stat(ino, &stbuf) == -1)
 
   74         if (parent != 1 || strcmp(name, hello_name) != 0)
 
   77                 memset(&e, 0, 
sizeof(e));
 
   80                 e.entry_timeout = 1.0;
 
   81                 hello_stat(e.ino, &e.attr);
 
   92 static void dirbuf_add(
fuse_req_t req, 
struct dirbuf *b, 
const char *name,
 
   96         size_t oldsize = b->size;
 
   98         b->p = (
char *) realloc(b->p, b->size);
 
   99         memset(&stbuf, 0, 
sizeof(stbuf));
 
  105 #define min(x, y) ((x) < (y) ? (x) : (y)) 
  107 static int reply_buf_limited(
fuse_req_t req, 
const char *buf, 
size_t bufsize,
 
  108                              off_t off, 
size_t maxsize)
 
  112                                       min(bufsize - off, maxsize));
 
  127                 memset(&b, 0, 
sizeof(b));
 
  128                 dirbuf_add(req, &b, 
".", 1);
 
  129                 dirbuf_add(req, &b, 
"..", 1);
 
  130                 dirbuf_add(req, &b, hello_name, 2);
 
  131                 reply_buf_limited(req, b.p, b.size, off, size);
 
  141         else if ((fi->
flags & O_ACCMODE) != O_RDONLY)
 
  153         reply_buf_limited(req, hello_str, strlen(hello_str), off, size);
 
  157         .
lookup         = hello_ll_lookup,
 
  158         .getattr        = hello_ll_getattr,
 
  159         .readdir        = hello_ll_readdir,
 
  160         .open           = hello_ll_open,
 
  161         .read           = hello_ll_read,
 
  164 int main(
int argc, 
char *argv[])
 
  167         struct fuse_session *se;
 
  172         if (fuse_parse_cmdline(&args, &opts) != 0)
 
  174         if (opts.show_help) {
 
  175                 printf(
"usage: %s [options] <mountpoint>\n\n", argv[0]);
 
  180         } 
else if (opts.show_version) {
 
  187         if(opts.mountpoint == NULL) {
 
  188                 printf(
"usage: %s [options] <mountpoint>\n", argv[0]);
 
  189                 printf(
"       %s --help\n", argv[0]);
 
  195                               sizeof(hello_ll_oper), NULL);
 
  208         if (opts.singlethread)
 
  211                 config.clone_fd = opts.clone_fd;
 
  212                 config.max_idle_threads = opts.max_idle_threads;
 
  213                 ret = fuse_session_loop_mt(se, &config);
 
  222         free(opts.mountpoint);
 
int fuse_set_signal_handlers(struct fuse_session *se)
const char * fuse_pkgversion(void)
void fuse_remove_signal_handlers(struct fuse_session *se)
int fuse_daemonize(int foreground)
void fuse_session_destroy(struct fuse_session *se)
int fuse_reply_open(fuse_req_t req, const struct fuse_file_info *fi)
int fuse_reply_err(fuse_req_t req, int err)
int fuse_reply_buf(fuse_req_t req, const char *buf, size_t size)
struct fuse_req * fuse_req_t
int fuse_session_loop(struct fuse_session *se)
int fuse_reply_entry(fuse_req_t req, const struct fuse_entry_param *e)
void fuse_session_unmount(struct fuse_session *se)
void fuse_cmdline_help(void)
void fuse_lowlevel_help(void)
struct fuse_session * fuse_session_new(struct fuse_args *args, const struct fuse_lowlevel_ops *op, size_t op_size, void *userdata)
int fuse_session_mount(struct fuse_session *se, const char *mountpoint)
void fuse_lowlevel_version(void)
size_t fuse_add_direntry(fuse_req_t req, char *buf, size_t bufsize, const char *name, const struct stat *stbuf, off_t off)
int fuse_reply_attr(fuse_req_t req, const struct stat *attr, double attr_timeout)
void fuse_opt_free_args(struct fuse_args *args)
#define FUSE_ARGS_INIT(argc, argv)
void(* lookup)(fuse_req_t req, fuse_ino_t parent, const char *name)