diff options
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 | } | ||