-
Notifications
You must be signed in to change notification settings - Fork 0
/
chfs_client.h
88 lines (61 loc) · 1.71 KB
/
chfs_client.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef chfs_client_h
#define chfs_client_h
#include <string>
//#include "chfs_protocol.h"
#include "extent_client.h"
#include <vector>
class chfs_client {
extent_client *ec;
public:
typedef unsigned long long inum;
enum xxstatus {
OK, RPCERR, NOENT, IOERR, EXIST
};
typedef int status;
struct fileinfo {
unsigned long long size;
unsigned long atime;
unsigned long mtime;
unsigned long ctime;
};
struct dirinfo {
unsigned long atime;
unsigned long mtime;
unsigned long ctime;
};
struct dirent {
std::string name;
chfs_client::inum inum;
};
struct syminfo {
std::string slink;
unsigned long long size;
unsigned long atime;
unsigned long mtime;
unsigned long ctime;
};
private:
static std::string filename(inum);
static inum n2i(std::string);
public:
// chfs_client();
chfs_client(std::string);
bool isfile(inum);
bool isdir(inum);
int getfile(inum, fileinfo &);
int getdir(inum, dirinfo &);
int getsymlink(inum, syminfo &);
int setattr(inum, size_t);
int lookup(inum, const char *, bool &, inum &);
int create(inum, const char *, mode_t, inum &);
int readdir(inum, std::list <dirent> &);
int write(inum, size_t, off_t, const char *, size_t &);
int read(inum, size_t, off_t, std::string &);
int unlink(inum, const char *);
int mkdir(inum, const char *, mode_t, inum &);
/** you may need to add symbolic link related methods here.*/
int link(inum, const char *, const char *link_path, inum &ino_out);
int readlink(inum ino, std::string &data);
bool issymlink(inum);
};
#endif