ceph/branches/ebofs/kernel/monmap.c
sageweil dc48f25847 branch for ebofs changes
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@2100 29311d96-e01e-0410-9327-a35deaab8ce9
2007-11-21 00:32:00 +00:00

27 lines
571 B
C

#include <linux/slab.h>
#include "monmap.h"
#include "messenger.h"
int ceph_monmap_decode(struct ceph_monmap *m, void **p, void *end)
{
int err;
if ((err = ceph_decode_64(p, end, &m->epoch)) < 0)
return err;
if ((err = ceph_decode_32(p, end, &m->num_mon)) < 0)
return err;
m->mon_inst = kmalloc(m->num_mon*sizeof(*m->mon_inst), GFP_KERNEL);
if (m->mon_inst == NULL)
return -ENOMEM;
if ((err = ceph_decode_copy(p, end, m->mon_inst, m->num_mon*sizeof(m->mon_inst[0]))) < 0)
goto bad;
return 0;
bad:
kfree(m->mon_inst);
m->mon_inst = 0;
return err;
}