1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Support the renaming of active mapped devices (ioctl interface only).

This commit is contained in:
Alasdair Kergon 2002-01-10 23:29:16 +00:00
parent 4a624ca055
commit e3851db216
3 changed files with 32 additions and 0 deletions

View File

@ -35,6 +35,9 @@ void dm_task_destroy(struct dm_task *dmt)
free(t);
}
if (dmt->newname)
free(dmt->newname);
if (dmt->dmi)
free(dmt->dmi);
@ -62,6 +65,16 @@ int dm_task_set_ro(struct dm_task *dmt)
return 1;
}
int dm_task_set_newname(struct dm_task *dmt, const char *newname)
{
if (!(dmt->newname = strdup(newname))) {
log("dm_task_set_newname: strdup(%s) failed", newname);
return 0;
}
return 1;
}
struct target *create_target(uint64_t start,
uint64_t len,
const char *type, const char *params)
@ -154,6 +167,14 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt)
count++;
}
if (count && dmt->newname) {
log("targets and newname are incompatible");
return NULL;
}
if (dmt->newname)
len += strlen(dmt->newname) + 1;
if (!(dmi = malloc(len)))
return NULL;
@ -176,6 +197,9 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt)
if (!(b = _add_target(t, b, e)))
goto bad;
if (dmt->newname)
strcpy(b, dmt->newname);
return dmi;
bad:
@ -227,6 +251,10 @@ int dm_task_run(struct dm_task *dmt)
command = DM_INFO;
break;
case DM_DEVICE_RENAME:
command = DM_RENAME;
break;
default:
log("Internal error: unknown device-mapper task %d",
dmt->type);

View File

@ -21,5 +21,6 @@ struct dm_task {
int read_only;
struct dm_ioctl *dmi;
char *newname;
};

View File

@ -38,6 +38,7 @@ enum {
DM_DEVICE_RESUME,
DM_DEVICE_INFO,
DM_DEVICE_RENAME,
};
@ -66,6 +67,8 @@ int dm_task_get_info(struct dm_task *dmt, struct dm_info *dmi);
int dm_task_set_ro(struct dm_task *dmt);
int dm_task_set_newname(struct dm_task *dmt, const char *newname);
/*
* Use these to prepare for a create or reload.
*/