1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

o change format of table line to <start> <len> <target> ...

This commit is contained in:
Joe Thornber 2001-08-28 14:56:47 +00:00
parent 2e95662387
commit a18deda24b
3 changed files with 32 additions and 31 deletions

View File

@ -228,23 +228,17 @@ static int process_table(const char *b, const char *e, int minor)
} else {
/* add the new entry */
int len = we - wb;
char high_s[64], *ptr;
char target[64];
struct target *t;
offset_t last = 0, high;
offset_t start, size, high;
size_t len;
if (len > sizeof(high_s))
if (get_number(&b, e, &start))
return -EINVAL;
strncpy(high_s, wb, we - wb);
high_s[len] = '\0';
high = simple_strtol(high_s, &ptr, 10);
if (ptr == high_s)
if (get_number(&b, e, &size))
return -EINVAL;
b = we;
if (get_word(b, e, &wb, &we))
return -EINVAL;
@ -258,10 +252,16 @@ static int process_table(const char *b, const char *e, int minor)
if (!(t = dm_get_target(target)))
return -EINVAL;
if (md->num_targets)
last = md->highs[md->num_targets - 1] + 1;
/* check there isn't a gap */
if ((md->num_targets &&
start != md->highs[md->num_targets - 1] + 1) ||
(!md->num_targets && start)) {
WARN("gap in target ranges");
return -EINVAL;
}
if ((r = t->ctr(last, high, md, we, e, &context)))
high = start + (size - 1);
if ((r = t->ctr(start, high, md, we, e, &context)))
return r;
if ((r = dm_add_entry(md, high, t->map, context)))

View File

@ -110,21 +110,6 @@ struct linear_c {
int offset; /* FIXME: we need a signed offset type */
};
static int get_number(const char **b, const char *e, unsigned int *n)
{
char *ptr;
*b = eat_space(*b, e);
if (*b >= e)
return -EINVAL;
*n = simple_strtoul(*b, &ptr, 10);
if (ptr == *b)
return -EINVAL;
*b = ptr;
return 0;
}
int linear_ctr(offset_t low, offset_t high, struct mapped_device *md,
const char *cb, const char *ce, void **result)
{

View File

@ -229,12 +229,12 @@ int dm_fs_remove(struct mapped_device *md);
#define WARN(f, x...) printk(KERN_WARNING "device-mapper: " f "\n" , ## x)
static inline int is_active(struct mapped_device *md)
inline static int is_active(struct mapped_device *md)
{
return test_bit(DM_ACTIVE, &md->state);
}
static inline const char *eat_space(const char *b, const char *e)
inline static const char *eat_space(const char *b, const char *e)
{
while(b != e && isspace((int) *b))
b++;
@ -242,4 +242,20 @@ static inline const char *eat_space(const char *b, const char *e)
return b;
}
inline static int get_number(const char **b, const char *e, unsigned int *n)
{
char *ptr;
*b = eat_space(*b, e);
if (*b >= e)
return -EINVAL;
*n = simple_strtoul(*b, &ptr, 10);
if (ptr == *b)
return -EINVAL;
*b = ptr;
return 0;
}
#endif