25 #define FUSE_USE_VERSION 31 28 #include <fuse_lowlevel.h> 36 static int null_getattr(
const char *path,
struct stat *stbuf,
41 if(strcmp(path,
"/") != 0)
44 stbuf->st_mode = S_IFREG | 0644;
46 stbuf->st_uid = getuid();
47 stbuf->st_gid = getgid();
48 stbuf->st_size = (1ULL << 32);
50 stbuf->st_atime = stbuf->st_mtime = stbuf->st_ctime = time(NULL);
55 static int null_truncate(
const char *path, off_t size,
61 if(strcmp(path,
"/") != 0)
71 if(strcmp(path,
"/") != 0)
77 static int null_read(
const char *path,
char *buf,
size_t size,
84 if(strcmp(path,
"/") != 0)
87 if (offset >= (1ULL << 32))
94 static int null_write(
const char *path,
const char *buf,
size_t size,
101 if(strcmp(path,
"/") != 0)
109 .truncate = null_truncate,
115 int main(
int argc,
char *argv[])
118 struct fuse_cmdline_opts opts;
125 if (!opts.mountpoint) {
126 fprintf(stderr,
"missing mountpoint parameter\n");
130 if (stat(opts.mountpoint, &stbuf) == -1) {
131 fprintf(stderr ,
"failed to access mountpoint %s: %s\n",
132 opts.mountpoint, strerror(errno));
133 free(opts.mountpoint);
136 free(opts.mountpoint);
137 if (!S_ISREG(stbuf.st_mode)) {
138 fprintf(stderr,
"mountpoint is not a regular file\n");
142 return fuse_main(argc, argv, &null_oper, NULL);
int fuse_parse_cmdline(struct fuse_args *args, struct fuse_cmdline_opts *opts)
#define fuse_main(argc, argv, op, private_data)
#define FUSE_ARGS_INIT(argc, argv)
void fuse_opt_free_args(struct fuse_args *args)
int(* getattr)(const char *, struct stat *, struct fuse_file_info *fi)