iloveos/lib/fischl.cpp
2023-11-26 23:52:09 -08:00

85 lines
2.0 KiB
C++

#define FUSE_USE_VERSION 31
#include <fuse.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <stddef.h>
#include <assert.h>
void* fischl_init(struct fuse_conn_info *conn) {
}
static int fischl_getattr(const char* path, struct stat* stbuf) {
return 0;
}
static int fischl_readdir(const char* path, void* buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info* fi) {
return 0;
}
static int fischl_mkdir(const char *, mode_t) {
return 0;
}
static int fischl_open(const char *path, struct fuse_file_info *fi) {
return 0;
}
static int fischl_read(const char* path, char *buf, size_t size, off_t offset, struct fuse_file_info* fi) {
return 0;
}
static const struct fuse_operations fischl_oper = {
.init = fischl_init,
.getattr = fischl_getattr,
.readdir = fischl_readdir,
.open = fischl_open,
.mkdir = fischl_mkdir,
.read = fischl_read,
};
static void fischl::show_help(const char *progname)
{
printf("usage: %s [options] <mountpoint>\n\n", progname);
printf("File-system specific options:\n"
" --name=<s> Name of the \"hello\" file\n"
" (default: \"hello\")\n"
" --contents=<s> Contents \"hello\" file\n"
" (default \"Hello, World!\\n\")\n"
"\n");
}
int fischl(int argc, char *argv[])
{
int ret;
struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
/* Parse options */
if (fuse_opt_parse(&args, &options, option_spec, NULL) == -1)
return 1;
/* When --help is specified, first print our own file-system
specific help text, then signal fuse_main to show
additional help (by adding `--help` to the options again)
without usage: line (by setting argv[0] to the empty
string) */
if (options.show_help) {
show_help(argv[0]);
assert(fuse_opt_add_arg(&args, "--help") == 0);
args.argv[0][0] = '\0';
}
ret = fuse_main(args.argc, args.argv, &fischl_oper, NULL);
fuse_opt_free_args(&args);
return ret;
}