-
Notifications
You must be signed in to change notification settings - Fork 6
/
inode.h
72 lines (58 loc) · 1.51 KB
/
inode.h
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
#ifndef GASSYFS_INODE_H_
#define GASSYFS_INODE_H_
#include <map>
#include <memory>
#include <string>
#include <vector>
#include <fuse.h>
#include <fuse_lowlevel.h>
#include "common.h"
class GassyFs;
class Inode {
public:
typedef std::shared_ptr<Inode> Ptr;
Inode(time_t time, uid_t uid, gid_t gid, blksize_t blksize,
mode_t mode, GassyFs *fs);
virtual ~Inode();
void set_ino(fuse_ino_t ino);
fuse_ino_t ino() const;
struct stat i_st;
bool is_directory() const;
bool is_symlink() const;
std::map<off_t, Extent> extents_;
bool setlua_atime(std::string policy);
std::string getlua_atime();
int alloc_node;
private:
bool ino_set_;
fuse_ino_t ino_;
GassyFs *fs_;
std::string lua_atime;
};
// TODO: specialize for regular file
class DirInode : public Inode {
public:
typedef std::shared_ptr<DirInode> Ptr;
typedef std::map<std::string, Inode::Ptr> dir_t;
DirInode(time_t time, uid_t uid, gid_t gid, blksize_t blksize,
mode_t mode, GassyFs *fs) :
Inode(time, uid, gid, blksize, mode, fs) {
i_st.st_nlink = 2;
i_st.st_mode = S_IFDIR | mode;
i_st.st_blocks = 1;
}
dir_t dentries;
};
class SymlinkInode : public Inode {
public:
typedef std::shared_ptr<SymlinkInode> Ptr;
SymlinkInode(time_t time, uid_t uid, gid_t gid, blksize_t blksize,
const std::string& link, GassyFs *fs) :
Inode(time, uid, gid, blksize, 0, fs) {
i_st.st_mode = S_IFLNK;
this->link = link;
i_st.st_size = link.length();
}
std::string link;
};
#endif