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

o Fixes to parsing code

This commit is contained in:
Steven Whitehouse 2001-10-16 11:56:55 +00:00
parent dfe0a65d93
commit e58cb41e7e

View File

@ -74,7 +74,7 @@ static void dmfs_parse_line(struct dm_table *t, unsigned num, char *str)
if (rv == 0) { if (rv == 0) {
printk(KERN_DEBUG "%ul %ul %s %s", start, size, printk(KERN_DEBUG "%ul %ul %s %s", start, size,
ttype->name, ttype->name,
ttype->print(context)); ttype->print ? ttype->print(context) : "-");
msg = "Error adding target to table"; msg = "Error adding target to table";
high = start + (size - 1); high = start + (size - 1);
if (dm_table_add_target(t, high, ttype, context) == 0) if (dm_table_add_target(t, high, ttype, context) == 0)
@ -90,28 +90,28 @@ out:
static int dmfs_copy(char *dst, int dstlen, char *src, int srclen, int *flag) static int dmfs_copy(char *dst, int dstlen, char *src, int srclen, int *flag)
{ {
int copied = 0; int len = min(dstlen, srclen);
char *start = dst;
while(dstlen && srclen) { while(len) {
*dst = *src++; *dst = *src++;
copied++;
if (*dst == '\n') if (*dst == '\n')
goto end_of_line; goto end_of_line;
dst++; dst++;
dstlen--; len--;
srclen--;
} }
out: out:
return copied; return dst - start;
end_of_line: end_of_line:
*flag = 1; *flag = 1;
*dst = 0; *dst++ = 0;
goto out; goto out;
} }
static int dmfs_parse_page(struct dm_table *t, char *buf, int len, char *tmp, unsigned long *tmpl, int *num) static int dmfs_parse_page(struct dm_table *t, char *buf, int end, unsigned long end_index, char *tmp, unsigned long *tmpl, int *num)
{ {
int copied; int copied;
unsigned long len = end ? end_index : PAGE_CACHE_SIZE - 1;
do { do {
int flag = 0; int flag = 0;
@ -121,7 +121,7 @@ static int dmfs_parse_page(struct dm_table *t, char *buf, int len, char *tmp, un
if (*tmpl + copied == PAGE_SIZE - 1) if (*tmpl + copied == PAGE_SIZE - 1)
goto line_too_long; goto line_too_long;
*tmpl = copied; *tmpl = copied;
if (flag) { if (flag || (len == 0 && end)) {
dmfs_parse_line(t, *num, tmp); dmfs_parse_line(t, *num, tmp);
(*num)++; (*num)++;
*tmpl = 0; *tmpl = 0;
@ -164,7 +164,6 @@ static struct dm_table *dmfs_parse(struct inode *inode)
end_offset = inode->i_size & (PAGE_CACHE_SIZE - 1); end_offset = inode->i_size & (PAGE_CACHE_SIZE - 1);
do { do {
unsigned long end = (index == end_index) ? end_offset : PAGE_CACHE_SIZE;
pg = find_get_page(mapping, index); pg = find_get_page(mapping, index);
if (pg) { if (pg) {
@ -175,14 +174,14 @@ static struct dm_table *dmfs_parse(struct inode *inode)
goto broken; goto broken;
kaddr = kmap(pg); kaddr = kmap(pg);
rv = dmfs_parse_page(t, kaddr, end, (char *)page, &rem, &num); rv = dmfs_parse_page(t, kaddr, (index == end_index), end_offset, (char *)page, &rem, &num);
kunmap(pg); kunmap(pg);
page_cache_release(pg);
if (rv) if (rv)
goto parse_error; goto parse_error;
} }
page_cache_release(pg);
index++; index++;
} while(index != end_index); } while(index != end_index);
@ -195,6 +194,7 @@ static struct dm_table *dmfs_parse(struct inode *inode)
broken: broken:
printk(KERN_ERR "dmfs_parse: Page not uptodate\n"); printk(KERN_ERR "dmfs_parse: Page not uptodate\n");
page_cache_release(pg);
free_page(page); free_page(page);
dm_table_destroy(t); dm_table_destroy(t);
return NULL; return NULL;
@ -321,7 +321,7 @@ struct address_space_operations dmfs_address_space_operations = {
static struct file_operations dmfs_table_file_operations = { static struct file_operations dmfs_table_file_operations = {
llseek: generic_file_llseek, llseek: generic_file_llseek,
read: generic_file_read, read: generic_file_read,
write: generic_file_write, /* FIXME: Needs to hold dmi->sem */ write: generic_file_write,
open: dmfs_table_open, open: dmfs_table_open,
release: dmfs_table_release, release: dmfs_table_release,
fsync: dmfs_table_sync, fsync: dmfs_table_sync,
@ -330,7 +330,7 @@ static struct file_operations dmfs_table_file_operations = {
static struct inode_operations dmfs_table_inode_operations = { static struct inode_operations dmfs_table_inode_operations = {
}; };
int dmfs_create_table(struct inode *dir, int mode) struct inode *dmfs_create_table(struct inode *dir, int mode)
{ {
struct inode *inode = new_inode(dir->i_sb); struct inode *inode = new_inode(dir->i_sb);
@ -342,10 +342,10 @@ int dmfs_create_table(struct inode *dir, int mode)
inode->i_blocks = 0; inode->i_blocks = 0;
inode->i_rdev = NODEV; inode->i_rdev = NODEV;
inode->i_atime = inode->i_ctime = inode->i_mtime = CURRENT_TIME; inode->i_atime = inode->i_ctime = inode->i_mtime = CURRENT_TIME;
inode->i_mapping = dir->i_mapping;
inode->i_mapping->a_ops = &dmfs_address_space_operations; inode->i_mapping->a_ops = &dmfs_address_space_operations;
inode->i_fop = &dmfs_table_file_operations; inode->i_fop = &dmfs_table_file_operations;
inode->i_op = &dmfs_table_inode_operations; inode->i_op = &dmfs_table_inode_operations;
inode->i_mapping = dir->i_mapping;
} }
return inode; return inode;