1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00

o Changed to use table->err_msg rather than passing functions around

This commit is contained in:
Steven Whitehouse 2001-09-20 18:22:35 +00:00
parent 5fe98688bb
commit 70c9968eaf
3 changed files with 13 additions and 19 deletions

View File

@ -133,10 +133,9 @@ static void close_error_file(struct file *out)
fput(out); fput(out);
} }
static void parse_error(const char *message, void *private) static void parse_error(const char *message, struct line_c *lc)
{ {
char buffer[32]; char buffer[32];
struct line_c *lc = (struct line_c *) private;
#define emit(b, l) lc->out->f_op->write(lc->out, (b), (l), &lc->out->f_pos) #define emit(b, l) lc->out->f_op->write(lc->out, (b), (l), &lc->out->f_pos)
@ -180,7 +179,9 @@ static int dmfs_release(struct inode *inode, struct file *f)
if (!(lc->out = open_error_file(lc->in))) if (!(lc->out = open_error_file(lc->in)))
return -ENOMEM; return -ENOMEM;
table = dm_parse(extract_line, lc, parse_error, lc); table = dm_parse(extract_line, lc);
if (table && table->err_msg)
parse_error(table->err_msg, lc);
close_error_file(lc->out); close_error_file(lc->out);

View File

@ -23,8 +23,7 @@
#include "dm.h" #include "dm.h"
struct dm_table *dm_parse(extract_line_fn line_fn, void *l_private, struct dm_table *dm_parse(extract_line_fn line_fn, void *l_private)
dm_error_fn err_fn, void *e_private)
{ {
struct text_region line, word; struct text_region line, word;
struct dm_table *table = dm_table_create(); struct dm_table *table = dm_table_create();
@ -53,21 +52,19 @@ struct dm_table *dm_parse(extract_line_fn line_fn, void *l_private,
/* sector start */ /* sector start */
if (!dm_get_number(&line, &start)) { if (!dm_get_number(&line, &start)) {
err_fn("expecting a number for sector start", table->err_msg = "expecting a number for sector start";
e_private);
PARSE_ERROR; PARSE_ERROR;
} }
/* length */ /* length */
if (!dm_get_number(&line, &size)) { if (!dm_get_number(&line, &size)) {
err_fn("expecting a number for region length", table->err_msg = "expecting a number for region length";
e_private);
PARSE_ERROR; PARSE_ERROR;
} }
/* target type */ /* target type */
if (!dm_get_word(&line, &word)) { if (!dm_get_word(&line, &word)) {
err_fn("target type missing", e_private); table->err_msg = "target type missing";
PARSE_ERROR; PARSE_ERROR;
} }
@ -76,7 +73,7 @@ struct dm_table *dm_parse(extract_line_fn line_fn, void *l_private,
/* lookup the target type */ /* lookup the target type */
if (!(ttype = dm_get_target_type(target_name))) { if (!(ttype = dm_get_target_type(target_name))) {
err_fn("unable to find target type", e_private); table->err_msg = "unable to find target type";
PARSE_ERROR; PARSE_ERROR;
} }
@ -87,13 +84,12 @@ struct dm_table *dm_parse(extract_line_fn line_fn, void *l_private,
((table->num_targets && ((table->num_targets &&
start != table->highs[table->num_targets - 1] + 1) || start != table->highs[table->num_targets - 1] + 1) ||
(!table->num_targets && start))) { (!table->num_targets && start))) {
err_fn("gap in target ranges", e_private); table->err_msg = "gap in target ranges";
PARSE_ERROR; PARSE_ERROR;
} }
/* build the target */ /* build the target */
if (ttype->ctr(table, start, size, &line, &context)) { if (ttype->ctr(table, start, size, &line, &context)) {
err_fn(table->err_msg, e_private);
PARSE_ERROR; PARSE_ERROR;
} }
@ -105,15 +101,13 @@ struct dm_table *dm_parse(extract_line_fn line_fn, void *l_private,
/* add the target to the table */ /* add the target to the table */
high = start + (size - 1); high = start + (size - 1);
if (dm_table_add_target(table, high, ttype, context)) { if (dm_table_add_target(table, high, ttype, context)) {
err_fn("internal error adding target to table", table->err_msg = "internal error adding target to table";
e_private);
PARSE_ERROR; PARSE_ERROR;
} }
/* Ensure sane block size */ /* Ensure sane block size */
if (table->blksize_size < table->hardsect_size) { if (table->blksize_size < table->hardsect_size) {
err_fn("block size smaller than hardsect size", table->err_msg = "block size smaller than hardsect size";
e_private);
PARSE_ERROR; PARSE_ERROR;
} }

View File

@ -240,8 +240,7 @@ int dm_table_complete(struct dm_table *t);
typedef int (*extract_line_fn)(struct text_region *line, typedef int (*extract_line_fn)(struct text_region *line,
void *private); void *private);
struct dm_table *dm_parse(extract_line_fn line_fn, void *line_private, struct dm_table *dm_parse(extract_line_fn line_fn, void *line_private);
dm_error_fn err_fn, void *err_private);
static inline int dm_empty_tok(struct text_region *txt) static inline int dm_empty_tok(struct text_region *txt)