mirror of
git://sourceware.org/git/lvm2.git
synced 2025-04-01 18:50:41 +03:00
o Removed the error reporting function from the target constructor function
arguments. Errors are now reported by setting a pointer in the table to point to an error message.
This commit is contained in:
parent
76fa6c5cfb
commit
05bebea511
@ -42,8 +42,7 @@ typedef void (*dm_error_fn)(const char *message, void *private);
|
||||
/* constructor, destructor and map fn types */
|
||||
typedef int (*dm_ctr_fn)(struct dm_table *t,
|
||||
offset_t b, offset_t l,
|
||||
struct text_region *args, void **result,
|
||||
dm_error_fn fn, void *private);
|
||||
struct text_region *args, void **result);
|
||||
|
||||
typedef void (*dm_dtr_fn)(struct dm_table *t, void *c);
|
||||
typedef int (*dm_map_fn)(struct buffer_head *bh, int rw, void *context);
|
||||
|
@ -43,8 +43,7 @@ struct linear_c {
|
||||
* <dev_path> <offset>
|
||||
*/
|
||||
static int linear_ctr(struct dm_table *t, offset_t b, offset_t l,
|
||||
struct text_region *args, void **result,
|
||||
dm_error_fn fn, void *private)
|
||||
struct text_region *args, void **result)
|
||||
{
|
||||
struct linear_c *lc;
|
||||
unsigned int start;
|
||||
@ -55,7 +54,7 @@ static int linear_ctr(struct dm_table *t, offset_t b, offset_t l,
|
||||
int hardsect_size;
|
||||
|
||||
if (!dm_get_word(args, &word)) {
|
||||
fn("couldn't get device path", private);
|
||||
t->err_msg = "couldn't get device path";
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@ -65,26 +64,26 @@ static int linear_ctr(struct dm_table *t, offset_t b, offset_t l,
|
||||
if (IS_ERR(bdev)) {
|
||||
switch (PTR_ERR(bdev)) {
|
||||
case -ENOTBLK:
|
||||
fn("not a block device", private);
|
||||
t->err_msg = "not a block device";
|
||||
break;
|
||||
case -EACCES:
|
||||
fn("nodev mount option", private);
|
||||
t->err_msg = "nodev mount option";
|
||||
break;
|
||||
case -ENOENT:
|
||||
default:
|
||||
fn("no such device", private);
|
||||
t->err_msg = "no such device";
|
||||
}
|
||||
return PTR_ERR(bdev);
|
||||
}
|
||||
|
||||
if (!dm_get_number(args, &start)) {
|
||||
fn("destination start not given", private);
|
||||
t->err_msg = "destination start not given";
|
||||
rv = -EINVAL;
|
||||
goto out_bdev_put;
|
||||
}
|
||||
|
||||
if (!(lc = kmalloc(sizeof(lc), GFP_KERNEL))) {
|
||||
fn("couldn't allocate memory for linear context\n", private);
|
||||
t->err_msg = "couldn't allocate memory for linear context\n";
|
||||
rv = -ENOMEM;
|
||||
goto out_bdev_put;
|
||||
}
|
||||
|
@ -92,9 +92,10 @@ struct dm_table *dm_parse(extract_line_fn line_fn, void *l_private,
|
||||
}
|
||||
|
||||
/* build the target */
|
||||
if (ttype->ctr(table, start, size, &line, &context,
|
||||
err_fn, e_private))
|
||||
if (ttype->ctr(table, start, size, &line, &context)) {
|
||||
err_fn(table->err_msg, e_private);
|
||||
PARSE_ERROR;
|
||||
}
|
||||
|
||||
/* no point registering the target
|
||||
if there was an error. */
|
||||
|
@ -121,8 +121,7 @@ int dm_unregister_target(struct target_type *t)
|
||||
* up LV's that have holes in them.
|
||||
*/
|
||||
static int io_err_ctr(struct dm_table *t, offset_t b, offset_t l,
|
||||
struct text_region *args, void **result,
|
||||
dm_error_fn fn, void *private)
|
||||
struct text_region *args, void **result)
|
||||
{
|
||||
/* this takes no arguments */
|
||||
*result = 0;
|
||||
|
@ -169,6 +169,7 @@ struct target {
|
||||
struct dm_table {
|
||||
atomic_t refcnt;
|
||||
|
||||
char *err_msg;
|
||||
/* btree table */
|
||||
int depth;
|
||||
int counts[MAX_DEPTH]; /* in nodes */
|
||||
|
Loading…
x
Reference in New Issue
Block a user