diff options
author | Sage Weil <sage@newdream.net> | 2010-02-02 19:11:19 -0500 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2010-02-10 18:04:39 -0500 |
commit | c7e337d6490d6f2f5e66ddf1b04d00b0dbd10108 (patch) | |
tree | 3a2e12219e38e807c71d8b2c30b89e7efbe82bdd /fs/ceph/buffer.c | |
parent | 79788c698b290426320e60374ed1324e4b5c69eb (diff) |
ceph: buffer decoding helpers
Helper for decoding into a ceph_buffer, and other misc decoding helpers
we will need.
Signed-off-by: Yehuda Sadeh <yehuda@hq.newdream.net>
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph/buffer.c')
-rw-r--r-- | fs/ceph/buffer.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/fs/ceph/buffer.c b/fs/ceph/buffer.c index 2576bd452cb8..b98086c7aeba 100644 --- a/fs/ceph/buffer.c +++ b/fs/ceph/buffer.c | |||
@@ -1,6 +1,7 @@ | |||
1 | 1 | ||
2 | #include "ceph_debug.h" | 2 | #include "ceph_debug.h" |
3 | #include "buffer.h" | 3 | #include "buffer.h" |
4 | #include "decode.h" | ||
4 | 5 | ||
5 | struct ceph_buffer *ceph_buffer_new(size_t len, gfp_t gfp) | 6 | struct ceph_buffer *ceph_buffer_new(size_t len, gfp_t gfp) |
6 | { | 7 | { |
@@ -59,3 +60,19 @@ int ceph_buffer_alloc(struct ceph_buffer *b, int len, gfp_t gfp) | |||
59 | return 0; | 60 | return 0; |
60 | } | 61 | } |
61 | 62 | ||
63 | int ceph_decode_buffer(struct ceph_buffer **b, void **p, void *end) | ||
64 | { | ||
65 | size_t len; | ||
66 | |||
67 | ceph_decode_need(p, end, sizeof(u32), bad); | ||
68 | len = ceph_decode_32(p); | ||
69 | dout("decode_buffer len %d\n", (int)len); | ||
70 | ceph_decode_need(p, end, len, bad); | ||
71 | *b = ceph_buffer_new(len, GFP_NOFS); | ||
72 | if (!*b) | ||
73 | return -ENOMEM; | ||
74 | ceph_decode_copy(p, (*b)->vec.iov_base, len); | ||
75 | return 0; | ||
76 | bad: | ||
77 | return -EINVAL; | ||
78 | } | ||