diff options
author | Pino Toscano <toscano.pino@tiscali.it> | 2013-03-22 16:59:27 +0100 |
---|---|---|
committer | Pino Toscano <toscano.pino@tiscali.it> | 2013-03-22 16:59:27 +0100 |
commit | b1f475196174db8bc750b545f23449dd5859d965 (patch) | |
tree | d62e67349927b0512a6849508d36ca4ad6512005 /example-24/hello_ll.c | |
parent | 70bf9589f3718ee6162eb7f0320f44a743b80b6d (diff) |
Remove examples for compatibility < 25
* configure.ac (AC_CONFIG_FILES): Remove example/Makefile, example-22/Makefile,
example-23/Makefile, example-24/Makefile.
* example/.gitignore: Remove.
* example/Makefile.am: Likewise.
* example/fusexmp.c: Likewise.
* example/fusexmp.c.patch: Likewise.
* example/hello.c: Likewise.
* example/null.c: Likewise.
* example-22/.gitignore: Likewise.
* example-22/Makefile.am: Likewise.
* example-22/fusexmp.c: Likewise.
* example-22/fusexmp.c.patch: Likewise.
* example-22/hello.c: Likewise.
* example-22/null.c: Likewise.
* example-23/.gitignore: Likewise.
* example-23/Makefile.am: Likewise.
* example-23/fusexmp.c: Likewise.
* example-23/fusexmp.c.patch: Likewise.
* example-23/fusexmp_fh.c: Likewise.
* example-23/fusexmp_fh.c.patch: Likewise.
* example-23/hello.c: Likewise.
* example-23/null.c: Likewise.
* example-24/.gitignore: Likewise.
* example-24/Makefile.am: Likewise.
* example-24/fusexmp.c: Likewise.
* example-24/fusexmp.c.patch: Likewise.
* example-24/fusexmp_fh.c: Likewise.
* example-24/fusexmp_fh.c.patch: Likewise.
* example-24/hello.c: Likewise.
* example-24/hello_ll.c: Likewise.
* example-24/null.c: Likewise.
Diffstat (limited to 'example-24/hello_ll.c')
-rw-r--r-- | example-24/hello_ll.c | 177 |
1 files changed, 0 insertions, 177 deletions
diff --git a/example-24/hello_ll.c b/example-24/hello_ll.c deleted file mode 100644 index d365771e1..000000000 --- a/example-24/hello_ll.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - FUSE: Filesystem in Userspace - Copyright (C) 2001-2005 Miklos Szeredi <miklos@szeredi.hu> - - This program can be distributed under the terms of the GNU GPL. - See the file COPYING. -*/ - -#include <fuse_lowlevel.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <errno.h> -#include <fcntl.h> -#include <unistd.h> -#include <assert.h> - -static const char *hello_str = "Hello World!\n"; -static const char *hello_name = "hello"; - -static int hello_stat(fuse_ino_t ino, struct stat *stbuf) -{ - stbuf->st_ino = ino; - switch (ino) { - case 1: - stbuf->st_mode = S_IFDIR | 0755; - stbuf->st_nlink = 2; - break; - - case 2: - stbuf->st_mode = S_IFREG | 0444; - stbuf->st_nlink = 1; - stbuf->st_size = strlen(hello_str); - break; - - default: - return -1; - } - return 0; -} - -static void hello_ll_getattr(fuse_req_t req, fuse_ino_t ino, - struct fuse_file_info *fi) -{ - struct stat stbuf; - - (void) fi; - - memset(&stbuf, 0, sizeof(stbuf)); - if (hello_stat(ino, &stbuf) == -1) - fuse_reply_err(req, ENOENT); - else - fuse_reply_attr(req, &stbuf, 1.0); -} - -static void hello_ll_lookup(fuse_req_t req, fuse_ino_t parent, const char *name) -{ - struct fuse_entry_param e; - - if (parent != 1 || strcmp(name, hello_name) != 0) - fuse_reply_err(req, ENOENT); - else { - memset(&e, 0, sizeof(e)); - e.ino = 2; - e.attr_timeout = 1.0; - e.entry_timeout = 1.0; - hello_stat(e.ino, &e.attr); - - fuse_reply_entry(req, &e); - } -} - -struct dirbuf { - char *p; - size_t size; -}; - -static void dirbuf_add(struct dirbuf *b, const char *name, fuse_ino_t ino) -{ - struct stat stbuf; - size_t oldsize = b->size; - b->size += fuse_dirent_size(strlen(name)); - b->p = (char *) realloc(b->p, b->size); - memset(&stbuf, 0, sizeof(stbuf)); - stbuf.st_ino = ino; - fuse_add_dirent(b->p + oldsize, name, &stbuf, b->size); -} - -#define min(x, y) ((x) < (y) ? (x) : (y)) - -static int reply_buf_limited(fuse_req_t req, const char *buf, size_t bufsize, - off_t off, size_t maxsize) -{ - if (off < bufsize) - return fuse_reply_buf(req, buf + off, min(bufsize - off, maxsize)); - else - return fuse_reply_buf(req, NULL, 0); -} - -static void hello_ll_readdir(fuse_req_t req, fuse_ino_t ino, size_t size, - off_t off, struct fuse_file_info *fi) -{ - (void) fi; - - if (ino != 1) - fuse_reply_err(req, ENOTDIR); - else { - struct dirbuf b; - - memset(&b, 0, sizeof(b)); - dirbuf_add(&b, ".", 1); - dirbuf_add(&b, "..", 1); - dirbuf_add(&b, hello_name, 2); - reply_buf_limited(req, b.p, b.size, off, size); - free(b.p); - } -} - -static void hello_ll_open(fuse_req_t req, fuse_ino_t ino, - struct fuse_file_info *fi) -{ - if (ino != 2) - fuse_reply_err(req, EISDIR); - else if ((fi->flags & 3) != O_RDONLY) - fuse_reply_err(req, EACCES); - else - fuse_reply_open(req, fi); -} - -static void hello_ll_read(fuse_req_t req, fuse_ino_t ino, size_t size, - off_t off, struct fuse_file_info *fi) -{ - (void) fi; - - assert(ino == 2); - reply_buf_limited(req, hello_str, strlen(hello_str), off, size); -} - -static struct fuse_lowlevel_ops hello_ll_oper = { - .lookup = hello_ll_lookup, - .getattr = hello_ll_getattr, - .readdir = hello_ll_readdir, - .open = hello_ll_open, - .read = hello_ll_read, -}; - -int main(int argc, char *argv[]) -{ - const char *mountpoint; - int err = -1; - int fd; - - if (argc != 2) { - fprintf(stderr, "usage: %s mountpoint\n", argv[0]); - return 1; - } - mountpoint = argv[1]; - fd = fuse_mount(mountpoint, NULL); - if (fd != -1) { - struct fuse_session *se; - - se = fuse_lowlevel_new("debug", &hello_ll_oper, sizeof(hello_ll_oper), - NULL); - if (se != NULL) { - struct fuse_chan *ch = fuse_kern_chan_new(fd); - if (ch != NULL) { - fuse_session_add_chan(se, ch); - err = fuse_session_loop(se); - } - fuse_session_destroy(se); - } - close(fd); - } - fuse_unmount(mountpoint); - - return err ? 1 : 0; -} |