Skip to content

Instantly share code, notes, and snippets.

@bancek
Created June 16, 2015 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bancek/4adadd65597a2da44a49 to your computer and use it in GitHub Desktop.
Save bancek/4adadd65597a2da44a49 to your computer and use it in GitHub Desktop.
Example FUSE driver
// 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