-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyfuse.c
More file actions
85 lines (69 loc) · 1.86 KB
/
Copy pathmyfuse.c
File metadata and controls
85 lines (69 loc) · 1.86 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/* Do not change! */
#define FUSE_USE_VERSION 29
#define _FILE_OFFSET_BITS 64
/******************/
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <fuse.h>
#include "myfilesystem.h"
int myfuse_getattr(const char * name, struct stat * result) {
// MODIFY THIS FUNCTION
memset(result, 0, sizeof(struct stat));
if (strcmp(name, "/") == 0) {
result->st_mode = S_IFDIR;
} else {
result->st_mode = S_IFREG;
}
return 0;
}
int myfuse_readdir(const char * name, void * buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info * fi) {
// MODIFY THIS FUNCTION
if (strcmp(name, "/") == 0) {
filler(buf, "test_file", NULL, 0);
}
return 0;
}
int myfuse_unlink(const char *);
// FILL OUT
int myfuse_rename(const char *, const char *);
// FILL OUT
int myfuse_truncate(const char *, off_t);
// FILL OUT
int myfuse_open(const char *, struct fuse_file_info *);
// FILL OUT
int myfuse_read(const char *, char *, size_t, off_t, struct fuse_file_info *);
// FILL OUT
int myfuse_write(const char *, const char *, size_t, off_t, struct fuse_file_info *);
// FILL OUT
int myfuse_release(const char *, struct fuse_file_info *);
// FILL OUT
void * myfuse_init(struct fuse_conn_info *);
// FILL OUT
void myfuse_destroy(void *);
// FILL OUT
int myfuse_create(const char *, mode_t, struct fuse_file_info *);
// FILL OUT
struct fuse_operations operations = {
.getattr = myfuse_getattr,
.readdir = myfuse_readdir,
/* FILL OUT BELOW FUNCTION POINTERS
.unlink =
.rename =
.truncate =
.open =
.read =
.write =
.release =
.init =
.destroy =
.create =
*/
};
int main(int argc, char * argv[]) {
// MODIFY (OPTIONAL)
int ret = fuse_main(argc, argv, &operations, NULL);
return ret;
}