Created
June 16, 2015 15:27
-
-
Save bancek/4adadd65597a2da44a49 to your computer and use it in GitHub Desktop.
Example FUSE driver
This file contains hidden or 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
// sudo apt-get install libfuse-dev pkg-config | |
// gcc -Wall deny.c `pkg-config fuse --cflags --libs` -o deny | |
// mkdir foo | |
// ./deny foo | |
#define FUSE_USE_VERSION 26 | |
#include <fuse.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <errno.h> | |
#include <fcntl.h> | |
static int deny_getattr(const char *path, struct stat *stbuf) { | |
return -EACCES; | |
} | |
static int deny_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi) { | |
return -EACCES; | |
} | |
static int deny_open(const char *path, struct fuse_file_info *fi) { | |
return -EACCES; | |
} | |
static int deny_read(const char *path, char *buf, size_t size, off_t offset, struct fuse_file_info *fi) { | |
return -EACCES; | |
} | |
static struct fuse_operations deny_oper = { | |
.getattr = deny_getattr, | |
.readdir = deny_readdir, | |
.open = deny_open, | |
.read = deny_read, | |
}; | |
int main(int argc, char *argv[]) { | |
return fuse_main(argc, argv, &deny_oper, NULL); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment