/*
* Adds a target to the map
*/
-int dm_table_add_target(struct dm_table *t, offset_t high,
+int dm_table_add_target(struct dm_table *t, offset_t highs,
struct target_type *type, void *private)
{
int r, n;
return r;
n = t->num_targets++;
- t->highs[n] = high;
+ t->highs[n] = highs;
t->targets[n].type = type;
t->targets[n].private = private;
static const char *_version = @DM_VERSION@;
static const char *_email = "lvm-devel@lists.sistina.com";
+static int major = 0;
static int _major = 0;
struct io_hook {
static int request(request_queue_t *q, int rw, struct buffer_head *bh);
static int dm_user_bmap(struct inode *inode, struct lv_bmap *lvb);
+static void __free_dev(struct mapped_device *md);
+
/*
* Shortcuts to lock/unlock the global _dev_lock
*/
0, 0, NULL, NULL)))
return -ENOMEM;
+ _major = major;
r = devfs_register_blkdev(_major, _name, &dm_blk_dops);
if (r < 0) {
DMERR("register_blkdev failed");
blk_size[_major] = NULL;
blksize_size[_major] = NULL;
hardsect_size[_major] = NULL;
+ _major = 0;
DMINFO("%s cleaned up", _version);
}
return md;
}
-static void free_dev(struct mapped_device *md)
+static void __free_dev(struct mapped_device *md)
{
kfree(md);
}
return NULL;
}
-static int check_name(const char *name)
+static int __check_name(const char *name)
{
if (strchr(name, '/')) {
DMWARN("invalid device name");
if (minor >= MAX_DEVICES)
return -ENXIO;
- if (!(md = alloc_dev(minor)))
+ md = alloc_dev(minor);
+ if (!md)
return -ENXIO;
dm_lock_w();
- if (check_name(name) < 0) {
+ if (__check_name(name) < 0) {
r = -EINVAL;
goto err;
}
return 0;
err:
+ __free_dev(md);
dm_unlock_w();
- free_dev(md);
return r;
}
dm_unlock_r();
return -EPERM;
}
+ dm_unlock_r();
fsync_dev(md->dev);
- dm_unlock_r();
dm_lock_w();
- if (md->use_count) {
+ if (md->suspended || md->use_count) {
dm_unlock_w();
return -EPERM;
}
- if ((r = unregister_device(md))) {
+ r = unregister_device(md);
+ if (r) {
dm_unlock_w();
return r;
}
minor = MINOR(md->dev);
_devs[minor] = 0;
__unbind(md);
+ __free_dev(md);
dm_unlock_w();
- free_dev(md);
-
return 0;
}
__unbind(md);
- if ((r = __bind(md, table))) {
+ r = __bind(md, table);
+ if (r) {
dm_unlock_w();
return r;
}
module_init(dm_init);
module_exit(dm_exit);
-MODULE_PARM(_major, "i");
-MODULE_PARM_DESC(_major, "The major number of the device mapper");
+MODULE_PARM(major, "i");
+MODULE_PARM_DESC(major, "The major number of the device mapper");
MODULE_DESCRIPTION(DM_NAME " driver");
MODULE_AUTHOR("Joe Thornber <thornber@sistina.com>");
MODULE_LICENSE("GPL");
int dm_table_create(struct dm_table **result);
void dm_table_destroy(struct dm_table *t);
-int dm_table_add_target(struct dm_table *t, offset_t high,
+int dm_table_add_target(struct dm_table *t, offset_t highs,
struct target_type *type, void *private);
int dm_table_complete(struct dm_table *t);
if (copy_from_user(&tmp, user, sizeof(tmp)))
return -EFAULT;
- if (!(dmi = vmalloc(tmp.data_size)))
+ if (!(dmi = (struct dm_ioctl *) vmalloc(tmp.data_size)))
return -ENOMEM;
if (copy_from_user(dmi, user, tmp.data_size))
char *params, *argv[MAX_ARGS];
struct target_type *ttype;
void *context, *begin, *end;
- offset_t high = 0;
+ offset_t highs = 0;
if (!args->target_count) {
DMWARN("populate_table: no targets specified");
}
/* Add the target to the table */
- high = spec->sector_start + (spec->length - 1);
- if (dm_table_add_target(table, high, ttype, context))
+ highs = spec->sector_start + (spec->length - 1);
+ if (dm_table_add_target(table, highs, ttype, context))
PARSE_ERROR("internal error adding target to table");
first = 0;
static int suspend(struct dm_ioctl *param)
{
+ int r;
struct mapped_device *md = dm_get(param->name);
if (!md)
return -ENXIO;
- return param->suspend ? dm_suspend(md) : dm_resume(md);
+ r = param->suspend ? dm_suspend(md) : dm_resume(md);
+ return r;
}
static int reload(struct dm_ioctl *param)
if (!(dmi = malloc(len)))
return NULL;
+ memset(dmi, 0, len);
+
strncpy(dmi->version, DM_IOCTL_VERSION, sizeof(dmi->version));
dmi->data_size = len;
strncpy(dmi->name, dmt->dev_name, sizeof(dmi->name));