-
Notifications
You must be signed in to change notification settings - Fork 1
/
dirent.h
74 lines (56 loc) · 1.53 KB
/
dirent.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
// dirent.h -- Directory Entry header
#ifndef dirent_h
#define dirent_h
#include "config.h"
#if HAVE_STDINT_H
# include <stdint.h>
#endif /* else we get int types from config.h */
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
typedef struct dirent *dirent;
#include "blob.h"
#include "region.h"
// bit masks/flags
#define RDESC_LOCAL 1
#define RDESC_REMOTE 2
// placeholder
typedef struct rdesc {
char flags; // bit field
char pad;
uint16_t a;
uint32_t b;
} *rdesc;
typedef struct rdesc_local {
char flags; // bit field
char pad;
uint16_t reg;
uint32_t off;
} *rdesc_local;
typedef struct rdesc_remote {
char flags; // bit field
char pad;
uint16_t port;
uint32_t addr;
} *rdesc_remote;
struct dirent {
uint32_t key[3];
char pad;
uint8_t rank;
uint8_t num_copies;
uint8_t len;
struct rdesc rdescs[];
};
extern dirent invalid_dirent;
/* LEN is the number of rdesc entries to fit in this dirent. */
dirent make_dirent(uint32_t *key, uint8_t len, uint8_t rank);
/* NEW_LEN is the number of rdesc entries to fit in this dirent. */
dirent copy_dirent(dirent d, uint8_t new_len);
int dirent_matches(dirent d, uint32_t *key);
void dirent_set_rdesc_local(dirent d, int i, region r, blob b);
rdesc_local dirent_get_rdesc_local(dirent d);
int dirent_has_remote(dirent d, in_addr_t addr, uint16_t port);
int dirent_add_remote(dirent d, in_addr_t addr, uint16_t port);
uint8_t dirent_get_rank(dirent d);
void dirent_set_rank(dirent d, uint8_t rank);
#endif //dirent_h