ADDED Makefile Index: Makefile ================================================================== --- Makefile +++ Makefile @@ -0,0 +1,22 @@ +CC = gcc +LIBS = -lfuse +PREFIX = /usr/local +prefix = $(PREFIX) +bindir = $(prefix)/bin + +all: appfs + +appfs: appfs.o + $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o appfs appfs.o $(LIBS) + +appfs.o: appfs.c + +install: appfs + cp appfs $(bindir) + +clean: + rm -f appfs appfs.o + +distclean: clean + +.PHONY: all clean distclean install ADDED appfs.c Index: appfs.c ================================================================== --- appfs.c +++ appfs.c @@ -0,0 +1,57 @@ +#define FUSE_USE_VERSION 26 +#define _FILE_OFFSET_BITS 64 + +#include +#include +#include +#include + +static int appfs_getattr(const char *path, struct stat *stbuf) { + int res = 0; + + memset(stbuf, 0, sizeof(struct stat)); + if (strcmp(path, "/") == 0) { + stbuf->st_mode = S_IFDIR | 0755; + stbuf->st_nlink = 2; + } else { + res = -ENOENT; + } + + return res; +} + +static int appfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi) { + if (strcmp(path, "/") != 0) { + return(-ENOENT); + } + + filler(buf, ".", NULL, 0); + filler(buf, "..", NULL, 0); + + return 0; +} + +static int appfs_open(const char *path, struct fuse_file_info *fi) { + return(-ENOENT); + + if ((fi->flags & 3) != O_RDONLY) + return -EACCES; + + return 0; +} + +static int appfs_read(const char *path, char *buf, size_t size, off_t offset, struct fuse_file_info *fi) { + return(-ENOENT); +} + +static struct fuse_operations appfs_oper = { + .getattr = appfs_getattr, + .readdir = appfs_readdir, + .open = appfs_open, + .read = appfs_read, +}; + +int main(int argc, char **argv) { + return(fuse_main(argc, argv, &appfs_oper, NULL)); +} +