int r;
struct dm_table *t;
struct mapped_device *md;
- unsigned int minor = 0;
r = check_name(param->name);
if (r)
}
if (param->flags & DM_PERSISTENT_DEV_FLAG)
- minor = minor(to_kdev_t(param->dev));
+ r = dm_create_with_minor(minor(to_kdev_t(param->dev)), t, &md);
+ else
+ r = dm_create(t, &md);
- r = dm_create(minor, t, &md);
if (r) {
dm_table_put(t);
return r;
/*
* Allocate and initialise a blank device with a given minor.
*/
-static struct mapped_device *alloc_dev(unsigned int minor)
+static struct mapped_device *alloc_dev(unsigned int minor, int persistent)
{
int r;
struct mapped_device *md = kmalloc(sizeof(*md), GFP_KERNEL);
}
/* get a minor number for the dev */
- r = (minor < 0) ? next_free_minor(&minor) : specific_minor(minor);
+ r = persistent ? specific_minor(minor) : next_free_minor(&minor);
if (r < 0) {
kfree(md);
return NULL;
/*
* Constructor for a new device.
*/
-int dm_create(unsigned int minor, struct dm_table *table,
- struct mapped_device **result)
+static int create_aux(unsigned int minor, int persistent,
+ struct dm_table *table, struct mapped_device **result)
{
int r;
struct mapped_device *md;
- md = alloc_dev(minor);
+ md = alloc_dev(minor, persistent);
if (!md)
return -ENXIO;
return 0;
}
+int dm_create(struct dm_table *table, struct mapped_device **result)
+{
+ return create_aux(0, 0, table, result);
+}
+
+int dm_create_with_minor(unsigned int minor,
+ struct dm_table *table, struct mapped_device **result)
+{
+ return create_aux(minor, 1, table, result);
+}
+
void dm_get(struct mapped_device *md)
{
atomic_inc(&md->holders);
* Functions for manipulating a struct mapped_device.
* Drop the reference with dm_put when you finish with the object.
*---------------------------------------------------------------*/
-int dm_create(unsigned int minor, struct dm_table *table,
- struct mapped_device **md);
+int dm_create(struct dm_table *table, struct mapped_device **md);
+int dm_create_with_minor(unsigned int minor, struct dm_table *table,
+ struct mapped_device **md);
/*
* Reference counting for md.