-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmlockfs.c
More file actions
61 lines (53 loc) · 1.35 KB
/
mlockfs.c
File metadata and controls
61 lines (53 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <fuse.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
static const char *basepath = "/tu_vieja";
static int getattr(const char *path, struct stat *stbuf) {
int res = 0;
memset(stbuf, 0, sizeof(struct stat));
if (strcmp(path, "/") == 0) {
stbuf->st_mode = S_IFDIR | 0755;
stbuf->st_nlink = 1;
} else
res = -ENOENT;
return res;
}
static int readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi) {
(void) offset;
(void) fi;
if (strcmp(path, "/") != 0)
return -ENOENT;
filler(buf, ".", NULL, 0);
filler(buf, "..", NULL, 0);
filler(buf, basepath + 1, NULL, 0);
return 0;
}
static int open(const char *path, struct fuse_file_info *fi) {
if (strcmp(path, basepath) != 0)
return -ENOENT;
if ((fi->flags & 3) != O_RDONLY)
return -EACCES;
return 0;
}
static int read(const char *path, char *buf, size_t size, off_t offset, struct fuse_file_info *fi) {
size_t len;
(void) fi;
if (strcmp(path, basepath) != 0)
return -ENOENT;
return 0;
}
static int write(void /*hay q ver q meirda va aca*/) {
return 0;
}
static struct fuse_operations opers = {
.getattr = getattr,
.readdir = readdir,
.open = open,
.read = read,
.write = write
};
int main(int argc, char *argv[]) {
return fuse_main(argc, argv, &opers, NULL);
}