equal
deleted
inserted
replaced
1 |
|
2 #include "cache.h" |
|
3 #include "common.h" |
|
4 |
|
5 enum cache_req_mode { |
|
6 REQ_GET, |
|
7 REQ_PUT, |
|
8 }; |
|
9 |
|
10 struct cache_req { |
|
11 struct cache_op *op; |
|
12 |
|
13 off_t offset; |
|
14 |
|
15 }; |
|
16 |
|
17 int cache_req_start (struct cache_req *ctx, struct cache *cache_info, u_int8_t key[CACHE_KEY_SIZE]) { |
|
18 // clear state |
|
19 memset(ctx, 0, sizeof(*ctx)); |
|
20 |
|
21 // get the op |
|
22 if (_cache_op_get(&ctx->op, cache_info, key)) |
|
23 goto error; |
|
24 |
|
25 |
|
26 } |
|
27 |
|
28 int cache_req_read_fd (struct cache_req *ctx, int fd) { |
|
29 return cache_op_read_fd(ctx->op, fd, ctx->offset); |
|
30 } |
|
31 |
|
32 int cache_req_write_fd (struct cache_req *ctx, int fd) { |
|
33 return cache_op_write_fd(ctx->op, fd, ctx->offset); |
|
34 } |
|
35 |
|