-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfuse_impl.cpp.ign
More file actions
72 lines (62 loc) · 1.6 KB
/
Copy pathfuse_impl.cpp.ign
File metadata and controls
72 lines (62 loc) · 1.6 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
#define FUSE_USE_VERSION 31
#include <fuse.h>
#include <fuse.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
static int fs_getattr(const char *path, struct stat *stbuf)
{
st->st_uid = getuid();
st->st_gid = getgid();
st->st_atime = time( NULL );
st->st_mtime = time( NULL );
if ( strcmp( path, "/" ) == 0 )
{
st->st_mode = S_IFDIR | 0755;
st->st_nlink = 2;
}
else
{
st->st_mode = S_IFREG | 0644;
st->st_nlink = 1;
st->st_size = 1024;
}
return 0;
}
static int fs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi)
{
filler( buffer, ".", NULL, 0 ); // Current Directory
filler( buffer, "..", NULL, 0 ); // Parent Directory
if ( strcmp( path, "/" ) == 0 ) // If the user is trying to show the files/directories of the root directory show the following
{
filler( buffer, "file54", NULL, 0 );
filler( buffer, "file349", NULL, 0 );
}
return 0;
}
static int fs_open(const char *path, struct fuse_file_info *fi)
{
// TODO: Implement the open() function
return 0;
}
static int fs_read(const char *path, char *buf, size_t size, off_t offset,
struct fuse_file_info *fi)
{
// TODO: Implement the read() function
return 0;
}
static struct fuse_operations fs_operations = {
.getattr = fs_getattr,
.readdir = fs_readdir,
.open = fs_open,
.read = fs_read,
};
int main(int argc, char *argv[])
{
// TODO: Initialize your filesystem here
return fuse_main(argc, argv, &fs_operations, NULL);
}