mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-18 10:04:20 +03:00
o change format of table line to <start> <len> <target> ...
This commit is contained in:
parent
2e95662387
commit
a18deda24b
@ -120,7 +120,7 @@ int dm_fs_add(struct mapped_device *md)
|
|||||||
pfd->fn = process_table;
|
pfd->fn = process_table;
|
||||||
pfd->minor = MINOR(md->dev);
|
pfd->minor = MINOR(md->dev);
|
||||||
|
|
||||||
if (!(md->pde = create_proc_entry(md->name, S_IRUGO | S_IWUSR,
|
if (!(md->pde = create_proc_entry(md->name, S_IRUGO | S_IWUSR,
|
||||||
_proc_dir))) {
|
_proc_dir))) {
|
||||||
kfree(pfd);
|
kfree(pfd);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
@ -228,23 +228,17 @@ static int process_table(const char *b, const char *e, int minor)
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* add the new entry */
|
/* add the new entry */
|
||||||
int len = we - wb;
|
|
||||||
char high_s[64], *ptr;
|
|
||||||
char target[64];
|
char target[64];
|
||||||
struct target *t;
|
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;
|
return -EINVAL;
|
||||||
|
|
||||||
strncpy(high_s, wb, we - wb);
|
if (get_number(&b, e, &size))
|
||||||
high_s[len] = '\0';
|
|
||||||
|
|
||||||
high = simple_strtol(high_s, &ptr, 10);
|
|
||||||
if (ptr == high_s)
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
b = we;
|
|
||||||
if (get_word(b, e, &wb, &we))
|
if (get_word(b, e, &wb, &we))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
@ -258,10 +252,16 @@ static int process_table(const char *b, const char *e, int minor)
|
|||||||
if (!(t = dm_get_target(target)))
|
if (!(t = dm_get_target(target)))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (md->num_targets)
|
/* check there isn't a gap */
|
||||||
last = md->highs[md->num_targets - 1] + 1;
|
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;
|
return r;
|
||||||
|
|
||||||
if ((r = dm_add_entry(md, high, t->map, context)))
|
if ((r = dm_add_entry(md, high, t->map, context)))
|
||||||
|
@ -110,21 +110,6 @@ struct linear_c {
|
|||||||
int offset; /* FIXME: we need a signed offset type */
|
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,
|
int linear_ctr(offset_t low, offset_t high, struct mapped_device *md,
|
||||||
const char *cb, const char *ce, void **result)
|
const char *cb, const char *ce, void **result)
|
||||||
{
|
{
|
||||||
|
@ -229,12 +229,12 @@ int dm_fs_remove(struct mapped_device *md);
|
|||||||
|
|
||||||
#define WARN(f, x...) printk(KERN_WARNING "device-mapper: " f "\n" , ## x)
|
#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);
|
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))
|
while(b != e && isspace((int) *b))
|
||||||
b++;
|
b++;
|
||||||
@ -242,4 +242,20 @@ static inline const char *eat_space(const char *b, const char *e)
|
|||||||
return b;
|
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
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user