Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // g++ -Wall main.cpp `pkg-config fuse --cflags --libs` -o hello
- #define FUSE_USE_VERSION 26
- #include <fuse.h>
- #include <stdio.h>
- #include <string.h>
- #include <errno.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <stdio.h>
- static char *path;
- static int savefd;
- static int getattr(const char *path, struct stat *stbuf)
- {
- int res;
- char rPath[1024];
- strcpy(rPath, "."); strcat(rPath, path);
- res = lstat(rPath, stbuf); // Mac stuck here
- return (res == -1 ? -errno : 0);
- }
- static void* loggedFS_init(struct fuse_conn_info* info)
- {
- fchdir(savefd); close(savefd); return NULL;
- }
- int main(int argc, char *argv[])
- {
- struct fuse_operations oper;
- bzero(&oper, sizeof(fuse_operations));
- oper.init = loggedFS_init;
- oper.getattr = getattr;
- path = strdup(argv[argc - 1]);
- printf("chdir to %sn", path);
- chdir(path);
- savefd = open(".", 0);
- return fuse_main(argc, argv, &oper, NULL);
- }
- int fstatat(int dirfd, const char *pathname, struct stat *buf,
- int flags);
Add Comment
Please, Sign In to add comment