-
Notifications
You must be signed in to change notification settings - Fork 5
/
extent_protocol.h
55 lines (47 loc) · 914 Bytes
/
extent_protocol.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
// extent wire protocol
#ifndef extent_protocol_h
#define extent_protocol_h
#include "rpc.h"
#include <chrono>
class extent_protocol {
public:
typedef int status;
typedef unsigned long long extentid_t;
enum xxstatus { OK, RPCERR, NOENT, IOERR };
enum rpc_numbers {
put = 0x6001,
get,
getattr,
remove
};
struct attr {
unsigned int atime;
unsigned int mtime;
unsigned int ctime;
unsigned int size;
};
};
inline unsigned int
time_since_epoch() // <ctime> time(NULL)
{
return std::chrono::system_clock::now().time_since_epoch() / std::chrono::seconds(1);
}
inline unmarshall &
operator>>(unmarshall &u, extent_protocol::attr &a)
{
u >> a.atime;
u >> a.mtime;
u >> a.ctime;
u >> a.size;
return u;
}
inline marshall &
operator<<(marshall &m, extent_protocol::attr a)
{
m << a.atime;
m << a.mtime;
m << a.ctime;
m << a.size;
return m;
}
#endif