mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
o Include dmsetup man page in build
o Allow pathname in dmsetup device arg o Generated patches for 0.90.02
This commit is contained in:
parent
515df8784a
commit
df520f1265
@ -49,6 +49,15 @@ void dm_log_init(dm_log_fn fn)
|
|||||||
_log = fn;
|
_log = fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _build_dev_path(char *buffer, size_t len, const char *dev_name)
|
||||||
|
{
|
||||||
|
/* If there's a /, assume caller knows what they're doing */
|
||||||
|
if (strchr(dev_name, '/'))
|
||||||
|
snprintf(buffer, len, "%s", dev_name);
|
||||||
|
else
|
||||||
|
snprintf(buffer, len, "/dev/%s/%s", DM_DIR, dev_name);
|
||||||
|
}
|
||||||
|
|
||||||
struct dm_task *dm_task_create(int type)
|
struct dm_task *dm_task_create(int type)
|
||||||
{
|
{
|
||||||
struct dm_task *dmt = malloc(sizeof(*dmt));
|
struct dm_task *dmt = malloc(sizeof(*dmt));
|
||||||
@ -66,10 +75,34 @@ struct dm_task *dm_task_create(int type)
|
|||||||
|
|
||||||
int dm_task_set_name(struct dm_task *dmt, const char *name)
|
int dm_task_set_name(struct dm_task *dmt, const char *name)
|
||||||
{
|
{
|
||||||
|
char *pos;
|
||||||
|
char path[PATH_MAX];
|
||||||
|
struct stat st1, st2;
|
||||||
|
|
||||||
if (dmt->dev_name)
|
if (dmt->dev_name)
|
||||||
free(dmt->dev_name);
|
free(dmt->dev_name);
|
||||||
|
|
||||||
return (dmt->dev_name = strdup(name)) ? 1 : 0;
|
/* If path was supplied, remove it if it points to the same device
|
||||||
|
* as its last component.
|
||||||
|
*/
|
||||||
|
if ((pos = strrchr(name, '/'))) {
|
||||||
|
snprintf(path, sizeof(path), "/dev/%s/%s", DM_DIR, pos + 1);
|
||||||
|
|
||||||
|
if (stat(name, &st1) || stat(path, &st2) ||
|
||||||
|
!(st1.st_dev == st2.st_dev)) {
|
||||||
|
log("dm_task_set_name: Device %s not found", name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
name = pos + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(dmt->dev_name = strdup(name))) {
|
||||||
|
log("dm_task_set_name: strdup(%s) failed", name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dm_task_add_target(struct dm_task *dmt,
|
int dm_task_add_target(struct dm_task *dmt,
|
||||||
@ -93,11 +126,6 @@ int dm_task_add_target(struct dm_task *dmt,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _build_dev_path(char *buffer, size_t len, const char *dev_name)
|
|
||||||
{
|
|
||||||
snprintf(buffer, len, "/dev/%s/%s", DM_DIR, dev_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
int add_dev_node(const char *dev_name, dev_t dev)
|
int add_dev_node(const char *dev_name, dev_t dev)
|
||||||
{
|
{
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
|
@ -4,91 +4,90 @@ dmsetup \- low level logical volume management
|
|||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.ad l
|
.ad l
|
||||||
.B dmsetup create
|
.B dmsetup create
|
||||||
.I <device name> <table path>
|
.I device_name table_file
|
||||||
.br
|
.br
|
||||||
.B dmsetup remove
|
.B dmsetup remove
|
||||||
.I <device name>
|
.I device_name
|
||||||
.br
|
.br
|
||||||
.B dmsetup suspend
|
.B dmsetup suspend
|
||||||
.I <device name>
|
.I device_name
|
||||||
.br
|
.br
|
||||||
.B dmsetup resume
|
.B dmsetup resume
|
||||||
.I <device name>
|
.I device_name
|
||||||
.br
|
.br
|
||||||
.B dmsetup reload
|
.B dmsetup reload
|
||||||
.I <device name> <table path>
|
.I device_name table_file
|
||||||
.br
|
.br
|
||||||
.B dmsetup info
|
.B dmsetup info
|
||||||
.I <device name>
|
.I device_name
|
||||||
.ad b
|
.ad b
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
dmsetup is used to manage mapped devices using the device-mapper
|
dmsetup manages logical devices that use the device-mapper driver.
|
||||||
driver. Devices are created by loading a table that gives a target
|
Devices are created by loading a table that specifies a target for
|
||||||
for ranges of sectors in the logical device.
|
each sector in the logical device.
|
||||||
|
|
||||||
The first argument to dmsetup is a command, after this the mapped
|
The first argument to dmsetup is a command.
|
||||||
device name (not the full path).
|
The second argument is the logical device name.
|
||||||
.SH Commands
|
.SH COMMANDS
|
||||||
.RS
|
|
||||||
.IP \fBcreate
|
.IP \fBcreate
|
||||||
.I <device name> <table path>
|
.I device_name table_file
|
||||||
.br
|
.br
|
||||||
Attempts to create a device using the table file given. If
|
Attempts to create a device using the table file given. If
|
||||||
successful a device will appear as
|
successful a device will appear as
|
||||||
/dev/device-mapper/<device-name>. See below for information
|
/dev/device-mapper/<device-name>. See below for information
|
||||||
on the table file format.
|
on the table file format.
|
||||||
.IP \fBremove
|
.IP \fBremove
|
||||||
.I <device name>
|
.I device_name
|
||||||
.br
|
.br
|
||||||
Removes the device
|
Removes the device
|
||||||
.IP \fBsuspend
|
.IP \fBsuspend
|
||||||
.I <device name>
|
.I device_name
|
||||||
.br
|
.br
|
||||||
Suspends a device, there are two parts to this. Firstly any
|
Suspends a device. Any I/O that has already been mapped by the device
|
||||||
io that has already been mapped by the device, but has not yet
|
but has not yet completed will be flushed. Any further I/O to that
|
||||||
completed will be flushed. Secondly any further io to that
|
|
||||||
device will be postponed for as long as the device is suspended.
|
device will be postponed for as long as the device is suspended.
|
||||||
.IP \fBresume
|
.IP \fBresume
|
||||||
.I <device name>
|
.I device_name
|
||||||
.br
|
.br
|
||||||
Un-suspends a device, postponed io now get's re-queued for processing.
|
Un-suspends a device. Postponed I/O now gets re-queued for processing.
|
||||||
.IP \fBreload
|
.IP \fBreload
|
||||||
.I <device name> <table path>
|
.I device_name table_file
|
||||||
.br
|
.br
|
||||||
This command will only work if a device is in the suspended state.
|
This command will only work if a device is in the suspended state.
|
||||||
It allows the user to change the mapping table for an existing device.
|
It changes the mapping table for an existing device.
|
||||||
.IP \fBinfo
|
.IP \fBinfo
|
||||||
.I <device name>
|
.I device_name
|
||||||
.br
|
.br
|
||||||
Output's some brief information about the device in the form:
|
Outputs some brief information about the device in the form:
|
||||||
.br
|
.br
|
||||||
<SUSPENDED|ACTIVE>
|
SUSPENDED|ACTIVE
|
||||||
.br
|
.br
|
||||||
<open count>
|
open_count
|
||||||
.br
|
.br
|
||||||
<major>,<minor>
|
major,minor
|
||||||
.br
|
.br
|
||||||
<target count>
|
target_count
|
||||||
.SH Table format
|
.SH TABLE FORMAT
|
||||||
Each line of the table specifies a single target, and is of the form:
|
Each line of the table specifies a single target and is of the form:
|
||||||
.br
|
.br
|
||||||
<logical start sector> <num sectors> <target type> <target args...>
|
logical_start_sector num_sectors target_type target_args
|
||||||
.br
|
.br
|
||||||
At the moment there are 3 simple target types available (though your
|
.br
|
||||||
system may have more in the form of modules).
|
At the moment there are 3 simple target types available - though your
|
||||||
|
system might have more in the form of modules.
|
||||||
|
|
||||||
.IP \fBlinear
|
.IP \fBlinear
|
||||||
.I <destination device> <start sector>
|
.I destination_device start_sector
|
||||||
.br
|
.br
|
||||||
The traditional linear mapping.
|
The traditional linear mapping.
|
||||||
|
|
||||||
.IP \fBstriped
|
.IP \fBstriped
|
||||||
.I <num stripes> <chunk size> [<destination #n> <start sector >]+
|
.I num_stripes chunk_size [destination start_sector]+
|
||||||
.br
|
.br
|
||||||
Creates a striped area,
|
Creates a striped area.
|
||||||
.br
|
.br
|
||||||
eg, striped 2 32 /dev/hda1 0 /dev/hdb1 0
|
e.g. striped 2 32 /dev/hda1 0 /dev/hdb1 0
|
||||||
will map the first chunk (16k) as follows:
|
will map the first chunk (16k) as follows:
|
||||||
.br
|
.br
|
||||||
LV chunk 1 -> hda1, chunk 1
|
LV chunk 1 -> hda1, chunk 1
|
||||||
.br
|
.br
|
||||||
@ -103,15 +102,16 @@ eg, striped 2 32 /dev/hda1 0 /dev/hdb1 0
|
|||||||
|
|
||||||
.IP \fBio-err
|
.IP \fBio-err
|
||||||
.br
|
.br
|
||||||
Errors any io that goes to this area. Useful for testing or
|
Errors any I/O that goes to this area. Useful for testing or
|
||||||
creating devices with holes in them.
|
for creating devices with holes in them.
|
||||||
|
|
||||||
|
|
||||||
.SH Examples
|
.SH EXAMPLES
|
||||||
|
|
||||||
|
|
||||||
# A table to join two disks together
|
# A table to join two disks together
|
||||||
.br
|
.br
|
||||||
|
.br
|
||||||
0 1028160 linear /dev/hda 0
|
0 1028160 linear /dev/hda 0
|
||||||
.br
|
.br
|
||||||
1028160 3903762 linear /dev/hdb 0
|
1028160 3903762 linear /dev/hdb 0
|
||||||
@ -129,4 +129,4 @@ creating devices with holes in them.
|
|||||||
2056320 2875602 linear /dev/hdb 1028160
|
2056320 2875602 linear /dev/hdb 1028160
|
||||||
|
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
Original version: Joe Thornber (thornber@sistina.com)
|
Original version: Joe Thornber (thornber@sistina.com)
|
||||||
|
@ -249,7 +249,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!c->fn(argc - 1, argv + 1)) {
|
if (!c->fn(argc - 1, argv + 1)) {
|
||||||
//fprintf(stderr, "Command failed\n");
|
fprintf(stderr, "Command failed\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user