mirror of
git://sourceware.org/git/lvm2.git
synced 2025-12-31 12:32:49 +03:00
Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
38a90e7669 | ||
|
|
6bfc526dcd | ||
|
|
aadb8a7405 | ||
|
|
27082bf77e | ||
|
|
a2903c80cd | ||
|
|
9a77c5369c | ||
|
|
3c30741a19 | ||
|
|
7028ad4ec0 | ||
|
|
8de750c6aa | ||
|
|
04f98de9ee | ||
|
|
a1a019784b | ||
|
|
4aeeae77bd | ||
|
|
651cfc2b78 | ||
|
|
2ef8af25e2 | ||
|
|
0b13852a5b | ||
|
|
13427578c9 | ||
|
|
d89ca2087e | ||
|
|
8b0ea9fba6 | ||
|
|
9f0b653d5a | ||
|
|
659a339233 | ||
|
|
4c29f177a0 | ||
|
|
d664e63d55 | ||
|
|
2493509dbe | ||
|
|
1c8b27f554 | ||
|
|
68297b7186 |
6
debian/README.Debian
vendored
Normal file
6
debian/README.Debian
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
LVM2 requires the device-mapper kernel module (dm-mod). This is
|
||||
available as a kernel patch for 2.4 (in kernel-patch-device-mapper), and
|
||||
is distributed with linux 2.5 and above. The LVM1 kernel module (lvm-mod)
|
||||
will not work with lvm2 packages. dm-mod and lvm-mod may both be loaded
|
||||
in the kernel at the same time with no problems. Without dm-mod, this
|
||||
package is pretty useless.
|
||||
13
debian/changelog
vendored
13
debian/changelog
vendored
@@ -1,3 +1,16 @@
|
||||
lvm2 (1.95.11-1) unstable; urgency=low
|
||||
|
||||
* New upstream release. (Closes: #171436)
|
||||
* Removed TODO and INTRO from debian/docs; added WHATS_NEW.
|
||||
* Remove vgcfgrestore.8 undocumented symlink.
|
||||
* Added a README.Debian, mentioning the device-mapper kernel module
|
||||
requirement that lvm2 has. (Closes: #171674, #163020)
|
||||
* Get rid of debian/conffiles (debhelper's smart enough to figure that out).
|
||||
* debian/copyright fix to appease lintian.
|
||||
* Fix typo in tools/commands.h that caused /usr/sbin/; to be created.
|
||||
|
||||
-- Andres Salomon <dilinger@mp3revolution.net> Mon, 9 Dec 2002 02:51:02 -0400
|
||||
|
||||
lvm2 (1.95.10-2) unstable; urgency=low
|
||||
|
||||
* Fix software raid problems by ensuring lvm init script runs after
|
||||
|
||||
2
debian/conffiles
vendored
2
debian/conffiles
vendored
@@ -1,2 +0,0 @@
|
||||
/etc/lvm/lvm.conf
|
||||
/etc/init.d/lvm2
|
||||
2
debian/copyright
vendored
2
debian/copyright
vendored
@@ -3,7 +3,7 @@ Wed, 20 Feb 2002 03:17:25 -0500.
|
||||
|
||||
It was downloaded from http://www.sistina.com/products_lvm.htm
|
||||
|
||||
Upstream Author(s): LVM Development Team
|
||||
Upstream Author: LVM Development Team
|
||||
|
||||
Copyright (c) 2001-2002 LVM Development Team
|
||||
|
||||
|
||||
3
debian/docs
vendored
3
debian/docs
vendored
@@ -1,6 +1,5 @@
|
||||
BUGS
|
||||
INTRO
|
||||
README
|
||||
TODO
|
||||
VERSION
|
||||
WHATS_NEW
|
||||
doc/*
|
||||
|
||||
1
debian/undocumented
vendored
1
debian/undocumented
vendored
@@ -7,7 +7,6 @@ pvdata.8
|
||||
pvmove.8
|
||||
pvresize.8
|
||||
version.8
|
||||
vgcfgrestore.8
|
||||
vgexport.8
|
||||
vgimport.8
|
||||
vgmknodes.8
|
||||
|
||||
@@ -49,6 +49,11 @@ devices {
|
||||
|
||||
# You can turn off writing this cache file by setting this to 0.
|
||||
write_cache_state = 1
|
||||
|
||||
# An advanced setting.
|
||||
# List of pairs of additional acceptable block device types found
|
||||
# in /proc/devices with maximum (non-zero) number of partitions.
|
||||
# types = [ "fd", 16 ]
|
||||
}
|
||||
|
||||
# This section that allows you to configure the nature of the
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
../lib/device/dev-cache.h
|
||||
../lib/device/device.h
|
||||
../lib/display/display.h
|
||||
../lib/display/display_formats.h
|
||||
../lib/filters/filter-composite.h
|
||||
../lib/filters/filter-persistent.h
|
||||
../lib/filters/filter-regex.h
|
||||
@@ -33,4 +32,5 @@
|
||||
../lib/misc/lvm-string.h
|
||||
../lib/misc/sharedlib.h
|
||||
../lib/regex/matcher.h
|
||||
../lib/report/report.h
|
||||
../lib/uuid/uuid.h
|
||||
|
||||
@@ -56,6 +56,7 @@ SOURCES=\
|
||||
regex/matcher.c \
|
||||
regex/parse_rx.c \
|
||||
regex/ttree.c \
|
||||
report/report.c \
|
||||
uuid/uuid.c
|
||||
|
||||
ifeq ("@LVM1@", "internal")
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "lvm-file.h"
|
||||
#include "format-text.h"
|
||||
#include "sharedlib.h"
|
||||
#include "display.h"
|
||||
|
||||
#ifdef LVM1_INTERNAL
|
||||
#include "format1.h"
|
||||
@@ -153,6 +154,20 @@ static int _process_config(struct cmd_context *cmd)
|
||||
DEFAULT_ACTIVATION);
|
||||
set_activation(cmd->default_settings.activation);
|
||||
|
||||
cmd->default_settings.suffix = find_config_int(cmd->cf->root,
|
||||
"global/suffix",
|
||||
'/', DEFAULT_SUFFIX);
|
||||
|
||||
if (!(cmd->default_settings.unit_factor =
|
||||
units_to_bytes(find_config_str(cmd->cf->root,
|
||||
"global/units",
|
||||
'/',
|
||||
DEFAULT_UNITS),
|
||||
&cmd->default_settings.unit_type))) {
|
||||
log_error("Invalid units specification");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -239,7 +254,9 @@ static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
|
||||
struct config_node *cn;
|
||||
struct dev_filter *f1, *f2, *f3;
|
||||
|
||||
if (!(f2 = lvm_type_filter_create(cmd->proc_dir)))
|
||||
cn = find_config_node(cmd->cf->root, "devices/types", '/');
|
||||
|
||||
if (!(f2 = lvm_type_filter_create(cmd->proc_dir, cn)))
|
||||
return NULL;
|
||||
|
||||
if (!(cn = find_config_node(cmd->cf->root, "devices/filter", '/'))) {
|
||||
|
||||
@@ -25,6 +25,9 @@ struct config_info {
|
||||
int test;
|
||||
int syslog;
|
||||
int activation;
|
||||
int suffix;
|
||||
uint64_t unit_factor;
|
||||
char unit_type;
|
||||
const char *msg_prefix;
|
||||
int cmd_name; /* Show command name? */
|
||||
|
||||
|
||||
@@ -245,6 +245,9 @@ int reload_config_file(struct config_tree **cf)
|
||||
struct stat info;
|
||||
int r, fd;
|
||||
|
||||
if (!c->filename)
|
||||
return 0;
|
||||
|
||||
if (stat(c->filename, &info) == -1) {
|
||||
if (errno == ENOENT)
|
||||
return 1;
|
||||
@@ -712,7 +715,7 @@ struct config_node *find_config_node(struct config_node *cn,
|
||||
}
|
||||
|
||||
const char *find_config_str(struct config_node *cn,
|
||||
const char *path, char sep, const char *fail)
|
||||
const char *path, const char sep, const char *fail)
|
||||
{
|
||||
struct config_node *n = find_config_node(cn, path, sep);
|
||||
|
||||
|
||||
@@ -51,10 +51,10 @@ int write_config_file(struct config_tree *cf, const char *file);
|
||||
int reload_config_file(struct config_tree **cf);
|
||||
|
||||
struct config_node *find_config_node(struct config_node *cn,
|
||||
const char *path, char seperator);
|
||||
const char *path, char separator);
|
||||
|
||||
const char *find_config_str(struct config_node *cn,
|
||||
const char *path, char sep, const char *fail);
|
||||
const char *path, const char sep, const char *fail);
|
||||
|
||||
int find_config_int(struct config_node *cn, const char *path,
|
||||
char sep, int fail);
|
||||
|
||||
@@ -47,6 +47,8 @@
|
||||
#define DEFAULT_VERBOSE 0
|
||||
#define DEFAULT_LOGLEVEL 0
|
||||
#define DEFAULT_INDENT 1
|
||||
#define DEFAULT_UNITS "h"
|
||||
#define DEFAULT_SUFFIX 1
|
||||
|
||||
#define DEFAULT_ACTIVATION 1
|
||||
|
||||
@@ -54,4 +56,24 @@
|
||||
#define DEFAULT_MAX_HISTORY 100
|
||||
#endif
|
||||
|
||||
#define DEFAULT_REP_ALIGNED 1
|
||||
#define DEFAULT_REP_BUFFERED 1
|
||||
#define DEFAULT_REP_HEADINGS 1
|
||||
#define DEFAULT_REP_SEPARATOR " "
|
||||
|
||||
#define DEFAULT_LVS_COLS "lv_name,vg_name,lv_attr,lv_size,origin,snap_percent"
|
||||
#define DEFAULT_VGS_COLS "vg_name,pv_count,lv_count,snap_count,vg_attr,vg_size,vg_free"
|
||||
#define DEFAULT_PVS_COLS "pv_name,vg_name,pv_fmt,pv_attr,pv_size,pv_free"
|
||||
#define DEFAULT_SEGS_COLS "lv_name,vg_name,lv_attr,stripes,segtype,seg_size"
|
||||
|
||||
#define DEFAULT_LVS_COLS_VERB "lv_name,vg_name,seg_count,lv_attr,lv_size,lv_minor,origin,snap_percent,lv_uuid"
|
||||
#define DEFAULT_VGS_COLS_VERB "vg_name,vg_attr,vg_extent_size,pv_count,lv_count,snap_count,vg_size,vg_free,vg_uuid"
|
||||
#define DEFAULT_PVS_COLS_VERB "pv_name,vg_name,pv_fmt,pv_attr,pv_size,pv_free,pv_uuid"
|
||||
#define DEFAULT_SEGS_COLS_VERB "lv_name,vg_name,lv_attr,seg_start,seg_size,stripes,segtype,stripesize,chunksize"
|
||||
|
||||
#define DEFAULT_LVS_SORT "vg_name,lv_name"
|
||||
#define DEFAULT_VGS_SORT "vg_name"
|
||||
#define DEFAULT_PVS_SORT "pv_name"
|
||||
#define DEFAULT_SEGS_SORT "vg_name,lv_name,seg_start"
|
||||
|
||||
#endif /* _LVM_DEFAULTS_H */
|
||||
|
||||
@@ -13,11 +13,13 @@ struct list {
|
||||
struct list *n, *p;
|
||||
};
|
||||
|
||||
static inline void list_init(struct list *head) {
|
||||
static inline void list_init(struct list *head)
|
||||
{
|
||||
head->n = head->p = head;
|
||||
}
|
||||
|
||||
static inline void list_add(struct list *head, struct list *elem) {
|
||||
static inline void list_add(struct list *head, struct list *elem)
|
||||
{
|
||||
assert(head->n);
|
||||
|
||||
elem->n = head;
|
||||
@@ -27,7 +29,8 @@ static inline void list_add(struct list *head, struct list *elem) {
|
||||
head->p = elem;
|
||||
}
|
||||
|
||||
static inline void list_add_h(struct list *head, struct list *elem) {
|
||||
static inline void list_add_h(struct list *head, struct list *elem)
|
||||
{
|
||||
assert(head->n);
|
||||
|
||||
elem->n = head->n;
|
||||
@@ -37,27 +40,35 @@ static inline void list_add_h(struct list *head, struct list *elem) {
|
||||
head->n = elem;
|
||||
}
|
||||
|
||||
static inline void list_del(struct list *elem) {
|
||||
static inline void list_del(struct list *elem)
|
||||
{
|
||||
elem->n->p = elem->p;
|
||||
elem->p->n = elem->n;
|
||||
}
|
||||
|
||||
static inline int list_empty(struct list *head) {
|
||||
static inline int list_empty(struct list *head)
|
||||
{
|
||||
return head->n == head;
|
||||
}
|
||||
|
||||
static inline int list_end(struct list *head, struct list *elem)
|
||||
{
|
||||
return elem->n == head;
|
||||
}
|
||||
|
||||
#define list_iterate(v, head) \
|
||||
for (v = (head)->n; v != head; v = v->n)
|
||||
|
||||
#define list_iterate_safe(v, t, head) \
|
||||
for (v = (head)->n, t = v->n; v != head; v = t, t = v->n)
|
||||
|
||||
static inline int list_size(struct list *head) {
|
||||
static inline int list_size(struct list *head)
|
||||
{
|
||||
int s = 0;
|
||||
struct list *v;
|
||||
|
||||
list_iterate(v, head)
|
||||
s++;
|
||||
s++;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,72 @@ static struct {
|
||||
static int _num_policies = sizeof(_policies) / sizeof(*_policies);
|
||||
static int _num_segtypes = sizeof(_segtypes) / sizeof(*_segtypes);
|
||||
|
||||
uint64_t units_to_bytes(const char *units, char *unit_type)
|
||||
{
|
||||
|
||||
char *ptr;
|
||||
uint64_t v;
|
||||
|
||||
ptr = (char *) units;
|
||||
|
||||
if (isdigit(*units)) {
|
||||
v = (uint64_t) strtod(units, &ptr);
|
||||
if (ptr == units)
|
||||
return 0;
|
||||
} else
|
||||
v = 1;
|
||||
|
||||
if (v == 1)
|
||||
*unit_type = *ptr;
|
||||
else
|
||||
*unit_type = 'U';
|
||||
|
||||
switch (*ptr) {
|
||||
case 'h':
|
||||
case 'H':
|
||||
v = 1ULL;
|
||||
*unit_type = *ptr;
|
||||
break;
|
||||
case 's':
|
||||
v *= SECTOR_SIZE;
|
||||
case 'b':
|
||||
case 'B':
|
||||
v *= 1ULL;
|
||||
break;
|
||||
case 'k':
|
||||
v *= 1024ULL;
|
||||
break;
|
||||
case 'm':
|
||||
v *= 1024ULL * 1024ULL;
|
||||
break;
|
||||
case 'g':
|
||||
v *= 1024ULL * 1024ULL * 1024ULL;
|
||||
break;
|
||||
case 't':
|
||||
v *= 1024ULL * 1024ULL * 1024ULL * 1024ULL;
|
||||
break;
|
||||
case 'K':
|
||||
v *= 1000ULL;
|
||||
break;
|
||||
case 'M':
|
||||
v *= 1000ULL * 1000ULL;
|
||||
break;
|
||||
case 'G':
|
||||
v *= 1000ULL * 1000ULL * 1000ULL;
|
||||
break;
|
||||
case 'T':
|
||||
v *= 1000ULL * 1000ULL * 1000ULL * 1000ULL;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (*(ptr + 1))
|
||||
return 0;
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
const char *get_alloc_string(alloc_policy_t alloc)
|
||||
{
|
||||
int i;
|
||||
@@ -68,7 +134,7 @@ const char *get_segtype_string(segment_type_t segtype)
|
||||
if (_segtypes[i].segtype == segtype)
|
||||
return _segtypes[i].str;
|
||||
|
||||
return NULL;
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
alloc_policy_t get_alloc_from_string(const char *str)
|
||||
@@ -95,35 +161,60 @@ segment_type_t get_segtype_from_string(const char *str)
|
||||
return SEG_STRIPED;
|
||||
}
|
||||
|
||||
char *display_size(uint64_t size, size_len_t sl)
|
||||
const char *display_size(struct cmd_context *cmd, uint64_t size, size_len_t sl)
|
||||
{
|
||||
int s;
|
||||
ulong byte = 1024 * 1024 * 1024;
|
||||
int suffix = 1;
|
||||
uint64_t byte;
|
||||
uint64_t units = 1024ULL;
|
||||
char *size_buf = NULL;
|
||||
char *size_str[][2] = {
|
||||
{"Terabyte", "TB"},
|
||||
{"Gigabyte", "GB"},
|
||||
{"Megabyte", "MB"},
|
||||
{"Kilobyte", "KB"},
|
||||
{"", ""}
|
||||
char *size_str[][3] = {
|
||||
{" Terabyte", " TB", "T"},
|
||||
{" Gigabyte", " GB", "G"},
|
||||
{" Megabyte", " MB", "M"},
|
||||
{" Kilobyte", " KB", "K"},
|
||||
{"", "", ""},
|
||||
{" Byte ", " B ", "B"},
|
||||
{" Units ", " Un", "U"},
|
||||
{" Sectors ", " Se", "S"},
|
||||
{" ", " ", " "},
|
||||
};
|
||||
|
||||
if (!(size_buf = dbg_malloc(SIZE_BUF))) {
|
||||
if (!(size_buf = pool_alloc(cmd->mem, SIZE_BUF))) {
|
||||
log_error("no memory for size display buffer");
|
||||
return NULL;
|
||||
return "";
|
||||
}
|
||||
|
||||
if (size == 0LL)
|
||||
sprintf(size_buf, "0");
|
||||
else {
|
||||
suffix = cmd->current_settings.suffix;
|
||||
|
||||
for (s = 0; s < 8; s++)
|
||||
if (toupper((int) cmd->current_settings.unit_type) ==
|
||||
*size_str[s][2])
|
||||
break;
|
||||
|
||||
if (size == 0ULL) {
|
||||
sprintf(size_buf, "0%s", suffix ? size_str[s][sl] : "");
|
||||
return size_buf;
|
||||
}
|
||||
|
||||
if (s < 8) {
|
||||
byte = cmd->current_settings.unit_factor;
|
||||
size *= 1024ULL;
|
||||
} else {
|
||||
suffix = 1;
|
||||
if (cmd->current_settings.unit_type == 'H')
|
||||
units = 1000ULL;
|
||||
else
|
||||
units = 1024ULL;
|
||||
byte = units * units * units;
|
||||
s = 0;
|
||||
while (size_str[s] && size < byte)
|
||||
s++, byte /= 1024;
|
||||
snprintf(size_buf, SIZE_BUF - 1,
|
||||
"%.2f %s", (float) size / byte, size_str[s][sl]);
|
||||
s++, byte /= units;
|
||||
}
|
||||
|
||||
/* Caller to deallocate */
|
||||
snprintf(size_buf, SIZE_BUF - 1, "%.2f%s", (float) size / byte,
|
||||
suffix ? size_str[s][sl] : "");
|
||||
|
||||
return size_buf;
|
||||
}
|
||||
|
||||
@@ -154,10 +245,11 @@ void pvdisplay_colons(struct physical_volume *pv)
|
||||
}
|
||||
|
||||
/* FIXME Include label fields */
|
||||
void pvdisplay_full(struct physical_volume *pv, void *handle)
|
||||
void pvdisplay_full(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
void *handle)
|
||||
{
|
||||
char uuid[64];
|
||||
char *size, *size1; /*, *size2; */
|
||||
const char *size;
|
||||
|
||||
uint64_t pe_free;
|
||||
|
||||
@@ -174,23 +266,21 @@ void pvdisplay_full(struct physical_volume *pv, void *handle)
|
||||
log_print("VG Name %s%s", pv->vg_name,
|
||||
pv->status & EXPORTED_VG ? " (exported)" : "");
|
||||
|
||||
size = display_size((uint64_t) pv->size / 2, SIZE_SHORT);
|
||||
size = display_size(cmd, (uint64_t) pv->size / 2, SIZE_SHORT);
|
||||
if (pv->pe_size && pv->pe_count) {
|
||||
size1 = display_size((pv->size - pv->pe_count * pv->pe_size)
|
||||
/ 2, SIZE_SHORT);
|
||||
|
||||
/******** FIXME display LVM on-disk data size
|
||||
size2 = display_size(pv->size / 2, SIZE_SHORT);
|
||||
********/
|
||||
|
||||
log_print("PV Size %s" " / not usable %s", /* [LVM: %s]", */
|
||||
size, size1); /* , size2); */
|
||||
size, display_size(cmd,
|
||||
(pv->size -
|
||||
pv->pe_count * pv->pe_size) / 2,
|
||||
SIZE_SHORT));
|
||||
|
||||
dbg_free(size1);
|
||||
/* dbg_free(size2); */
|
||||
} else
|
||||
log_print("PV Size %s", size);
|
||||
dbg_free(size);
|
||||
|
||||
/* PV number not part of LVM2 design
|
||||
log_print("PV# %u", pv->pv_number);
|
||||
@@ -219,11 +309,19 @@ void pvdisplay_full(struct physical_volume *pv, void *handle)
|
||||
int pvdisplay_short(struct cmd_context *cmd, struct volume_group *vg,
|
||||
struct physical_volume *pv, void *handle)
|
||||
{
|
||||
char uuid[64];
|
||||
|
||||
if (!pv)
|
||||
return 0;
|
||||
|
||||
if (!id_write_format(&pv->id, uuid, sizeof(uuid))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
log_print("PV Name %s ", dev_name(pv->dev));
|
||||
/* FIXME pv->pv_number); */
|
||||
log_print("PV UUID %s", *uuid ? uuid : "none");
|
||||
log_print("PV Status %sallocatable",
|
||||
(pv->status & ALLOCATABLE_PV) ? "" : "NOT ");
|
||||
log_print("Total PE / Free PE %u / %u",
|
||||
@@ -256,13 +354,12 @@ void lvdisplay_colons(struct logical_volume *lv)
|
||||
int lvdisplay_full(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
void *handle)
|
||||
{
|
||||
char *size;
|
||||
struct dm_info info;
|
||||
int inkernel, snap_active;
|
||||
char uuid[64];
|
||||
struct snapshot *snap = NULL;
|
||||
struct list *slh, *snaplist;
|
||||
float snap_percent; /* fused, fsize; */
|
||||
float snap_percent; /* fused, fsize; */
|
||||
|
||||
if (!id_write_format(&lv->lvid.id[1], uuid, sizeof(uuid))) {
|
||||
stack;
|
||||
@@ -295,6 +392,7 @@ int lvdisplay_full(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
snap->cow->name,
|
||||
(snap_active > 0) ? "active" : "INACTIVE");
|
||||
}
|
||||
snap = NULL;
|
||||
} else if ((snap = find_cow(lv))) {
|
||||
snap_active = lv_snapshot_percent(lv, &snap_percent);
|
||||
log_print("LV snapshot status %s destination for %s%s/%s",
|
||||
@@ -316,10 +414,10 @@ int lvdisplay_full(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
if (inkernel)
|
||||
log_print("# open %u", info.open_count);
|
||||
|
||||
size = display_size(snap ? snap->origin->size / 2 : lv->size / 2,
|
||||
SIZE_SHORT);
|
||||
log_print("LV Size %s", size);
|
||||
dbg_free(size);
|
||||
log_print("LV Size %s",
|
||||
display_size(cmd,
|
||||
snap ? snap->origin->size / 2 : lv->size / 2,
|
||||
SIZE_SHORT));
|
||||
|
||||
log_print("Current LE %u",
|
||||
snap ? snap->origin->le_count : lv->le_count);
|
||||
@@ -334,23 +432,22 @@ int lvdisplay_full(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
log_print("Stripe size (KByte) %u", lv->stripesize / 2);
|
||||
***********/
|
||||
|
||||
if (snap) {
|
||||
if (snap_percent == -1)
|
||||
snap_percent = 100;
|
||||
if (snap) {
|
||||
if (snap_percent == -1)
|
||||
snap_percent = 100;
|
||||
|
||||
size = display_size(snap->chunk_size / 2, SIZE_SHORT);
|
||||
log_print("Snapshot chunk size %s", size);
|
||||
dbg_free(size);
|
||||
log_print("Snapshot chunk size %s",
|
||||
display_size(cmd, snap->chunk_size / 2, SIZE_SHORT));
|
||||
|
||||
/*
|
||||
size = display_size(lv->size / 2, SIZE_SHORT);
|
||||
sscanf(size, "%f", &fsize);
|
||||
fused = fsize * snap_percent / 100;
|
||||
*/
|
||||
log_print("Allocated to snapshot %.2f%% ", /* [%.2f/%s]", */
|
||||
snap_percent); /*, fused, size); */
|
||||
/* dbg_free(size); */
|
||||
}
|
||||
log_print("Allocated to snapshot %.2f%% ", /* [%.2f/%s]", */
|
||||
snap_percent); /*, fused, size); */
|
||||
/* dbg_free(size); */
|
||||
}
|
||||
|
||||
/********** FIXME Snapshot
|
||||
size = ???
|
||||
@@ -397,19 +494,23 @@ int lvdisplay_segments(struct logical_volume *lv)
|
||||
list_iterate(segh, &lv->segments) {
|
||||
seg = list_item(segh, struct lv_segment);
|
||||
|
||||
log_print("Logical extent %d to %d:",
|
||||
log_print("Logical extent %u to %u:",
|
||||
seg->le, seg->le + seg->len - 1);
|
||||
|
||||
log_print(" Type\t\t%s", get_segtype_string(seg->type));
|
||||
if (seg->type == SEG_STRIPED && seg->stripes == 1)
|
||||
log_print(" Type\t\tlinear");
|
||||
else
|
||||
log_print(" Type\t\t%s",
|
||||
get_segtype_string(seg->type));
|
||||
|
||||
switch (seg->type) {
|
||||
case SEG_STRIPED:
|
||||
if (seg->stripes == 1)
|
||||
_display_stripe(seg, 0, " ");
|
||||
else {
|
||||
log_print(" Stripes\t\t%d", seg->stripes);
|
||||
log_print(" Stripe size\t\t%d",
|
||||
seg->stripe_size);
|
||||
log_print(" Stripes\t\t%u", seg->stripes);
|
||||
log_print(" Stripe size\t\t%u KB",
|
||||
seg->stripe_size / 2);
|
||||
|
||||
for (s = 0; s < seg->stripes; s++) {
|
||||
log_print(" Stripe %d:", s);
|
||||
@@ -437,7 +538,6 @@ void vgdisplay_full(struct volume_group *vg)
|
||||
{
|
||||
uint32_t access;
|
||||
uint32_t active_pvs;
|
||||
char *s1;
|
||||
char uuid[64];
|
||||
|
||||
if (vg->status & PARTIAL_VG)
|
||||
@@ -483,28 +583,33 @@ void vgdisplay_full(struct volume_group *vg)
|
||||
log_print("Cur PV %u", vg->pv_count);
|
||||
log_print("Act PV %u", active_pvs);
|
||||
|
||||
s1 = display_size((uint64_t) vg->extent_count * (vg->extent_size / 2),
|
||||
SIZE_SHORT);
|
||||
log_print("VG Size %s", s1);
|
||||
dbg_free(s1);
|
||||
log_print("VG Size %s",
|
||||
display_size(vg->cmd,
|
||||
(uint64_t) vg->extent_count * (vg->extent_size /
|
||||
2), SIZE_SHORT));
|
||||
|
||||
s1 = display_size(vg->extent_size / 2, SIZE_SHORT);
|
||||
log_print("PE Size %s", s1);
|
||||
dbg_free(s1);
|
||||
log_print("PE Size %s",
|
||||
display_size(vg->cmd, vg->extent_size / 2, SIZE_SHORT));
|
||||
|
||||
log_print("Total PE %u", vg->extent_count);
|
||||
|
||||
s1 = display_size(((uint64_t)
|
||||
vg->extent_count - vg->free_count) *
|
||||
(vg->extent_size / 2), SIZE_SHORT);
|
||||
log_print("Alloc PE / Size %u / %s",
|
||||
vg->extent_count - vg->free_count, s1);
|
||||
dbg_free(s1);
|
||||
vg->extent_count - vg->free_count, display_size(vg->cmd,
|
||||
((uint64_t)
|
||||
vg->
|
||||
extent_count
|
||||
-
|
||||
vg->
|
||||
free_count) *
|
||||
(vg->
|
||||
extent_size /
|
||||
2),
|
||||
SIZE_SHORT));
|
||||
|
||||
s1 = display_size((uint64_t) vg->free_count * (vg->extent_size / 2),
|
||||
SIZE_SHORT);
|
||||
log_print("Free PE / Size %u / %s", vg->free_count, s1);
|
||||
dbg_free(s1);
|
||||
log_print("Free PE / Size %u / %s", vg->free_count,
|
||||
display_size(vg->cmd,
|
||||
(uint64_t) vg->free_count * (vg->extent_size /
|
||||
2), SIZE_SHORT));
|
||||
|
||||
if (!id_write_format(&vg->id, uuid, sizeof(uuid))) {
|
||||
stack;
|
||||
@@ -524,16 +629,15 @@ void vgdisplay_colons(struct volume_group *vg)
|
||||
|
||||
void vgdisplay_short(struct volume_group *vg)
|
||||
{
|
||||
char *s1, *s2, *s3;
|
||||
s1 = display_size(vg->extent_count * vg->extent_size / 2, SIZE_SHORT);
|
||||
s2 = display_size((vg->extent_count -
|
||||
vg->free_count) * vg->extent_size / 2, SIZE_SHORT);
|
||||
s3 = display_size(vg->free_count * vg->extent_size / 2, SIZE_SHORT);
|
||||
log_print("\"%s\" %-9s [%-9s used / %s free]", vg->name,
|
||||
/********* FIXME if "open" print "/used" else print "/idle"??? ******/
|
||||
s1, s2, s3);
|
||||
dbg_free(s1);
|
||||
dbg_free(s2);
|
||||
dbg_free(s3);
|
||||
display_size(vg->cmd, vg->extent_count * vg->extent_size / 2,
|
||||
SIZE_SHORT), display_size(vg->cmd,
|
||||
(vg->extent_count -
|
||||
vg->free_count) *
|
||||
vg->extent_size / 2,
|
||||
SIZE_SHORT),
|
||||
display_size(vg->cmd, vg->free_count * vg->extent_size / 2,
|
||||
SIZE_SHORT));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,14 +25,17 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef enum { SIZE_LONG = 0, SIZE_SHORT = 1 } size_len_t;
|
||||
typedef enum { SIZE_LONG = 0, SIZE_SHORT = 1, SIZE_UNIT = 2 } size_len_t;
|
||||
|
||||
uint64_t units_to_bytes(const char *units, char *unit_type);
|
||||
|
||||
/* Specify size in KB */
|
||||
char *display_size(uint64_t size, size_len_t sl);
|
||||
const char *display_size(struct cmd_context *cmd, uint64_t size, size_len_t sl);
|
||||
char *display_uuid(char *uuidstr);
|
||||
|
||||
void pvdisplay_colons(struct physical_volume *pv);
|
||||
void pvdisplay_full(struct physical_volume *pv, void *handle);
|
||||
void pvdisplay_full(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
void *handle);
|
||||
int pvdisplay_short(struct cmd_context *cmd, struct volume_group *vg,
|
||||
struct physical_volume *pv, void *handle);
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "dev-cache.h"
|
||||
#include "filter.h"
|
||||
#include "lvm-string.h"
|
||||
#include "config.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -39,7 +40,12 @@ typedef struct {
|
||||
|
||||
static int _md_major = -1;
|
||||
|
||||
/* FIXME Move list into config file */
|
||||
int md_major(void)
|
||||
{
|
||||
return _md_major;
|
||||
}
|
||||
|
||||
/* This list can be supplemented with devices/types in the config file */
|
||||
static device_info_t device_info[] = {
|
||||
{"ide", 16}, /* IDE disk */
|
||||
{"sd", 16}, /* SCSI disk */
|
||||
@@ -55,10 +61,8 @@ static device_info_t device_info[] = {
|
||||
{NULL, 0}
|
||||
};
|
||||
|
||||
static int *scan_proc_dev(const char *proc);
|
||||
|
||||
static int passes_lvm_type_device_filter(struct dev_filter *f,
|
||||
struct device *dev)
|
||||
static int _passes_lvm_type_device_filter(struct dev_filter *f,
|
||||
struct device *dev)
|
||||
{
|
||||
int fd;
|
||||
const char *name = dev_name(dev);
|
||||
@@ -78,48 +82,18 @@ static int passes_lvm_type_device_filter(struct dev_filter *f,
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct dev_filter *lvm_type_filter_create(const char *proc)
|
||||
{
|
||||
struct dev_filter *f;
|
||||
|
||||
if (!(f = dbg_malloc(sizeof(struct dev_filter)))) {
|
||||
log_error("LVM type filter allocation failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
f->passes_filter = passes_lvm_type_device_filter;
|
||||
f->destroy = lvm_type_filter_destroy;
|
||||
|
||||
if (!(f->private = scan_proc_dev(proc)))
|
||||
return NULL;
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
int md_major(void)
|
||||
{
|
||||
return _md_major;
|
||||
}
|
||||
|
||||
void lvm_type_filter_destroy(struct dev_filter *f)
|
||||
{
|
||||
dbg_free(f->private);
|
||||
dbg_free(f);
|
||||
return;
|
||||
}
|
||||
|
||||
static int *scan_proc_dev(const char *proc)
|
||||
static int *_scan_proc_dev(const char *proc, struct config_node *cn)
|
||||
{
|
||||
char line[80];
|
||||
char proc_devices[PATH_MAX];
|
||||
FILE *pd = NULL;
|
||||
int ret = 0;
|
||||
int i, j = 0;
|
||||
int line_maj = 0;
|
||||
int blocksection = 0;
|
||||
int dev_len = 0;
|
||||
|
||||
struct config_value *cv;
|
||||
int *max_partitions_by_major;
|
||||
char *name;
|
||||
|
||||
if (!(max_partitions_by_major =
|
||||
dbg_malloc(sizeof(int) * NUMBER_OF_MAJORS))) {
|
||||
@@ -170,12 +144,44 @@ static int *scan_proc_dev(const char *proc)
|
||||
for (j = 0; device_info[j].name != NULL; j++) {
|
||||
|
||||
dev_len = strlen(device_info[j].name);
|
||||
if (dev_len <= strlen(line + i)
|
||||
&& !strncmp(device_info[j].name, line + i, dev_len)
|
||||
&& (line_maj < NUMBER_OF_MAJORS)) {
|
||||
if (dev_len <= strlen(line + i) &&
|
||||
!strncmp(device_info[j].name, line + i, dev_len) &&
|
||||
(line_maj < NUMBER_OF_MAJORS)) {
|
||||
max_partitions_by_major[line_maj] =
|
||||
device_info[j].max_partitions;
|
||||
ret++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (max_partitions_by_major[line_maj] || !cn)
|
||||
continue;
|
||||
|
||||
/* Check devices/types for local variations */
|
||||
for (cv = cn->v; cv; cv = cv->next) {
|
||||
if (cv->type != CFG_STRING) {
|
||||
log_error("Expecting string in devices/types "
|
||||
"in config file");
|
||||
return NULL;
|
||||
}
|
||||
dev_len = strlen(cv->v.str);
|
||||
name = cv->v.str;
|
||||
cv = cv->next;
|
||||
if (!cv || cv->type != CFG_INT) {
|
||||
log_error("Max partition count missing for %s "
|
||||
"in devices/types in config file",
|
||||
name);
|
||||
return NULL;
|
||||
}
|
||||
if (!cv->v.i) {
|
||||
log_error("Zero partition count invalid for "
|
||||
"%s in devices/types in config file",
|
||||
name);
|
||||
return NULL;
|
||||
}
|
||||
if (dev_len <= strlen(line + i) &&
|
||||
!strncmp(name, line + i, dev_len) &&
|
||||
(line_maj < NUMBER_OF_MAJORS)) {
|
||||
max_partitions_by_major[line_maj] = cv->v.i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -183,3 +189,29 @@ static int *scan_proc_dev(const char *proc)
|
||||
fclose(pd);
|
||||
return max_partitions_by_major;
|
||||
}
|
||||
|
||||
struct dev_filter *lvm_type_filter_create(const char *proc,
|
||||
struct config_node *cn)
|
||||
{
|
||||
struct dev_filter *f;
|
||||
|
||||
if (!(f = dbg_malloc(sizeof(struct dev_filter)))) {
|
||||
log_error("LVM type filter allocation failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
f->passes_filter = _passes_lvm_type_device_filter;
|
||||
f->destroy = lvm_type_filter_destroy;
|
||||
|
||||
if (!(f->private = _scan_proc_dev(proc, cn)))
|
||||
return NULL;
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
void lvm_type_filter_destroy(struct dev_filter *f)
|
||||
{
|
||||
dbg_free(f->private);
|
||||
dbg_free(f);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -21,11 +21,13 @@
|
||||
#ifndef _LVM_FILTER_H
|
||||
#define _LVM_FILTER_H
|
||||
|
||||
struct dev_filter *lvm_type_filter_create(const char *proc);
|
||||
#include "config.h"
|
||||
|
||||
struct dev_filter *lvm_type_filter_create(const char *proc,
|
||||
struct config_node *cn);
|
||||
|
||||
void lvm_type_filter_destroy(struct dev_filter *f);
|
||||
|
||||
int md_major(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
Base {
|
||||
global:
|
||||
init_format;
|
||||
local:
|
||||
|
||||
@@ -297,14 +297,11 @@ static int _pv_setup(struct format_type *fmt,
|
||||
uint64_t pvmetadatasize, struct list *mdas,
|
||||
struct physical_volume *pv, struct volume_group *vg)
|
||||
{
|
||||
char *sz;
|
||||
|
||||
if (pv->size > MAX_PV_SIZE)
|
||||
pv->size--;
|
||||
if (pv->size > MAX_PV_SIZE) {
|
||||
log_error("Physical volumes cannot be bigger than %s",
|
||||
sz = display_size(MAX_PV_SIZE / 2, SIZE_SHORT));
|
||||
dbg_free(sz);
|
||||
display_size(fmt->cmd, MAX_PV_SIZE / 2, SIZE_SHORT));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -365,9 +362,9 @@ static int _lv_setup(struct format_instance *fid, struct logical_volume *lv)
|
||||
return 0;
|
||||
}
|
||||
if (lv->size > max_size) {
|
||||
char *dummy = display_size(max_size, SIZE_SHORT);
|
||||
log_error("logical volumes cannot be larger than %s", dummy);
|
||||
dbg_free(dummy);
|
||||
log_error("logical volumes cannot be larger than %s",
|
||||
display_size(fid->fmt->cmd, max_size / 2,
|
||||
SIZE_SHORT));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -447,22 +444,20 @@ int _vg_setup(struct format_instance *fid, struct volume_group *vg)
|
||||
vg->max_pv = MAX_PV - 1;
|
||||
|
||||
if (vg->extent_size > MAX_PE_SIZE || vg->extent_size < MIN_PE_SIZE) {
|
||||
char *dummy, *dummy2;
|
||||
|
||||
log_error("Extent size must be between %s and %s",
|
||||
(dummy = display_size(MIN_PE_SIZE / 2, SIZE_SHORT)),
|
||||
(dummy2 = display_size(MAX_PE_SIZE / 2, SIZE_SHORT)));
|
||||
display_size(fid->fmt->cmd, MIN_PE_SIZE / 2,
|
||||
SIZE_SHORT), display_size(fid->fmt->cmd,
|
||||
MAX_PE_SIZE /
|
||||
2,
|
||||
SIZE_SHORT));
|
||||
|
||||
dbg_free(dummy);
|
||||
dbg_free(dummy2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (vg->extent_size % MIN_PE_SIZE) {
|
||||
char *dummy;
|
||||
log_error("Extent size must be multiple of %s",
|
||||
(dummy = display_size(MIN_PE_SIZE / 2, SIZE_SHORT)));
|
||||
dbg_free(dummy);
|
||||
display_size(fid->fmt->cmd, MIN_PE_SIZE / 2,
|
||||
SIZE_SHORT));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ struct text_context {
|
||||
|
||||
/*
|
||||
* NOTE: Currently there can be only one vg per text file, and locking
|
||||
* assumes VG's metadata is only held in metadata areas on PVs
|
||||
* assumes VG's metadata is only held in metadata areas on PVs
|
||||
* inside the VG.
|
||||
*/
|
||||
|
||||
@@ -65,17 +65,19 @@ static int _vg_setup(struct format_instance *fid, struct volume_group *vg)
|
||||
|
||||
static int _lv_setup(struct format_instance *fid, struct logical_volume *lv)
|
||||
{
|
||||
/******** FIXME Any LV size restriction?
|
||||
uint64_t max_size = UINT_MAX;
|
||||
|
||||
if (!*lv->lvid.s)
|
||||
lvid_create(&lv->lvid, &lv->vg->id);
|
||||
|
||||
if (lv->size > max_size) {
|
||||
char *dummy = display_size(max_size, SIZE_SHORT);
|
||||
char *dummy = display_size(max_size / 2, SIZE_SHORT);
|
||||
log_error("logical volumes cannot be larger than %s", dummy);
|
||||
dbg_free(dummy);
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
if (!*lv->lvid.s)
|
||||
lvid_create(&lv->lvid, &lv->vg->id);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -625,12 +627,12 @@ static int _vg_commit_file_backup(struct format_instance *fid,
|
||||
log_debug("Renaming %s to %s", tc->path_edit, tc->path_live);
|
||||
if (rename(tc->path_edit, tc->path_live)) {
|
||||
log_error("%s: rename to %s failed: %s", tc->path_edit,
|
||||
tc->path_edit, strerror(errno));
|
||||
tc->path_live, strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
sync();
|
||||
sync_dir(tc->path_edit);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -664,7 +666,7 @@ static int _vg_commit_file(struct format_instance *fid, struct volume_group *vg,
|
||||
log_error("%s: rename to %s failed: %s",
|
||||
tc->path_live, newname,
|
||||
strerror(errno));
|
||||
sync();
|
||||
sync_dir(newname);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -688,7 +690,7 @@ static int _vg_remove_file(struct format_instance *fid, struct volume_group *vg,
|
||||
return 0;
|
||||
}
|
||||
|
||||
sync();
|
||||
sync_dir(tc->path_live);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h> /* FILE */
|
||||
#include <string.h> /* strerror() */
|
||||
#include <stdio.h> /* FILE */
|
||||
#include <string.h> /* strerror() */
|
||||
#include <errno.h>
|
||||
|
||||
#define _LOG_DEBUG 7
|
||||
@@ -65,7 +65,7 @@ int ignorelockingfailure(void);
|
||||
void log_suppress(int suppress);
|
||||
|
||||
void print_log(int level, const char *file, int line, const char *format, ...)
|
||||
__attribute__ (( format (printf, 4, 5) ));
|
||||
__attribute__ ((format(printf, 4, 5)));
|
||||
|
||||
#define plog(l, x...) print_log(l, __FILE__, __LINE__ , ## x)
|
||||
|
||||
@@ -90,4 +90,3 @@ void print_log(int level, const char *file, int line, const char *format, ...)
|
||||
log_info("%s: %s failed: %s", y, x, strerror(errno))
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -137,6 +137,7 @@ int vg_add_snapshot(struct logical_volume *origin,
|
||||
cow->status &= ~VISIBLE_LV;
|
||||
sl->snapshot = s;
|
||||
list_add(&origin->vg->snapshots, &sl->list);
|
||||
origin->vg->snapshot_count++;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -151,6 +152,7 @@ int vg_remove_snapshot(struct volume_group *vg, struct logical_volume *cow)
|
||||
|
||||
if (sl->snapshot->cow == cow) {
|
||||
list_del(slh);
|
||||
vg->snapshot_count--;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,3 +194,35 @@ int is_empty_dir(const char *dir)
|
||||
|
||||
return dirent ? 0 : 1;
|
||||
}
|
||||
|
||||
void sync_dir(const char *file)
|
||||
{
|
||||
int fd;
|
||||
char *dir, *c;
|
||||
|
||||
if (!(dir = dbg_strdup(file))) {
|
||||
log_error("sync_dir failed in strdup");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!dir_exists(dir)) {
|
||||
c = dir + strlen(dir);
|
||||
while (*c != '/' && c > dir)
|
||||
c--;
|
||||
|
||||
*c = '\0';
|
||||
}
|
||||
|
||||
if ((fd = open(dir, O_RDONLY)) == -1) {
|
||||
log_sys_error("open", dir);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (fsync(fd) == -1)
|
||||
log_sys_error("fsync", dir);
|
||||
|
||||
close(fd);
|
||||
|
||||
out:
|
||||
dbg_free(dir);
|
||||
}
|
||||
|
||||
@@ -32,3 +32,6 @@ int is_empty_dir(const char *dir);
|
||||
* if directory was successfully created (or already exists), else 0.
|
||||
*/
|
||||
int create_dir(const char *dir);
|
||||
|
||||
/* Sync directory changes */
|
||||
void sync_dir(const char *file);
|
||||
|
||||
52
lib/report/columns.h
Normal file
52
lib/report/columns.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Sistina Software (UK) Limited.
|
||||
*
|
||||
* This file is released under the LGPL.
|
||||
*/
|
||||
|
||||
/* Report type, Containing struct, Field type, Report heading,
|
||||
* Data field with struct to pass to display function, Minimum display width,
|
||||
* Display Fn, Unique format identifier */
|
||||
FIELD(LVS, lv, STR, "LV UUID", lvid.id[1], 38, uuid, "lv_uuid")
|
||||
FIELD(LVS, lv, STR, "LV", name, 4, string, "lv_name")
|
||||
FIELD(LVS, lv, STR, "Attr", lvid, 4, lvstatus, "lv_attr")
|
||||
FIELD(LVS, lv, NUM, "Min", minor, 3, int32, "lv_minor")
|
||||
FIELD(LVS, lv, NUM, "LSize", size, 5, size64, "lv_size")
|
||||
FIELD(LVS, lv, NUM, "#Seg", lvid, 4, lvsegcount, "seg_count")
|
||||
FIELD(LVS, lv, STR, "Origin", lvid, 6, origin, "origin")
|
||||
FIELD(LVS, lv, NUM, "Snap%", lvid, 6, snpercent, "snap_percent")
|
||||
|
||||
FIELD(PVS, pv, STR, "Fmt", id, 3, pvfmt, "pv_fmt")
|
||||
FIELD(PVS, pv, STR, "PV UUID", id, 38, uuid, "pv_uuid")
|
||||
FIELD(PVS, pv, NUM, "PSize", id, 5, pvsize, "pv_size")
|
||||
FIELD(PVS, pv, NUM, "PFree", id, 5, pvfree, "pv_free")
|
||||
FIELD(PVS, pv, NUM, "Used", id, 4, pvused, "pv_used")
|
||||
FIELD(PVS, pv, STR, "PV", dev, 10, dev_name, "pv_name")
|
||||
FIELD(PVS, pv, STR, "Attr", status, 4, pvstatus, "pv_attr")
|
||||
FIELD(PVS, pv, NUM, "PE", pe_count, 3, uint32, "pv_pe_count")
|
||||
FIELD(PVS, pv, NUM, "Alloc", pe_alloc_count, 5, uint32, "pv_pe_alloc_count")
|
||||
|
||||
FIELD(VGS, vg, STR, "Fmt", cmd, 3, vgfmt, "vg_fmt")
|
||||
FIELD(VGS, vg, STR, "VG UUID", id, 38, uuid, "vg_uuid")
|
||||
FIELD(VGS, vg, STR, "VG", name, 4, string, "vg_name")
|
||||
FIELD(VGS, vg, STR, "Attr", status, 4, vgstatus, "vg_attr")
|
||||
FIELD(VGS, vg, NUM, "VSize", cmd, 5, vgsize, "vg_size")
|
||||
FIELD(VGS, vg, NUM, "VFree", cmd, 5, vgfree, "vg_free")
|
||||
FIELD(VGS, vg, STR, "SYS ID", system_id, 6, string, "vg_sysid")
|
||||
FIELD(VGS, vg, NUM, "Ext", extent_size, 3, size32, "vg_extent_size")
|
||||
FIELD(VGS, vg, NUM, "#Ext", extent_count, 4, uint32, "vg_extent_count")
|
||||
FIELD(VGS, vg, NUM, "Free", free_count, 4, uint32, "vg_free_count")
|
||||
FIELD(VGS, vg, NUM, "MaxLV", max_lv, 5, uint32, "max_lv")
|
||||
FIELD(VGS, vg, NUM, "MaxPV", max_pv, 5, uint32, "max_pv")
|
||||
FIELD(VGS, vg, NUM, "#PV", pv_count, 3, uint32, "pv_count")
|
||||
FIELD(VGS, vg, NUM, "#LV", lv_count, 3, uint32, "lv_count")
|
||||
FIELD(VGS, vg, NUM, "#SN", snapshot_count, 3, uint32, "snap_count")
|
||||
FIELD(VGS, vg, NUM, "Seq", seqno, 3, uint32, "vg_seqno")
|
||||
|
||||
FIELD(SEGS, seg, STR, "Type", list, 4, segtype, "segtype")
|
||||
FIELD(SEGS, seg, NUM, "#Str", stripes, 4, uint32, "stripes")
|
||||
FIELD(SEGS, seg, NUM, "Stripe", stripe_size, 6, size32, "stripesize")
|
||||
FIELD(SEGS, seg, NUM, "Chunk", chunk_size, 5, size32, "chunksize")
|
||||
FIELD(SEGS, seg, NUM, "Start", list, 5, segstart, "seg_start")
|
||||
FIELD(SEGS, seg, NUM, "SSize", list, 5, segsize, "seg_size")
|
||||
|
||||
1067
lib/report/report.c
Normal file
1067
lib/report/report.c
Normal file
File diff suppressed because it is too large
Load Diff
43
lib/report/report.h
Normal file
43
lib/report/report.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Sistina Software
|
||||
*
|
||||
* This LVM library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This LVM library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this LVM library; if not, write to the Free
|
||||
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
* MA 02111-1307, USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _LVM_REPORT_H
|
||||
#define _LVM_REPORT_H
|
||||
|
||||
#include "metadata.h"
|
||||
|
||||
typedef enum { LVS = 1, PVS = 2, VGS = 4, SEGS = 8 } report_type_t;
|
||||
|
||||
struct field;
|
||||
struct report_handle;
|
||||
|
||||
typedef int (*field_report_fn) (struct report_handle * dh, struct field * field,
|
||||
const void *data);
|
||||
|
||||
void *report_init(struct cmd_context *cmd, const char *format, const char *keys,
|
||||
report_type_t *report_type, const char *separator,
|
||||
int aligned, int buffered, int headings);
|
||||
void report_free(void *handle);
|
||||
int report_object(void *handle, struct volume_group *vg,
|
||||
struct logical_volume *lv, struct physical_volume *pv,
|
||||
struct lv_segment *seg);
|
||||
int report_output(void *handle);
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
Base {
|
||||
global:
|
||||
dm_log_init;
|
||||
dm_task_create;
|
||||
|
||||
@@ -13,11 +13,13 @@ struct list {
|
||||
struct list *n, *p;
|
||||
};
|
||||
|
||||
static inline void list_init(struct list *head) {
|
||||
static inline void list_init(struct list *head)
|
||||
{
|
||||
head->n = head->p = head;
|
||||
}
|
||||
|
||||
static inline void list_add(struct list *head, struct list *elem) {
|
||||
static inline void list_add(struct list *head, struct list *elem)
|
||||
{
|
||||
assert(head->n);
|
||||
|
||||
elem->n = head;
|
||||
@@ -27,7 +29,8 @@ static inline void list_add(struct list *head, struct list *elem) {
|
||||
head->p = elem;
|
||||
}
|
||||
|
||||
static inline void list_add_h(struct list *head, struct list *elem) {
|
||||
static inline void list_add_h(struct list *head, struct list *elem)
|
||||
{
|
||||
assert(head->n);
|
||||
|
||||
elem->n = head->n;
|
||||
@@ -37,27 +40,35 @@ static inline void list_add_h(struct list *head, struct list *elem) {
|
||||
head->n = elem;
|
||||
}
|
||||
|
||||
static inline void list_del(struct list *elem) {
|
||||
static inline void list_del(struct list *elem)
|
||||
{
|
||||
elem->n->p = elem->p;
|
||||
elem->p->n = elem->n;
|
||||
}
|
||||
|
||||
static inline int list_empty(struct list *head) {
|
||||
static inline int list_empty(struct list *head)
|
||||
{
|
||||
return head->n == head;
|
||||
}
|
||||
|
||||
static inline int list_end(struct list *head, struct list *elem)
|
||||
{
|
||||
return elem->n == head;
|
||||
}
|
||||
|
||||
#define list_iterate(v, head) \
|
||||
for (v = (head)->n; v != head; v = v->n)
|
||||
|
||||
#define list_iterate_safe(v, t, head) \
|
||||
for (v = (head)->n, t = v->n; v != head; v = t, t = v->n)
|
||||
|
||||
static inline int list_size(struct list *head) {
|
||||
static inline int list_size(struct list *head)
|
||||
{
|
||||
int s = 0;
|
||||
struct list *v;
|
||||
|
||||
list_iterate(v, head)
|
||||
s++;
|
||||
s++;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -22,11 +22,11 @@ VPATH = @srcdir@
|
||||
|
||||
MAN5=lvm.conf.5
|
||||
MAN8=lvchange.8 lvcreate.8 lvdisplay.8 lvextend.8 lvm.8 lvmchange.8 \
|
||||
lvreduce.8 lvremove.8 lvrename.8 lvscan.8 pvchange.8 \
|
||||
pvcreate.8 pvdisplay.8 pvremove.8 pvscan.8 vgcfgbackup.8 \
|
||||
lvreduce.8 lvremove.8 lvrename.8 lvs.8 lvscan.8 pvchange.8 \
|
||||
pvcreate.8 pvdisplay.8 pvremove.8 pvs.8 pvscan.8 vgcfgbackup.8 \
|
||||
vgcfgrestore.8 vgchange.8 vgck.8 vgcreate.8 \
|
||||
vgconvert.8 vgdisplay.8 vgextend.8 vgmerge.8 vgreduce.8 vgremove.8 \
|
||||
vgrename.8 vgscan.8
|
||||
vgrename.8 vgs.8 vgscan.8
|
||||
MAN5DIR=${mandir}/man5
|
||||
MAN8DIR=${mandir}/man8
|
||||
|
||||
|
||||
@@ -91,6 +91,13 @@ Defaults to "/etc/lvm/.cache".
|
||||
\fBwrite_cache_state\fP \(em Set to 0 to disable the writing out of the
|
||||
persistent filter cache file when \fBlvm\fP exits.
|
||||
Defaults to 1.
|
||||
.IP
|
||||
\fBtypes\fP \(em List of pairs of additional acceptable block device types
|
||||
found in /proc/devices together with maximum (non-zero) number of
|
||||
partitions (normally 16). By default, LVM2 supports ide, sd, md, loop,
|
||||
dasd, dac960, nbd, ida, cciss, ubd and ataraid. Block devices with major
|
||||
numbers of different types are ignored by LVM2. Example:
|
||||
\fBtypes = ["fd", 16]\fP
|
||||
.TP
|
||||
\fBlog\fP \(em Default log settings
|
||||
.IP
|
||||
|
||||
64
man/lvs.8
Normal file
64
man/lvs.8
Normal file
@@ -0,0 +1,64 @@
|
||||
.TH LVS 8 "LVM TOOLS" "Sistina Software UK" \" -*- nroff -*-
|
||||
.SH NAME
|
||||
lvs \- report information about logical volumes
|
||||
.SH SYNOPSIS
|
||||
.B lvs
|
||||
[\-\-aligned] [\-d/\-\-debug] [\-h/\-?/\-\-help]
|
||||
[\-\-ignorelockingfailure] [\-\-noheadings] [\-\-nosuffix]
|
||||
[\-o/\-\-options [+]Field[,Field]]
|
||||
[\-O/\-\-sort [+/-]Key1[,[+/-]Key2[,...]]]
|
||||
[\-P/\-\-partial] [\-\-segments]
|
||||
[\-\-separator Separator] [\-\-unbuffered]
|
||||
[\-\-units hsbkmgtHKMGT]
|
||||
[\-v/\-\-verbose]
|
||||
[\-\-version] [VolumeGroupName [VolumeGroupName...]]
|
||||
.SH DESCRIPTION
|
||||
vgs produces formatted output about volume groups
|
||||
.SH OPTIONS
|
||||
See \fBlvm\fP for common options.
|
||||
.TP
|
||||
.I \-\-aligned
|
||||
Use with \-\-separator to align the output columns.
|
||||
.TP
|
||||
.I \-\-noheadings
|
||||
Suppress the headings line that is normally the first line of output.
|
||||
Useful if grepping the output.
|
||||
.TP
|
||||
.I \-\-nosuffix
|
||||
Suppress the suffix on output sizes. Use with \-\-units (except h and H)
|
||||
if processing the output.
|
||||
.TP
|
||||
.I \-o, \-\-options
|
||||
Comma-separated ordered list of columns. Precede the list with '+' to append
|
||||
to the default selection of columns. Column names are:
|
||||
lv_uuid, lv_name, lv_attr, lv_minor, lv_size, seg_count, origin,
|
||||
snap_percent (suppressed if no kernel driver), segtype, stripes,
|
||||
stripesize, chunksize, seg_start, seg_size.
|
||||
With \-\-segments, any "seg_" prefixes are optional; otherwise any "lv_"
|
||||
prefixes are optional. Columns mentioned in \fBvgs (8)\fP
|
||||
can also be chosen
|
||||
The lv_attr bits are: (o)rigin, (s)napshot, (w)riteable, (r)eadonly,
|
||||
(c)ontiguous allocation, (n)ext free allocation, fixed (m)inor, (s)uspended,
|
||||
(a)ctive, device (o)pen.
|
||||
.TP
|
||||
.I \-\-segments
|
||||
Use default columns that emphasize segment information.
|
||||
.TP
|
||||
.I \-O, \-\-sort
|
||||
Comma-separated ordered list of columns to sort by. Replaces the default
|
||||
selection. Precede any column with - for a reverse sort on that column.
|
||||
.TP
|
||||
.I \-\-separator Separator
|
||||
String to use to separate each column. Useful if grepping the output.
|
||||
.TP
|
||||
.I \-\-unbuffered
|
||||
Produce output immediately without sorting or aligning the columns properly.
|
||||
.TP
|
||||
.I \-\-units hsbkmgtHKMGT
|
||||
All sizes are output in these units: (h)uman-readable, (s)ectors, (b)ytes,
|
||||
(k)ilobytes, (m)egabytes, (g)igabytes, (t)erabytes. Capitalise to use multiples
|
||||
of 1000 (S.I.) instead of 1024. Can also specify custom (u)nits e.g.
|
||||
\-\-units 3M
|
||||
.SH SEE ALSO
|
||||
.BR pvs (8),
|
||||
.BR vgs (8)
|
||||
54
man/pvs.8
Normal file
54
man/pvs.8
Normal file
@@ -0,0 +1,54 @@
|
||||
.TH PVS 8 "LVM TOOLS" "Sistina Software UK" \" -*- nroff -*-
|
||||
.SH NAME
|
||||
pvs \- report information about physical volumes
|
||||
.SH SYNOPSIS
|
||||
.B pvs
|
||||
[\-\-aligned] [\-d/\-\-debug] [\-h/\-?/\-\-help]
|
||||
[\-\-ignorelockingfailure] [\-\-noheadings] [\-\-nosuffix]
|
||||
[\-o/\-\-options [+]Field[,Field]]
|
||||
[\-O/\-\-sort [+/-]Key1[,[+/-]Key2[,...]]]
|
||||
[\-\-separator Separator] [\-\-unbuffered]
|
||||
[\-\-units hsbkmgtHKMGT]
|
||||
[\-v/\-\-verbose]
|
||||
[\-\-version] [PhysicalVolume [PhysicalVolume...]]
|
||||
.SH DESCRIPTION
|
||||
pvs produces formatted output about physical volumes
|
||||
.SH OPTIONS
|
||||
See \fBlvm\fP for common options.
|
||||
.TP
|
||||
.I \-\-aligned
|
||||
Use with \-\-separator to align the output columns.
|
||||
.TP
|
||||
.I \-\-noheadings
|
||||
Suppress the headings line that is normally the first line of output.
|
||||
Useful if grepping the output.
|
||||
.TP
|
||||
.I \-\-nosuffix
|
||||
Suppress the suffix on output sizes. Use with \-\-units (except h and H)
|
||||
if processing the output.
|
||||
.TP
|
||||
.I \-o, \-\-options
|
||||
Comma-separated ordered list of columns. Precede the list with '+' to append
|
||||
to the default selection of columns. Column names are: pv_fmt, pv_uuid,
|
||||
pv_size, pv_free, pv_used, pv_name, pv_attr, pv_pe_count, pv_pe_alloc_count.
|
||||
The "pv_" prefix is optional. Columns mentioned in \fBvgs (8)\fP can also
|
||||
be chosen. The pv_attr bits are: (a)llocatable and e(x)ported.
|
||||
.TP
|
||||
.I \-O, \-\-sort
|
||||
Comma-separated ordered list of columns to sort by. Replaces the default
|
||||
selection. Precede any column with - for a reverse sort on that column.
|
||||
.TP
|
||||
.I \-\-separator Separator
|
||||
String to use to separate each column. Useful if grepping the output.
|
||||
.TP
|
||||
.I \-\-unbuffered
|
||||
Produce output immediately without sorting or aligning the columns properly.
|
||||
.TP
|
||||
.I \-\-units hsbkmgtHKMGT
|
||||
All sizes are output in these units: (h)uman-readable, (s)ectors, (b)ytes,
|
||||
(k)ilobytes, (m)egabytes, (g)igabytes, (t)erabytes. Capitalise to use multiples
|
||||
of 1000 (S.I.) instead of 1024. Can also specify custom (u)nits e.g.
|
||||
\-\-units 3M
|
||||
.SH SEE ALSO
|
||||
.BR lvs (8),
|
||||
.BR vgs (8)
|
||||
@@ -18,6 +18,16 @@ allows you to restore the metadata
|
||||
of your volume groups from a text backup file produced by \fBvgcfgbackup\fP.
|
||||
.SH OPTIONS
|
||||
See \fBlvm\fP for common options.
|
||||
.SH REPLACING PHYSICAL VOLUMES
|
||||
\fBvgdisplay --partial --verbose\fP will show you the UUIDs and sizes of
|
||||
any PVs that are no longer present.
|
||||
If a PV in the VG is lost and you wish to substitute
|
||||
another of the same size, use
|
||||
\fBpvcreate --restorefile filename --uuid uuid\fP (plus additional
|
||||
arguments as appropriate) to initialise it with the same UUID as
|
||||
the missing PV. Repeat for all other missing PVs in the VG.
|
||||
Then use \fBvgcfgrestore --file filename\fP to restore the volume
|
||||
group's metadata.
|
||||
.SH SEE ALSO
|
||||
.BR lvm (8),
|
||||
.BR vgcreate (8)
|
||||
|
||||
58
man/vgs.8
Normal file
58
man/vgs.8
Normal file
@@ -0,0 +1,58 @@
|
||||
.TH VGS 8 "LVM TOOLS" "Sistina Software UK" \" -*- nroff -*-
|
||||
.SH NAME
|
||||
vgs \- report information about volume groups
|
||||
.SH SYNOPSIS
|
||||
.B vgs
|
||||
[\-\-aligned] [\-d/\-\-debug] [\-h/\-?/\-\-help]
|
||||
[\-\-ignorelockingfailure] [\-\-noheadings] [\-\-nosuffix]
|
||||
[\-o/\-\-options [+]Field[,Field]]
|
||||
[\-O/\-\-sort [+/-]Key1[,[+/-]Key2[,...]]]
|
||||
[\-P/\-\-partial]
|
||||
[\-\-separator Separator] [\-\-unbuffered]
|
||||
[\-\-units hsbkmgtHKMGT]
|
||||
[\-v/\-\-verbose]
|
||||
[\-\-version] [VolumeGroupName [VolumeGroupName...]]
|
||||
.SH DESCRIPTION
|
||||
vgs produces formatted output about volume groups
|
||||
.SH OPTIONS
|
||||
See \fBlvm\fP for common options.
|
||||
.TP
|
||||
.I \-\-aligned
|
||||
Use with \-\-separator to align the output columns.
|
||||
.TP
|
||||
.I \-\-noheadings
|
||||
Suppress the headings line that is normally the first line of output.
|
||||
Useful if grepping the output.
|
||||
.TP
|
||||
.I \-\-nosuffix
|
||||
Suppress the suffix on output sizes. Use with \-\-units (except h and H)
|
||||
if processing the output.
|
||||
.TP
|
||||
.I \-o, \-\-options
|
||||
Comma-separated ordered list of columns. Precede the list with '+' to append
|
||||
to the default selection of columns. Column names are: vg_fmt, vg_uuid,
|
||||
vg_name, vg_attr, vg_size, vg_free, vg_sysid, vg_extent_size, vg_extent_count,
|
||||
vg_free_count, max_lv, max_pv, pv_count, lv_count, snap_count, vg_seqno.
|
||||
Any "vg_" prefixes are optional. Columns mentioned in either \fBpvs (8)\fP
|
||||
or \fBlvs (8)\fP can also be chosen, but columns cannot be taken from both
|
||||
at the same time. The vg_attr bits are: (w)riteable, (r)eadonly,
|
||||
resi(z)eable, e(x)ported, (p)artial.
|
||||
.TP
|
||||
.I \-O, \-\-sort
|
||||
Comma-separated ordered list of columns to sort by. Replaces the default
|
||||
selection. Precede any column with - for a reverse sort on that column.
|
||||
.TP
|
||||
.I \-\-separator Separator
|
||||
String to use to separate each column. Useful if grepping the output.
|
||||
.TP
|
||||
.I \-\-unbuffered
|
||||
Produce output immediately without sorting or aligning the columns properly.
|
||||
.TP
|
||||
.I \-\-units hsbkmgtHKMGT
|
||||
All sizes are output in these units: (h)uman-readable, (s)ectors, (b)ytes,
|
||||
(k)ilobytes, (m)egabytes, (g)igabytes, (t)erabytes. Capitalise to use multiples
|
||||
of 1000 (S.I.) instead of 1024. Can also specify custom (u)nits e.g.
|
||||
\-\-units 3M
|
||||
.SH SEE ALSO
|
||||
.BR pvs (8),
|
||||
.BR lvs (8)
|
||||
@@ -39,6 +39,7 @@ SOURCES=\
|
||||
pvdisplay.c \
|
||||
pvremove.c \
|
||||
pvscan.c \
|
||||
report.c \
|
||||
toollib.c \
|
||||
vgcfgbackup.c \
|
||||
vgcfgrestore.c \
|
||||
@@ -67,8 +68,8 @@ lvm: $(OBJECTS) $(top_srcdir)/lib/liblvm.a
|
||||
$(CC) -o lvm $(OBJECTS) $(LD_FLAGS) -L$(top_srcdir)/lib \
|
||||
-L$(DESTDIR)/lib -llvm -ldevmapper $(LIBS) -ldl -rdynamic
|
||||
|
||||
.commands: commands.h cmdnames.h
|
||||
$(CC) -E -P cmdnames.h | grep -v help > .commands
|
||||
.commands: commands.h cmdnames.h Makefile
|
||||
$(CC) -E -P cmdnames.h | egrep -v '(help|version)' > .commands
|
||||
|
||||
install: $(TARGETS)
|
||||
$(INSTALL) -D -o $(OWNER) -g $(GROUP) -m 555 $(STRIP) lvm \
|
||||
|
||||
23
tools/args.h
23
tools/args.h
@@ -10,13 +10,19 @@
|
||||
*/
|
||||
arg(version_ARG, '\0', "version", NULL)
|
||||
arg(quiet_ARG, '\0', "quiet", NULL)
|
||||
arg(physicalvolumesize_ARG, '\0', "setphysicalvolumesize", size_arg)
|
||||
arg(physicalvolumesize_ARG, '\0', "setphysicalvolumesize", size_mb_arg)
|
||||
arg(ignorelockingfailure_ARG, '\0', "ignorelockingfailure", NULL)
|
||||
arg(metadatacopies_ARG, '\0', "metadatacopies", int_arg)
|
||||
arg(metadatasize_ARG, '\0', "metadatasize", size_arg)
|
||||
arg(metadatasize_ARG, '\0', "metadatasize", size_mb_arg)
|
||||
arg(restorefile_ARG, '\0', "restorefile", string_arg)
|
||||
arg(labelsector_ARG, '\0', "labelsector", int_arg)
|
||||
arg(driverloaded_ARG, '\0', "driverloaded", yes_no_arg)
|
||||
arg(aligned_ARG, '\0', "aligned", NULL)
|
||||
arg(unbuffered_ARG, '\0', "unbuffered", NULL)
|
||||
arg(noheadings_ARG, '\0', "noheadings", NULL)
|
||||
arg(segments_ARG, '\0', "segments", NULL)
|
||||
arg(units_ARG, '\0', "units", string_arg)
|
||||
arg(nosuffix_ARG, '\0', "nosuffix", NULL)
|
||||
|
||||
/* Allow some variations */
|
||||
arg(resizable_ARG, '\0', "resizable", yes_no_arg)
|
||||
@@ -30,8 +36,9 @@ arg(all_ARG, 'a', "all", NULL)
|
||||
arg(autobackup_ARG, 'A', "autobackup", yes_no_arg)
|
||||
arg(activevolumegroups_ARG, 'A', "activevolumegroups", NULL)
|
||||
arg(blockdevice_ARG, 'b', "blockdevice", NULL)
|
||||
arg(chunksize_ARG, 'c', "chunksize", size_arg)
|
||||
arg(chunksize_ARG, 'c', "chunksize", size_kb_arg)
|
||||
arg(colon_ARG, 'c', "colon", NULL)
|
||||
arg(columns_ARG, 'C', "columns", NULL)
|
||||
arg(contiguous_ARG, 'C', "contiguous", yes_no_arg)
|
||||
arg(debug_ARG, 'd', "debug", NULL)
|
||||
arg(disk_ARG, 'D', "disk", NULL)
|
||||
@@ -41,7 +48,8 @@ arg(file_ARG, 'f', "file", string_arg)
|
||||
arg(force_ARG, 'f', "force", NULL)
|
||||
arg(full_ARG, 'f', "full", NULL)
|
||||
arg(help_ARG, 'h', "help", NULL)
|
||||
arg(stripesize_ARG, 'I', "stripesize", size_arg)
|
||||
arg(help2_ARG, '?', "", NULL)
|
||||
arg(stripesize_ARG, 'I', "stripesize", size_kb_arg)
|
||||
arg(stripes_ARG, 'i', "stripes", int_arg)
|
||||
arg(iop_version_ARG, 'i', "iop_version", NULL)
|
||||
arg(logicalvolume_ARG, 'l', "logicalvolume", int_arg)
|
||||
@@ -49,7 +57,7 @@ arg(maxlogicalvolumes_ARG, 'l', "maxlogicalvolumes", int_arg)
|
||||
arg(extents_ARG, 'l', "extents", int_arg_with_sign)
|
||||
arg(lvmpartition_ARG, 'l', "lvmpartition", NULL)
|
||||
arg(list_ARG, 'l', "list", NULL)
|
||||
arg(size_ARG, 'L', "size", size_arg)
|
||||
arg(size_ARG, 'L', "size", size_mb_arg)
|
||||
arg(logicalextent_ARG, 'L', "logicalextent", int_arg_with_sign)
|
||||
arg(persistent_ARG, 'M', "persistent", yes_no_arg)
|
||||
arg(metadatatype_ARG, 'M', "metadatatype", metadatatype_arg)
|
||||
@@ -59,13 +67,16 @@ arg(name_ARG, 'n', "name", string_arg)
|
||||
arg(oldpath_ARG, 'n', "oldpath", NULL)
|
||||
arg(nofsck_ARG, 'n', "nofsck", NULL)
|
||||
arg(novolumegroup_ARG, 'n', "novolumegroup", NULL)
|
||||
arg(options_ARG, 'o', "options", string_arg)
|
||||
arg(sort_ARG, 'O', "sort", string_arg)
|
||||
arg(permission_ARG, 'p', "permission", permission_arg)
|
||||
arg(maxphysicalvolumes_ARG, 'p', "maxphysicalvolumes", int_arg)
|
||||
arg(partial_ARG, 'P', "partial", NULL)
|
||||
arg(physicalvolume_ARG, 'P', "physicalvolume", NULL)
|
||||
arg(readahead_ARG, 'r', "readahead", int_arg)
|
||||
arg(reset_ARG, 'R', "reset", NULL)
|
||||
arg(physicalextentsize_ARG, 's', "physicalextentsize", size_arg)
|
||||
arg(physicalextentsize_ARG, 's', "physicalextentsize", size_mb_arg)
|
||||
arg(separator_ARG, 's', "separator", string_arg)
|
||||
arg(stdin_ARG, 's', "stdin", NULL)
|
||||
arg(snapshot_ARG, 's', "snapshot", NULL)
|
||||
arg(short_ARG, 's', "short", NULL)
|
||||
|
||||
470
tools/commands.h
470
tools/commands.h
@@ -41,42 +41,41 @@ xx(help,
|
||||
xx(lvactivate,
|
||||
"Activate logical volume on given partition(s)",
|
||||
"lvactivate "
|
||||
"\t[-d/--debug]\n"
|
||||
"\t[-h/-?/--help]\n"
|
||||
"\t[-v/--verbose]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"Logical Volume(s)\n")
|
||||
***********/
|
||||
|
||||
xx(lvchange,
|
||||
"Change the attributes of logical volume(s)",
|
||||
"lvchange\n"
|
||||
"\t[-A/--autobackup y/n]\n"
|
||||
"\t[-a/--available y/n]\n"
|
||||
"\t[-C/--contiguous y/n]\n"
|
||||
"\t[-d/--debug]\n"
|
||||
"\t[-h/-?/--help]\n"
|
||||
"\t[-A|--autobackup y|n]\n"
|
||||
"\t[-a|--available y|n]\n"
|
||||
"\t[-C|--contiguous y|n]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[--ignorelockingfailure]\n"
|
||||
"\t[-M/--persistent y/n] [--minor minor]\n"
|
||||
"\t[-P/--partial] " "\n"
|
||||
"\t[-p/--permission r/rw]\n"
|
||||
"\t[-r/--readahead ReadAheadSectors]\n"
|
||||
"\t[-t/--test]\n"
|
||||
"\t[-v/--verbose]\n"
|
||||
"\t[-M|--persistent y|n] [--minor minor]\n"
|
||||
"\t[-P|--partial] " "\n"
|
||||
"\t[-p|--permission r|rw]\n"
|
||||
"\t[-r|--readahead ReadAheadSectors]\n"
|
||||
"\t[-t|--test]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"\t[--version]" "\n"
|
||||
"\tLogicalVolume[Path] [LogicalVolume[Path]...]\n",
|
||||
|
||||
autobackup_ARG, available_ARG, contiguous_ARG,
|
||||
minor_ARG, persistent_ARG, partial_ARG,
|
||||
permission_ARG, readahead_ARG, test_ARG,
|
||||
ignorelockingfailure_ARG)
|
||||
ignorelockingfailure_ARG, minor_ARG, partial_ARG, permission_ARG,
|
||||
persistent_ARG, readahead_ARG, test_ARG)
|
||||
|
||||
xx(lvcreate,
|
||||
"Create a logical volume",
|
||||
"lvcreate " "\n"
|
||||
"\t[-A|--autobackup {y|n}]\n"
|
||||
"\t[-c|--chunksize]\n"
|
||||
"\t[-C|--contiguous {y|n}]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[-h|-?|--help]\n"
|
||||
"\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n"
|
||||
"\t{-l|--extents LogicalExtentsNumber |\n"
|
||||
"\t -L|--size LogicalVolumeSize[kKmMgGtT]}\n"
|
||||
@@ -84,12 +83,29 @@ xx(lvcreate,
|
||||
"\t[-n|--name LogicalVolumeName]\n"
|
||||
"\t[-p|--permission {r|rw}]\n"
|
||||
"\t[-r|--readahead ReadAheadSectors]\n"
|
||||
"\t[-s|--snapshot]\n"
|
||||
"\t[-t|--test]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"\t[-Z|--zero {y|n}]\n"
|
||||
"\t[--version]\n"
|
||||
"\tVolumeGroupName [PhysicalVolumePath...]\n\n",
|
||||
"\tVolumeGroupName [PhysicalVolumePath...]\n\n"
|
||||
|
||||
"lvcreate -s|--snapshot\n"
|
||||
"\t[-c|--chunksize]\n"
|
||||
"\t[-A|--autobackup {y|n}]\n"
|
||||
"\t[-C|--contiguous {y|n}]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|-?|--help]\n"
|
||||
"\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n"
|
||||
"\t{-l|--extents LogicalExtentsNumber |\n"
|
||||
"\t -L|--size LogicalVolumeSize[kKmMgGtT]}\n"
|
||||
"\t[-M|--persistent {y|n}] [--minor minor]\n"
|
||||
"\t[-n|--name LogicalVolumeName]\n"
|
||||
"\t[-p|--permission {r|rw}]\n"
|
||||
"\t[-r|--readahead ReadAheadSectors]\n"
|
||||
"\t[-t|--test]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"\t[--version]\n"
|
||||
"\tOriginalLogicalVolume[Path] [PhysicalVolumePath...]\n\n",
|
||||
|
||||
autobackup_ARG, chunksize_ARG, contiguous_ARG, extents_ARG, minor_ARG,
|
||||
name_ARG, permission_ARG, persistent_ARG, readahead_ARG, size_ARG,
|
||||
@@ -98,28 +114,52 @@ xx(lvcreate,
|
||||
xx(lvdisplay,
|
||||
"Display information about a logical volume",
|
||||
"lvdisplay\n"
|
||||
"\t[-c/--colon]\n"
|
||||
"\t[-d/--debug]\n"
|
||||
"\t[-h/-?/--help]\n"
|
||||
"\t[-m/--maps]\n"
|
||||
"\t[-P/--partial] " "\n"
|
||||
"\t[-v/--verbose]\n"
|
||||
"\tLogicalVolume[Path] [LogicalVolume[Path]...]\n",
|
||||
"\t[-c|--colon]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[--ignorelockingfailure]\n"
|
||||
"\t[-m|--maps]\n"
|
||||
"\t[--nosuffix]\n"
|
||||
"\t[-P|--partial] " "\n"
|
||||
"\t[--units hsbkmgtHKMGT]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"\t[--version]" "\n"
|
||||
"\t[LogicalVolume[Path] [LogicalVolume[Path]...]]\n"
|
||||
"\n"
|
||||
"lvdisplay --columns|-C\n"
|
||||
"\t[--aligned]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[--ignorelockingfailure]\n"
|
||||
"\t[--noheadings]\n"
|
||||
"\t[--nosuffix]\n"
|
||||
"\t[-o|--options [+]Field[,Field]]\n"
|
||||
"\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n"
|
||||
"\t[-P|--partial] " "\n"
|
||||
"\t[--segments]\n"
|
||||
"\t[--separator Separator]\n"
|
||||
"\t[--unbuffered]\n"
|
||||
"\t[--units hsbkmgtHKMGT]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"\t[--version]" "\n"
|
||||
"\t[LogicalVolume[Path] [LogicalVolume[Path]...]]\n",
|
||||
|
||||
colon_ARG, disk_ARG, maps_ARG, partial_ARG,
|
||||
ignorelockingfailure_ARG)
|
||||
aligned_ARG, colon_ARG, columns_ARG, disk_ARG, ignorelockingfailure_ARG,
|
||||
maps_ARG, noheadings_ARG, nosuffix_ARG, options_ARG, sort_ARG,
|
||||
partial_ARG, segments_ARG, separator_ARG, unbuffered_ARG, units_ARG)
|
||||
|
||||
xx(lvextend,
|
||||
"Add space to a logical volume",
|
||||
"lvextend\n"
|
||||
"\t[-A/--autobackup y/n]\n"
|
||||
"\t[-d/--debug]\n"
|
||||
"\t[-h/-?/--help]\n"
|
||||
"\t[-A|--autobackup y|n]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n"
|
||||
"\t{-l/--extents [+]LogicalExtentsNumber |\n"
|
||||
"\t -L/--size [+]LogicalVolumeSize[kKmMgGtT]}\n"
|
||||
"\t[-t/--test]\n"
|
||||
"\t[-v/--verbose]\n"
|
||||
"\t{-l|--extents [+]LogicalExtentsNumber |\n"
|
||||
"\t -L|--size [+]LogicalVolumeSize[kKmMgGtT]}\n"
|
||||
"\t[-t|--test]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"\t[--version]" "\n"
|
||||
"\tLogicalVolume[Path] [ PhysicalVolumePath... ]\n",
|
||||
|
||||
autobackup_ARG, extents_ARG, size_ARG, stripes_ARG,
|
||||
@@ -128,53 +168,58 @@ xx(lvextend,
|
||||
xx(lvmchange,
|
||||
"With the device mapper, this is obsolete and does nothing.",
|
||||
"lvmchange\n"
|
||||
"\t[-d/--debug]\n"
|
||||
"\t[-h/-?/--help]\n"
|
||||
"\t[-R/--reset]\n"
|
||||
"\t[-v/--verbose]\n",
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[-R|--reset]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"\t[--version]" "\n",
|
||||
|
||||
reset_ARG)
|
||||
|
||||
xx(lvmdiskscan,
|
||||
"List devices that may be used as physical volumes",
|
||||
"lvmdiskscan\n"
|
||||
"\t[-d/--debug]\n"
|
||||
"\t[-h/-?/--help]\n"
|
||||
"\t[-l/--lvmpartition]\n",
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[-l|--lvmpartition]\n"
|
||||
"\t[--version]" "\n",
|
||||
|
||||
lvmpartition_ARG)
|
||||
|
||||
xx(lvmsadc,
|
||||
"Collect activity data",
|
||||
"lvmsadc\n"
|
||||
"\t[-d/--debug]\n"
|
||||
"\t[-h/-?/--help]\n"
|
||||
"\t[-v/--verbose]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"\t[--version]" "\n"
|
||||
"\t[LogFilePath]\n" )
|
||||
|
||||
xx(lvmsar,
|
||||
"Create activity report",
|
||||
"lvmsar\n"
|
||||
"\t[-d/--debug]\n"
|
||||
"\t[-f/--full]\n"
|
||||
"\t[-h/-?/--help]\n"
|
||||
"\t[-s/--stdin]\n"
|
||||
"\t[-v/--verbose]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-f|--full]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[-s|--stdin]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"\t[--version]" "\n"
|
||||
"\tLogFilePath\n",
|
||||
|
||||
full_ARG, stdin_ARG)
|
||||
full_ARG, stdin_ARG)
|
||||
|
||||
xx(lvreduce,
|
||||
"Reduce the size of a logical volume",
|
||||
"lvreduce\n"
|
||||
"\t[-A/--autobackup y/n]\n"
|
||||
"\t[-d/--debug]\n"
|
||||
"\t[-f/--force]\n"
|
||||
"\t[-h/-?/--help]\n"
|
||||
"\t{-l/--extents [-]LogicalExtentsNumber |\n"
|
||||
"\t -L/--size [-]LogicalVolumeSize[kKmMgGtT]}\n"
|
||||
"\t[-t/--test]\n"
|
||||
"\t[-v/--verbose]\n"
|
||||
"\t[-A|--autobackup y|n]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-f|--force]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t{-l|--extents [-]LogicalExtentsNumber |\n"
|
||||
"\t -L|--size [-]LogicalVolumeSize[kKmMgGtT]}\n"
|
||||
"\t[-t|--test]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"\t[--version]" "\n"
|
||||
"\tLogicalVolume[Path]\n",
|
||||
|
||||
autobackup_ARG, force_ARG, extents_ARG,
|
||||
@@ -183,12 +228,13 @@ xx(lvreduce,
|
||||
xx(lvremove,
|
||||
"Remove logical volume(s) from the system",
|
||||
"lvremove\n"
|
||||
"\t[-A/--autobackup y/n]\n"
|
||||
"\t[-d/--debug]\n"
|
||||
"\t[-f/--force]\n"
|
||||
"\t[-h/-?/--help]\n"
|
||||
"\t[-t/--test]\n"
|
||||
"\t[-v/--verbose]\n"
|
||||
"\t[-A|--autobackup y|n]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-f|--force]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[-t|--test]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"\t[--version]" "\n"
|
||||
"\tLogicalVolume[Path] [LogicalVolume[Path]...]\n",
|
||||
|
||||
autobackup_ARG, force_ARG, test_ARG)
|
||||
@@ -198,7 +244,7 @@ xx(lvrename,
|
||||
"lvrename "
|
||||
"\t[-A|--autobackup {y|n}] " "\n"
|
||||
"\t[-d|--debug] " "\n"
|
||||
"\t[-h|--help] " "\n"
|
||||
"\t[-h|-?|--help] " "\n"
|
||||
"\t[-t|--test] " "\n"
|
||||
"\t[-v|--verbose]" "\n"
|
||||
"\t[--version] " "\n"
|
||||
@@ -210,44 +256,71 @@ xx(lvrename,
|
||||
xx(lvresize,
|
||||
"Resize a logical volume",
|
||||
"lvresize\n"
|
||||
"\t[-A/--autobackup y/n]\n"
|
||||
"\t[-d/--debug]\n"
|
||||
"\t[-h/-?/--help]\n"
|
||||
"\t[-A|--autobackup y|n]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n"
|
||||
"\t{-l/--extents [+/-]LogicalExtentsNumber |\n"
|
||||
"\t -L/--size [+/-]LogicalVolumeSize[kKmMgGtT]}\n"
|
||||
"\t{-l|--extents [+|-]LogicalExtentsNumber |\n"
|
||||
"\t -L|--size [+|-]LogicalVolumeSize[kKmMgGtT]}\n"
|
||||
"\t[-t|--test]\n"
|
||||
"\t[-v/--verbose]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"\t[--version]" "\n"
|
||||
"\tLogicalVolume[Path] [ PhysicalVolumePath... ]\n",
|
||||
|
||||
autobackup_ARG, extents_ARG, size_ARG, stripes_ARG, stripesize_ARG,
|
||||
test_ARG)
|
||||
|
||||
xx(lvs,
|
||||
"Display information about logical volumes",
|
||||
"lvs" "\n"
|
||||
"\t[--aligned]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[--ignorelockingfailure]\n"
|
||||
"\t[--noheadings]\n"
|
||||
"\t[--nosuffix]\n"
|
||||
"\t[-o|--options [+]Field[,Field]]\n"
|
||||
"\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n"
|
||||
"\t[-P|--partial] " "\n"
|
||||
"\t[--segments]\n"
|
||||
"\t[--separator Separator]\n"
|
||||
"\t[--unbuffered]\n"
|
||||
"\t[--units hsbkmgtHKMGT]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"\t[--version]" "\n"
|
||||
"\t[LogicalVolume[Path] [LogicalVolume[Path]...]]\n",
|
||||
|
||||
aligned_ARG, ignorelockingfailure_ARG, noheadings_ARG, nosuffix_ARG,
|
||||
options_ARG, partial_ARG, segments_ARG, separator_ARG, sort_ARG,
|
||||
unbuffered_ARG, units_ARG)
|
||||
|
||||
xx(lvscan,
|
||||
"List all logical volumes in all volume groups",
|
||||
"lvscan " "\n"
|
||||
"\t[-b|--blockdevice] " "\n"
|
||||
"\t[-d|--debug] " "\n"
|
||||
"\t[-h|--help] " "\n"
|
||||
"\t[-h|-?|--help] " "\n"
|
||||
"\t[--ignorelockingfailure]\n"
|
||||
"\t[-P|--partial] " "\n"
|
||||
"\t[-v|--verbose] " "\n"
|
||||
"\t[--version]\n",
|
||||
|
||||
blockdevice_ARG, disk_ARG, partial_ARG, ignorelockingfailure_ARG);
|
||||
blockdevice_ARG, disk_ARG, ignorelockingfailure_ARG, partial_ARG)
|
||||
|
||||
xx(pvchange,
|
||||
"Change attributes of physical volume(s)",
|
||||
"pvchange\n"
|
||||
"\t[-A/--autobackup y/n]\n"
|
||||
"\t[-d/--debug]\n"
|
||||
"\t[-h/-?/--help]\n"
|
||||
"\t[-v/--verbose]\n"
|
||||
"\t[-a/--all]\n"
|
||||
"\t[-A|--autobackup y|n]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"\t[--version]" "\n"
|
||||
"\t[-a|--all]\n"
|
||||
"\t[-t|--test]\n"
|
||||
"\t[-x/--allocatable y/n]\n"
|
||||
"\t[-x|--allocatable y|n]\n"
|
||||
"\t[PhysicalVolumePath...]\n",
|
||||
|
||||
all_ARG, autobackup_ARG, allocatable_ARG, allocation_ARG, test_ARG)
|
||||
all_ARG, allocatable_ARG, allocation_ARG, autobackup_ARG, test_ARG)
|
||||
|
||||
xx(pvcreate,
|
||||
"Initialize physical volume(s) for use by LVM",
|
||||
@@ -255,7 +328,7 @@ xx(pvcreate,
|
||||
"\t[--restorefile file]\n"
|
||||
"\t[-d|--debug]" "\n"
|
||||
"\t[-f[f]|--force [--force]] " "\n"
|
||||
"\t[-h|--help] " "\n"
|
||||
"\t[-h|-?|--help] " "\n"
|
||||
"\t[--labelsector sector] " "\n"
|
||||
"\t[-M|--metadatatype 1|2]" "\n"
|
||||
"\t[--metadatacopies #copies]" "\n"
|
||||
@@ -278,7 +351,7 @@ xx(pvdata,
|
||||
"\t[-a|--all] " "\n"
|
||||
"\t[-d|--debug] " "\n"
|
||||
"\t[-E|--physicalextent] " "\n"
|
||||
"\t[-h|--help]" "\n"
|
||||
"\t[-h|-?|--help]" "\n"
|
||||
"\t[-L|--logicalvolume] " "\n"
|
||||
"\t[-P[P]|--physicalvolume [--physicalvolume]]" "\n"
|
||||
"\t[-U|--uuidlist] " "\n"
|
||||
@@ -291,17 +364,39 @@ xx(pvdata,
|
||||
physicalvolume_ARG, uuidlist_ARG, volumegroup_ARG)
|
||||
|
||||
xx(pvdisplay,
|
||||
"Display various attributes of logical volume(s)",
|
||||
"Display various attributes of physical volume(s)",
|
||||
"pvdisplay\n"
|
||||
"\t[-c/--colon]\n"
|
||||
"\t[-d/--debug]\n"
|
||||
"\t[-h/-?/--help]\n"
|
||||
"\t[-m/--maps]\n"
|
||||
"\t[-s/--short]\n"
|
||||
"\t[-v/--verbose]\n"
|
||||
"\tPhysicalVolumePath [PhysicalVolumePath...]\n",
|
||||
"\t[-c|--colon]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[--ignorelockingfailure]\n"
|
||||
"\t[-m|--maps]\n"
|
||||
"\t[--nosuffix]\n"
|
||||
"\t[-s|--short]\n"
|
||||
"\t[--units hsbkmgtHKMGT]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"\t[--version]" "\n"
|
||||
"\t[PhysicalVolumePath [PhysicalVolumePath...]]\n"
|
||||
"\n"
|
||||
"pvdisplay --columns|-C\n"
|
||||
"\t[--aligned]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[--ignorelockingfailure]\n"
|
||||
"\t[--noheadings]\n"
|
||||
"\t[--nosuffix]\n"
|
||||
"\t[-o|--options [+]Field[,Field]]\n"
|
||||
"\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n"
|
||||
"\t[--separator Separator]\n"
|
||||
"\t[--unbuffered]\n"
|
||||
"\t[--units hsbkmgtHKMGT]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"\t[--version]" "\n"
|
||||
"\t[PhysicalVolumePath [PhysicalVolumePath...]]\n",
|
||||
|
||||
colon_ARG, maps_ARG, short_ARG, ignorelockingfailure_ARG)
|
||||
aligned_ARG, colon_ARG, columns_ARG, ignorelockingfailure_ARG, maps_ARG,
|
||||
noheadings_ARG, nosuffix_ARG, options_ARG, separator_ARG, short_ARG,
|
||||
sort_ARG, unbuffered_ARG, units_ARG)
|
||||
|
||||
xx(pvmove,
|
||||
"Move extents from one physical volume to another",
|
||||
@@ -309,7 +404,7 @@ xx(pvmove,
|
||||
"[-A|--autobackup {y|n}] "
|
||||
"[-d|--debug] "
|
||||
"[-f|--force]"
|
||||
"[-h|--help]\n\t"
|
||||
"[-h|-?|--help]\n\t"
|
||||
"[-t|--test] "
|
||||
"[-v|--verbose] "
|
||||
"[--version]\n\t"
|
||||
@@ -317,14 +412,14 @@ xx(pvmove,
|
||||
"SourcePhysicalVolume[:PhysicalExtent[-PhysicalExtent]...]}\n\t"
|
||||
"[DestinationPhysicalVolume[:PhysicalExtent[-PhysicalExtent]...]...]\n",
|
||||
|
||||
autobackup_ARG, force_ARG, name_ARG, test_ARG)
|
||||
autobackup_ARG, force_ARG, name_ARG, test_ARG)
|
||||
|
||||
xx(pvremove,
|
||||
"Remove LVM label(s) from physical volume(s)",
|
||||
"pvremove " "\n"
|
||||
"\t[-d|--debug]" "\n"
|
||||
"\t[-f[f]|--force [--force]] " "\n"
|
||||
"\t[-h|--help] " "\n"
|
||||
"\t[-h|-?|--help] " "\n"
|
||||
"\t[-y|--yes]" "\n"
|
||||
"\t[-t|--test] " "\n"
|
||||
"\t[-v|--verbose] " "\n"
|
||||
@@ -341,7 +436,7 @@ xx(pvresize,
|
||||
"pvresize "
|
||||
"[-A|--autobackup {y|n}] "
|
||||
"[-d|--debug] "
|
||||
"[-h|--help]\n\t"
|
||||
"[-h|-?|--help]\n\t"
|
||||
"[-s|--size PhysicalVolumeSize[kKmMgGtT]" "\n"
|
||||
"[-v|--verbose] "
|
||||
"[--version]\n\t"
|
||||
@@ -349,32 +444,56 @@ xx(pvresize,
|
||||
***/
|
||||
autobackup_ARG, physicalvolumesize_ARG)
|
||||
|
||||
xx(pvs,
|
||||
"Display information about physical volumes",
|
||||
"pvs" "\n"
|
||||
"\t[--aligned]\n"
|
||||
"\t[-d|--debug]" "\n"
|
||||
"\t[-h|-?|--help] " "\n"
|
||||
"\t[--noheadings]\n"
|
||||
"\t[--ignorelockingfailure]\n"
|
||||
"\t[--nosuffix]\n"
|
||||
"\t[-o|--options [+]Field[,Field]]\n"
|
||||
"\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n"
|
||||
"\t[--separator Separator]\n"
|
||||
"\t[--unbuffered]\n"
|
||||
"\t[--units hsbkmgtHKMGT]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"\t[--version]\n"
|
||||
"\t[PhysicalVolume [PhysicalVolume...]]\n",
|
||||
|
||||
aligned_ARG, ignorelockingfailure_ARG, noheadings_ARG, nosuffix_ARG,
|
||||
options_ARG, separator_ARG, sort_ARG, unbuffered_ARG, units_ARG)
|
||||
|
||||
xx(pvscan,
|
||||
"List all physical volumes",
|
||||
"pvscan " "\n"
|
||||
"\t[-d|--debug] " "\n"
|
||||
"\t{-e|--exported | -n/--novolumegroup} " "\n"
|
||||
"\t[-h|--help]" "\n"
|
||||
"\t{-e|--exported | -n|--novolumegroup} " "\n"
|
||||
"\t[-h|-?|--help]" "\n"
|
||||
"\t[--ignorelockingfailure]\n"
|
||||
"\t[-P|--partial] " "\n"
|
||||
"\t[-s|--short] " "\n"
|
||||
"\t[-u|--uuid] " "\n"
|
||||
"\t[-v|--verbose] " "\n"
|
||||
"\t[--version]\n",
|
||||
|
||||
exported_ARG, novolumegroup_ARG, partial_ARG, short_ARG, uuid_ARG,
|
||||
ignorelockingfailure_ARG)
|
||||
exported_ARG, ignorelockingfailure_ARG, novolumegroup_ARG, partial_ARG,
|
||||
short_ARG, uuid_ARG)
|
||||
|
||||
xx(vgcfgbackup,
|
||||
"Backup volume group configuration(s)",
|
||||
"vgcfgbackup " "\n"
|
||||
"\t[-d|--debug] " "\n"
|
||||
"\t[-f|--file filename] " "\n"
|
||||
"\t[-h|--help] " "\n"
|
||||
"\t[-h|-?|--help] " "\n"
|
||||
"\t[--ignorelockingfailure]\n"
|
||||
"\t[-P|--partial] " "\n"
|
||||
"\t[-v|--verbose]" "\n"
|
||||
"\t[-V|--version] " "\n"
|
||||
"\t[--version] " "\n"
|
||||
"\t[VolumeGroupName...]\n",
|
||||
file_ARG, partial_ARG, ignorelockingfailure_ARG)
|
||||
|
||||
file_ARG, ignorelockingfailure_ARG, partial_ARG)
|
||||
|
||||
xx(vgcfgrestore,
|
||||
"Restore volume group configuration",
|
||||
@@ -399,6 +518,7 @@ xx(vgchange,
|
||||
"\t[-P|--partial] " "\n"
|
||||
"\t[-d|--debug] " "\n"
|
||||
"\t[-h|--help] " "\n"
|
||||
"\t[--ignorelockingfailure]\n"
|
||||
"\t[-t|--test]" "\n"
|
||||
"\t[-v|--verbose] " "\n"
|
||||
"\t[--version]" "\n"
|
||||
@@ -407,16 +527,16 @@ xx(vgchange,
|
||||
"\t -l|--logicalvolume MaxLogicalVolumes}" "\n"
|
||||
"\t[VolumeGroupName...]\n",
|
||||
|
||||
autobackup_ARG, available_ARG, logicalvolume_ARG, partial_ARG,
|
||||
resizeable_ARG, resizable_ARG, allocation_ARG,
|
||||
test_ARG, ignorelockingfailure_ARG)
|
||||
allocation_ARG, autobackup_ARG, available_ARG, ignorelockingfailure_ARG,
|
||||
logicalvolume_ARG, partial_ARG, resizeable_ARG, resizable_ARG, test_ARG)
|
||||
|
||||
xx(vgck,
|
||||
"Check the consistency of volume group(s)",
|
||||
"vgck "
|
||||
"\t[-d/--debug]\n"
|
||||
"\t[-h/-?/--help]\n"
|
||||
"\t[-v/--verbose]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"\t[--version]" "\n",
|
||||
"\t[VolumeGroupName...]\n" )
|
||||
|
||||
xx(vgconvert,
|
||||
@@ -461,13 +581,33 @@ xx(vgdisplay,
|
||||
"\t[-d|--debug] " "\n"
|
||||
"\t[-h|--help] " "\n"
|
||||
"\t[--ignorelockingfailure]" "\n"
|
||||
"\t[--nosuffix]\n"
|
||||
"\t[-P|--partial] " "\n"
|
||||
"\t[--units hsbkmgtHKMGT]\n"
|
||||
"\t[-A|--activevolumegroups | [-D|--disk]" "\n"
|
||||
"\t[--version]" "\n"
|
||||
"\t[VolumeGroupName...] ]\n",
|
||||
"\t[VolumeGroupName [VolumeGroupName...]]\n"
|
||||
"\n"
|
||||
"vgdisplay --columns|-C\n"
|
||||
"\t[--aligned]\n"
|
||||
"\t[-d|--debug] " "\n"
|
||||
"\t[-h|--help] " "\n"
|
||||
"\t[--ignorelockingfailure]" "\n"
|
||||
"\t[--noheadings]\n"
|
||||
"\t[--nosuffix]\n"
|
||||
"\t[-o|--options [+]Field[,Field]]\n"
|
||||
"\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n"
|
||||
"\t[-P|--partial] " "\n"
|
||||
"\t[--separator Separator]\n"
|
||||
"\t[--unbuffered]\n"
|
||||
"\t[--units hsbkmgtHKMGT]\n"
|
||||
"\t[--verbose]" "\n"
|
||||
"\t[--version]" "\n"
|
||||
"\t[VolumeGroupName [VolumeGroupName...]]\n",
|
||||
|
||||
activevolumegroups_ARG, colon_ARG, disk_ARG, short_ARG, partial_ARG,
|
||||
ignorelockingfailure_ARG)
|
||||
activevolumegroups_ARG, aligned_ARG, colon_ARG, columns_ARG, disk_ARG,
|
||||
ignorelockingfailure_ARG, noheadings_ARG, nosuffix_ARG, options_ARG,
|
||||
partial_ARG, separator_ARG, short_ARG, sort_ARG, unbuffered_ARG, units_ARG)
|
||||
|
||||
xx(vgexport,
|
||||
"Unregister volume group(s) from the system",
|
||||
@@ -484,11 +624,12 @@ xx(vgexport,
|
||||
xx(vgextend,
|
||||
"Add physical volumes to a volume group",
|
||||
"vgextend\n"
|
||||
"\t[-A/--autobackup y/n]\n"
|
||||
"\t[-d/--debug]\n"
|
||||
"\t[-h/-?/--help]\n"
|
||||
"\t[-t/--test]\n"
|
||||
"\t[-v/--verbose]\n"
|
||||
"\t[-A|--autobackup y|n]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[-t|--test]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"\t[--version]" "\n"
|
||||
"\tVolumeGroupName PhysicalDevicePath [PhysicalDevicePath...]\n",
|
||||
|
||||
autobackup_ARG, test_ARG)
|
||||
@@ -496,12 +637,13 @@ xx(vgextend,
|
||||
xx(vgimport,
|
||||
"Register exported volume group with system",
|
||||
"vgimport " "\n"
|
||||
"\t[-a/--all]\n"
|
||||
"\t[-a|--all]\n"
|
||||
"\t[-d|--debug] " "\n"
|
||||
"\t[-f|--force] " "\n"
|
||||
"\t[-h|--help] " "\n"
|
||||
"\t[-t|--test] " "\n"
|
||||
"\t[-v|--verbose]" "\n"
|
||||
"\t[--version]" "\n"
|
||||
"\tVolumeGroupName..." "\n",
|
||||
|
||||
all_ARG, force_ARG, test_ARG)
|
||||
@@ -509,12 +651,13 @@ xx(vgimport,
|
||||
xx(vgmerge,
|
||||
"Merge volume groups",
|
||||
"vgmerge\n"
|
||||
"\t[-A/--autobackup y/n]\n"
|
||||
"\t[-d/--debug]\n"
|
||||
"\t[-h/-?/--help]\n"
|
||||
"\t[-l/--list]\n"
|
||||
"\t[-t/--test]\n"
|
||||
"\t[-v/--verbose]\n"
|
||||
"\t[-A|--autobackup y|n]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[-l|--list]\n"
|
||||
"\t[-t|--test]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"\t[--version]" "\n"
|
||||
"\tDestinationVolumeGroupName SourceVolumeGroupName\n",
|
||||
|
||||
autobackup_ARG, list_ARG, test_ARG)
|
||||
@@ -522,20 +665,22 @@ xx(vgmerge,
|
||||
xx(vgmknodes,
|
||||
"Create the special files for volume group devices in /dev",
|
||||
"vgmknodes\n"
|
||||
"\t[-d/--debug]\n"
|
||||
"\t[-h/-?/--help]\n"
|
||||
"\t[-v/--verbose]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"\t[--version]" "\n"
|
||||
"\t[VolumeGroupName...]\n" )
|
||||
|
||||
xx(vgreduce,
|
||||
"Remove physical volume(s) from a volume group",
|
||||
"vgreduce\n"
|
||||
"\t[-a/--all]\n"
|
||||
"\t[-A/--autobackup y/n]\n"
|
||||
"\t[-d/--debug]\n"
|
||||
"\t[-h/-?/--help]\n"
|
||||
"\t[-t/--test]\n"
|
||||
"\t[-v/--verbose]\n"
|
||||
"\t[-a|--all]\n"
|
||||
"\t[-A|--autobackup y|n]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[-t|--test]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"\t[--version]" "\n"
|
||||
"\tVolumeGroupName\n"
|
||||
"\t[PhysicalVolumePath...]\n",
|
||||
|
||||
@@ -544,10 +689,11 @@ xx(vgreduce,
|
||||
xx(vgremove,
|
||||
"Remove volume group(s)",
|
||||
"vgremove\n"
|
||||
"\t[-d/--debug]\n"
|
||||
"\t[-h/-?/--help]\n"
|
||||
"\t[-t/--test]\n"
|
||||
"\t[-v/--verbose]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[-t|--test]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"\t[--version]" "\n"
|
||||
"\tVolumeGroupName [VolumeGroupName...]\n",
|
||||
|
||||
test_ARG)
|
||||
@@ -555,24 +701,50 @@ xx(vgremove,
|
||||
xx(vgrename,
|
||||
"Rename a volume group",
|
||||
"vgrename\n"
|
||||
"\t[-A/--autobackup y/n]\n"
|
||||
"\t[-d/--debug]\n"
|
||||
"\t[-h/-?/--help]\n"
|
||||
"\t[-t/--test]\n"
|
||||
"\t[-v/--verbose]\n"
|
||||
"\t[-A|--autobackup y|n]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[-t|--test]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"\t[--version]" "\n"
|
||||
"\tOldVolumeGroupPath NewVolumeGroupPath |\n"
|
||||
"\tOldVolumeGroupName NewVolumeGroupName\n",
|
||||
|
||||
autobackup_ARG, force_ARG, test_ARG)
|
||||
|
||||
xx(vgs,
|
||||
"Display information about volume groups",
|
||||
"vgs" "\n"
|
||||
"\t[--aligned]\n"
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[--ignorelockingfailure]\n"
|
||||
"\t[--noheadings]\n"
|
||||
"\t[--nosuffix]\n"
|
||||
"\t[-o|--options [+]Field[,Field]]\n"
|
||||
"\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n"
|
||||
"\t[-P|--partial] " "\n"
|
||||
"\t[--separator Separator]\n"
|
||||
"\t[--unbuffered]\n"
|
||||
"\t[--units hsbkmgtHKMGT]\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"\t[--version]\n"
|
||||
"\t[VolumeGroupName [VolumeGroupName...]]\n",
|
||||
|
||||
aligned_ARG, ignorelockingfailure_ARG, noheadings_ARG, nosuffix_ARG,
|
||||
options_ARG, partial_ARG, separator_ARG, sort_ARG, unbuffered_ARG, units_ARG)
|
||||
|
||||
xx(vgscan,
|
||||
"Search for all volume groups",
|
||||
"vgscan "
|
||||
"\t[-d/--debug]\n"
|
||||
"\t[-h/-?/--help]\n"
|
||||
"\t[-P/--partial] " "\n"
|
||||
"\t[-v/--verbose]\n" ,
|
||||
partial_ARG, ignorelockingfailure_ARG)
|
||||
"\t[-d|--debug]\n"
|
||||
"\t[-h|--help]\n"
|
||||
"\t[--ignorelockingfailure]\n"
|
||||
"\t[-P|--partial] " "\n"
|
||||
"\t[-v|--verbose]\n"
|
||||
"\t[--version]" "\n",
|
||||
|
||||
ignorelockingfailure_ARG, partial_ARG)
|
||||
|
||||
xx(vgsplit,
|
||||
"Move physical volumes into a new volume group",
|
||||
|
||||
@@ -144,7 +144,7 @@ static int _read_size_params(struct lvcreate_params *lp,
|
||||
|
||||
/* Size returned in kilobyte units; held in sectors */
|
||||
if (arg_count(cmd, size_ARG))
|
||||
lp->size = arg_int64_value(cmd, size_ARG, 0) * 2ull;
|
||||
lp->size = arg_uint64_value(cmd, size_ARG, 0) * 2ull;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -378,15 +378,11 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
|
||||
lp->extents = lp->size;
|
||||
|
||||
if (lp->extents % vg->extent_size) {
|
||||
char *s1;
|
||||
|
||||
lp->extents += vg->extent_size - lp->extents %
|
||||
vg->extent_size;
|
||||
log_print("Rounding up size to full physical "
|
||||
"extent %s",
|
||||
(s1 = display_size(lp->extents / 2,
|
||||
SIZE_SHORT)));
|
||||
dbg_free(s1);
|
||||
log_print("Rounding up size to full physical extent %s",
|
||||
display_size(cmd, lp->extents / 2,
|
||||
SIZE_SHORT));
|
||||
}
|
||||
|
||||
lp->extents /= vg->extent_size;
|
||||
@@ -399,14 +395,12 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
|
||||
lp->extents = lp->extents - size_rest + lp->stripes;
|
||||
}
|
||||
|
||||
if (!activation()) {
|
||||
if (lp->snapshot)
|
||||
if (lp->snapshot) {
|
||||
if (!activation()) {
|
||||
log_error("Can't create snapshot without using "
|
||||
"device-mapper kernel driver");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (lp->snapshot) {
|
||||
return 0;
|
||||
}
|
||||
if (!(org = find_lv(vg, lp->origin))) {
|
||||
log_err("Couldn't find origin volume '%s'.",
|
||||
lp->origin);
|
||||
@@ -439,9 +433,8 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
|
||||
return 0;
|
||||
|
||||
/* store vg on disk(s) */
|
||||
if (!vg_write(vg)) {
|
||||
if (!vg_write(vg))
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!lock_vol(cmd, lv->lvid.s, LCK_LV_ACTIVATE)) {
|
||||
/* FIXME Remove the failed lv we just added */
|
||||
|
||||
@@ -36,7 +36,20 @@ int lvdisplay_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
|
||||
int lvdisplay(struct cmd_context *cmd, int argc, char **argv)
|
||||
{
|
||||
/* FIXME Allow VG args via process_each */
|
||||
if (arg_count(cmd, columns_ARG)) {
|
||||
if (arg_count(cmd, colon_ARG) || arg_count(cmd, maps_ARG)) {
|
||||
log_error("Incompatible options selected");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
return lvs(cmd, argc, argv);
|
||||
} else if (arg_count(cmd, aligned_ARG) ||
|
||||
arg_count(cmd, noheadings_ARG) ||
|
||||
arg_count(cmd, options_ARG) ||
|
||||
arg_count(cmd, separator_ARG) ||
|
||||
arg_count(cmd, sort_ARG) || arg_count(cmd, unbuffered_ARG)) {
|
||||
log_error("Incompatible options selected");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, colon_ARG) && arg_count(cmd, verbose_ARG)) {
|
||||
log_error("Options -v and -c are incompatible");
|
||||
|
||||
50
tools/lvm.c
50
tools/lvm.c
@@ -113,7 +113,7 @@ int _get_int_arg(struct arg *a, char **ptr)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int size_arg(struct cmd_context *cmd, struct arg *a)
|
||||
static int _size_arg(struct cmd_context *cmd, struct arg *a, int factor)
|
||||
{
|
||||
char *ptr;
|
||||
int i;
|
||||
@@ -153,13 +153,26 @@ int size_arg(struct cmd_context *cmd, struct arg *a)
|
||||
|
||||
while (i-- > 0)
|
||||
v *= 1024;
|
||||
}
|
||||
} else
|
||||
v *= factor;
|
||||
|
||||
a->i_value = (uint32_t) v;
|
||||
a->i64_value = (uint64_t) v;
|
||||
a->i64_value = (int64_t) v;
|
||||
a->ui64_value = (uint64_t) v;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int size_kb_arg(struct cmd_context *cmd, struct arg *a)
|
||||
{
|
||||
return _size_arg(cmd, a, 1);
|
||||
}
|
||||
|
||||
int size_mb_arg(struct cmd_context *cmd, struct arg *a)
|
||||
{
|
||||
return _size_arg(cmd, a, 1024);
|
||||
}
|
||||
|
||||
int int_arg(struct cmd_context *cmd, struct arg *a)
|
||||
{
|
||||
char *ptr;
|
||||
@@ -305,7 +318,7 @@ static void _register_commands()
|
||||
{
|
||||
#define xx(a, b, c...) _register_command(# a, a, b, ## c, \
|
||||
driverloaded_ARG, \
|
||||
debug_ARG, help_ARG, \
|
||||
debug_ARG, help_ARG, help2_ARG, \
|
||||
version_ARG, verbose_ARG, \
|
||||
quiet_ARG, -1);
|
||||
#include "commands.h"
|
||||
@@ -348,9 +361,7 @@ void usage(const char *name)
|
||||
* is no short argument then the index of the
|
||||
* argument in the the_args array is set as the
|
||||
* long opt value. Yuck. Of course this means we
|
||||
* can't have more than 'a' long arguments. Since
|
||||
* we have only 1 ATM (--version) I think we can
|
||||
* live with this restriction.
|
||||
* can't have more than 'a' long arguments.
|
||||
*/
|
||||
static void _add_getopt_arg(int arg, char **ptr, struct option **o)
|
||||
{
|
||||
@@ -367,7 +378,10 @@ static void _add_getopt_arg(int arg, char **ptr, struct option **o)
|
||||
(*o)->name = a->long_arg + 2;
|
||||
(*o)->has_arg = a->fn ? 1 : 0;
|
||||
(*o)->flag = NULL;
|
||||
(*o)->val = arg;
|
||||
if (a->short_arg)
|
||||
(*o)->val = a->short_arg;
|
||||
else
|
||||
(*o)->val = arg;
|
||||
(*o)++;
|
||||
}
|
||||
}
|
||||
@@ -422,6 +436,9 @@ static int _process_command_line(struct cmd_context *cmd, int *argc,
|
||||
optind = 0;
|
||||
while ((opt = getopt_long(*argc, *argv, str, opts, NULL)) >= 0) {
|
||||
|
||||
if (opt == '?')
|
||||
return 0;
|
||||
|
||||
a = _find_arg(cmd->command, opt);
|
||||
|
||||
if (!a) {
|
||||
@@ -531,6 +548,17 @@ static int _get_settings(struct cmd_context *cmd)
|
||||
else
|
||||
init_ignorelockingfailure(0);
|
||||
|
||||
if (arg_count(cmd, nosuffix_ARG))
|
||||
cmd->current_settings.suffix = 0;
|
||||
|
||||
if (arg_count(cmd, units_ARG))
|
||||
if (!(cmd->current_settings.unit_factor =
|
||||
units_to_bytes(arg_str_value(cmd, units_ARG, ""),
|
||||
&cmd->current_settings.unit_type))) {
|
||||
log_error("Invalid units specification");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
/* Handle synonyms */
|
||||
if (!_merge_synonym(cmd, resizable_ARG, resizeable_ARG) ||
|
||||
!_merge_synonym(cmd, allocation_ARG, allocatable_ARG) ||
|
||||
@@ -543,7 +571,7 @@ static int _get_settings(struct cmd_context *cmd)
|
||||
|
||||
static int _process_common_commands(struct cmd_context *cmd)
|
||||
{
|
||||
if (arg_count(cmd, help_ARG)) {
|
||||
if (arg_count(cmd, help_ARG) || arg_count(cmd, help2_ARG)) {
|
||||
usage(cmd->command->name);
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
@@ -959,7 +987,7 @@ static char *_list_args(const char *text, int state)
|
||||
char *l;
|
||||
l = (the_args +
|
||||
com->valid_args[match_no++ - com->num_args])->long_arg;
|
||||
if (!strncmp(text, l, len))
|
||||
if (*(l + 2) && !strncmp(text, l, len))
|
||||
return strdup(l);
|
||||
}
|
||||
|
||||
@@ -1134,5 +1162,7 @@ int main(int argc, char **argv)
|
||||
|
||||
out:
|
||||
_fin(cmd);
|
||||
if (ret == ECMD_PROCESSED)
|
||||
ret = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -13,17 +13,76 @@
|
||||
|
||||
#include "tools.h"
|
||||
|
||||
int _get_max_dev_name_len(struct dev_filter *filter);
|
||||
void _count(struct device *, int *, int *);
|
||||
void _print(struct device *, uint64_t, char *);
|
||||
int _check_device(struct device *);
|
||||
|
||||
int disks_found = 0;
|
||||
int parts_found = 0;
|
||||
int pv_disks_found = 0;
|
||||
int pv_parts_found = 0;
|
||||
int max_len;
|
||||
|
||||
static int _get_max_dev_name_len(struct dev_filter *filter)
|
||||
{
|
||||
int len = 0;
|
||||
int max_len = 0;
|
||||
struct dev_iter *iter;
|
||||
struct device *dev;
|
||||
|
||||
if (!(iter = dev_iter_create(filter))) {
|
||||
log_error("dev_iter_create failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Do scan */
|
||||
for (dev = dev_iter_get(iter); dev; dev = dev_iter_get(iter)) {
|
||||
len = strlen(dev_name(dev));
|
||||
if (len > max_len)
|
||||
max_len = len;
|
||||
}
|
||||
dev_iter_destroy(iter);
|
||||
|
||||
return max_len;
|
||||
}
|
||||
|
||||
static void _count(struct device *dev, int *disks, int *parts)
|
||||
{
|
||||
int c = dev_name(dev)[strlen(dev_name(dev)) - 1];
|
||||
|
||||
if (!isdigit(c))
|
||||
(*disks)++;
|
||||
else
|
||||
(*parts)++;
|
||||
}
|
||||
|
||||
static void _print(struct cmd_context *cmd, struct device *dev, uint64_t size,
|
||||
char *what)
|
||||
{
|
||||
log_print("%-*s [%15s] %s", max_len, dev_name(dev),
|
||||
display_size(cmd, size / 2, SIZE_SHORT), what ? : "");
|
||||
}
|
||||
|
||||
static int _check_device(struct cmd_context *cmd, struct device *dev)
|
||||
{
|
||||
char buffer;
|
||||
uint64_t size;
|
||||
|
||||
if (!dev_open(dev, 0)) {
|
||||
return 0;
|
||||
}
|
||||
if (dev_read(dev, 0, 1, &buffer) != 1) {
|
||||
dev_close(dev);
|
||||
return 0;
|
||||
}
|
||||
if (!dev_get_size(dev, &size)) {
|
||||
log_error("Couldn't get size of \"%s\"", dev_name(dev));
|
||||
}
|
||||
_print(cmd, dev, size, NULL);
|
||||
_count(dev, &disks_found, &parts_found);
|
||||
if (!dev_close(dev)) {
|
||||
log_error("dev_close on \"%s\" failed", dev_name(dev));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int lvmdiskscan(struct cmd_context *cmd, int argc, char **argv)
|
||||
{
|
||||
uint64_t size;
|
||||
@@ -50,7 +109,7 @@ int lvmdiskscan(struct cmd_context *cmd, int argc, char **argv)
|
||||
dev_name(dev));
|
||||
continue;
|
||||
}
|
||||
_print(dev, size, "LVM physical volume");
|
||||
_print(cmd, dev, size, "LVM physical volume");
|
||||
_count(dev, &pv_disks_found, &pv_parts_found);
|
||||
continue;
|
||||
}
|
||||
@@ -59,7 +118,7 @@ int lvmdiskscan(struct cmd_context *cmd, int argc, char **argv)
|
||||
continue;
|
||||
|
||||
/* What other device is it? */
|
||||
if (!_check_device(dev))
|
||||
if (!_check_device(cmd, dev))
|
||||
continue;
|
||||
}
|
||||
dev_iter_destroy(iter);
|
||||
@@ -78,74 +137,3 @@ int lvmdiskscan(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _check_device(struct device *dev)
|
||||
{
|
||||
char buffer;
|
||||
uint64_t size;
|
||||
|
||||
if (!dev_open(dev, 0)) {
|
||||
return 0;
|
||||
}
|
||||
if (dev_read(dev, 0, 1, &buffer) != 1) {
|
||||
dev_close(dev);
|
||||
return 0;
|
||||
}
|
||||
if (!dev_get_size(dev, &size)) {
|
||||
log_error("Couldn't get size of \"%s\"", dev_name(dev));
|
||||
}
|
||||
_print(dev, size, NULL);
|
||||
_count(dev, &disks_found, &parts_found);
|
||||
if (!dev_close(dev)) {
|
||||
log_error("dev_close on \"%s\" failed", dev_name(dev));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _get_max_dev_name_len(struct dev_filter *filter)
|
||||
{
|
||||
int len = 0;
|
||||
int max_len = 0;
|
||||
struct dev_iter *iter;
|
||||
struct device *dev;
|
||||
|
||||
if (!(iter = dev_iter_create(filter))) {
|
||||
log_error("dev_iter_create failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Do scan */
|
||||
for (dev = dev_iter_get(iter); dev; dev = dev_iter_get(iter)) {
|
||||
len = strlen(dev_name(dev));
|
||||
if (len > max_len)
|
||||
max_len = len;
|
||||
}
|
||||
dev_iter_destroy(iter);
|
||||
|
||||
return max_len;
|
||||
}
|
||||
|
||||
void _count(struct device *dev, int *disks, int *parts)
|
||||
{
|
||||
int c = dev_name(dev)[strlen(dev_name(dev)) - 1];
|
||||
|
||||
if (!isdigit(c))
|
||||
(*disks)++;
|
||||
else
|
||||
(*parts)++;
|
||||
}
|
||||
|
||||
void _print(struct device *dev, uint64_t size, char *what)
|
||||
{
|
||||
char *dummy = display_size(size / 2, SIZE_SHORT);
|
||||
const char *name = dev_name(dev);
|
||||
|
||||
if (!what) {
|
||||
|
||||
what = "";
|
||||
}
|
||||
|
||||
log_print("%-*s [%15s] %s", max_len, name, dummy, what);
|
||||
dbg_free(dummy);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
|
||||
sign_t sign = SIGN_NONE;
|
||||
char *lv_name, *vg_name;
|
||||
char *st;
|
||||
char *dummy;
|
||||
const char *cmd_name;
|
||||
struct list *pvh, *segh;
|
||||
struct lv_list *lvl;
|
||||
@@ -145,8 +144,6 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
|
||||
extents = size * 2;
|
||||
|
||||
if (extents % vg->extent_size) {
|
||||
char *s1;
|
||||
|
||||
if (sign == SIGN_MINUS)
|
||||
extents -= extents % vg->extent_size;
|
||||
else
|
||||
@@ -154,8 +151,7 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
|
||||
(extents % vg->extent_size);
|
||||
|
||||
log_print("Rounding up size to full physical extent %s",
|
||||
(s1 = display_size(extents / 2, SIZE_SHORT)));
|
||||
dbg_free(s1);
|
||||
display_size(cmd, extents / 2, SIZE_SHORT));
|
||||
}
|
||||
|
||||
extents /= vg->extent_size;
|
||||
@@ -310,16 +306,14 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
|
||||
}
|
||||
|
||||
if (info.exists) {
|
||||
dummy = display_size((uint64_t)
|
||||
extents * (vg->extent_size / 2),
|
||||
SIZE_SHORT);
|
||||
log_print("WARNING: Reducing active%s logical volume "
|
||||
"to %s", info.open_count ? " and open" : "",
|
||||
dummy);
|
||||
display_size(cmd, (uint64_t)
|
||||
extents * (vg->extent_size / 2),
|
||||
SIZE_SHORT));
|
||||
|
||||
log_print("THIS MAY DESTROY YOUR DATA "
|
||||
"(filesystem etc.)");
|
||||
dbg_free(dummy);
|
||||
}
|
||||
|
||||
if (!arg_count(cmd, force_ARG)) {
|
||||
@@ -352,11 +346,10 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
|
||||
/* Use full list from VG */
|
||||
pvh = &vg->pvs;
|
||||
}
|
||||
dummy = display_size((uint64_t)
|
||||
extents * (vg->extent_size / 2),
|
||||
SIZE_SHORT);
|
||||
log_print("Extending logical volume %s to %s", lv_name, dummy);
|
||||
dbg_free(dummy);
|
||||
log_print("Extending logical volume %s to %s", lv_name,
|
||||
display_size(cmd, (uint64_t)
|
||||
extents * (vg->extent_size / 2),
|
||||
SIZE_SHORT));
|
||||
|
||||
if (!lv_extend(vg->fid, lv, stripes, stripesize,
|
||||
extents - lv->le_count, pvh))
|
||||
|
||||
@@ -27,7 +27,6 @@ static int lvscan_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
int lv_total = 0;
|
||||
ulong lv_capacity_total = 0;
|
||||
|
||||
char *dummy;
|
||||
const char *active_str, *snapshot_str;
|
||||
|
||||
if (lv_info(lv, &info) && info.exists)
|
||||
@@ -42,14 +41,11 @@ static int lvscan_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
else
|
||||
snapshot_str = " ";
|
||||
|
||||
dummy = display_size(lv->size / 2, SIZE_SHORT);
|
||||
|
||||
log_print("%s%s '%s%s/%s' [%s] %s", active_str, snapshot_str,
|
||||
cmd->dev_dir, lv->vg->name, lv->name, dummy,
|
||||
cmd->dev_dir, lv->vg->name, lv->name,
|
||||
display_size(cmd, lv->size / 2, SIZE_SHORT),
|
||||
get_alloc_string(lv->alloc));
|
||||
|
||||
dbg_free(dummy);
|
||||
|
||||
lv_total++;
|
||||
|
||||
lv_capacity_total += lv->size;
|
||||
@@ -66,4 +62,5 @@ int lvscan(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
||||
return process_each_lv(cmd, argc, argv, LCK_VG_READ, NULL,
|
||||
&lvscan_single);
|
||||
|
||||
}
|
||||
|
||||
@@ -130,9 +130,9 @@ static void pvcreate_single(struct cmd_context *cmd, const char *pv_name,
|
||||
if (!pvcreate_check(cmd, pv_name))
|
||||
goto error;
|
||||
|
||||
size = arg_int64_value(cmd, physicalvolumesize_ARG, 0) * 2;
|
||||
size = arg_uint64_value(cmd, physicalvolumesize_ARG, 0) * 2;
|
||||
|
||||
pvmetadatasize = arg_int64_value(cmd, metadatasize_ARG, 0) * 2;
|
||||
pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG, 0) * 2;
|
||||
if (!pvmetadatasize)
|
||||
pvmetadatasize = find_config_int(cmd->cf->root,
|
||||
"metadata/pvmetadatasize",
|
||||
|
||||
@@ -20,10 +20,9 @@
|
||||
|
||||
#include "tools.h"
|
||||
|
||||
void pvdisplay_single(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
void *handle)
|
||||
int pvdisplay_single(struct cmd_context *cmd, struct volume_group *vg,
|
||||
struct physical_volume *pv, void *handle)
|
||||
{
|
||||
char *sz;
|
||||
uint64_t size;
|
||||
|
||||
const char *pv_name = dev_name(pv->dev);
|
||||
@@ -34,67 +33,56 @@ void pvdisplay_single(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
size = (pv->pe_count - pv->pe_alloc_count) * pv->pe_size;
|
||||
|
||||
if (arg_count(cmd, short_ARG)) {
|
||||
sz = display_size(size / 2, SIZE_SHORT);
|
||||
log_print("Device \"%s\" has a capacity of %s", pv_name, sz);
|
||||
dbg_free(sz);
|
||||
return;
|
||||
log_print("Device \"%s\" has a capacity of %s", pv_name,
|
||||
display_size(cmd, size / 2, SIZE_SHORT));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (pv->status & EXPORTED_VG)
|
||||
log_print("Physical volume \"%s\" of volume group \"%s\" "
|
||||
"is exported", pv_name, pv->vg_name);
|
||||
|
||||
if (!pv->vg_name) {
|
||||
if (!pv->vg_name)
|
||||
log_print("\"%s\" is a new physical volume of \"%s\"",
|
||||
pv_name, (sz = display_size(size / 2, SIZE_SHORT)));
|
||||
dbg_free(sz);
|
||||
}
|
||||
pv_name, display_size(cmd, size / 2, SIZE_SHORT));
|
||||
|
||||
if (arg_count(cmd, colon_ARG)) {
|
||||
pvdisplay_colons(pv);
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
pvdisplay_full(pv, handle);
|
||||
pvdisplay_full(cmd, pv, handle);
|
||||
|
||||
if (!arg_count(cmd, maps_ARG))
|
||||
return;
|
||||
return 0;
|
||||
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pvdisplay(struct cmd_context *cmd, int argc, char **argv)
|
||||
{
|
||||
int opt = 0;
|
||||
|
||||
struct list *pvh, *pvs;
|
||||
struct physical_volume *pv;
|
||||
if (arg_count(cmd, columns_ARG)) {
|
||||
if (arg_count(cmd, colon_ARG) || arg_count(cmd, maps_ARG) ||
|
||||
arg_count(cmd, short_ARG)) {
|
||||
log_error("Incompatible options selected");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
return pvs(cmd, argc, argv);
|
||||
} else if (arg_count(cmd, aligned_ARG) ||
|
||||
arg_count(cmd, noheadings_ARG) ||
|
||||
arg_count(cmd, options_ARG) ||
|
||||
arg_count(cmd, separator_ARG) ||
|
||||
arg_count(cmd, sort_ARG) || arg_count(cmd, unbuffered_ARG)) {
|
||||
log_error("Incompatible options selected");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, colon_ARG) && arg_count(cmd, maps_ARG)) {
|
||||
log_error("Option -v not allowed with option -c");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
if (argc) {
|
||||
log_very_verbose("Using physical volume(s) on command line");
|
||||
|
||||
for (; opt < argc; opt++) {
|
||||
if (!(pv = pv_read(cmd, argv[opt], NULL, NULL))) {
|
||||
log_error("Failed to read physical "
|
||||
"volume \"%s\"", argv[opt]);
|
||||
continue;
|
||||
}
|
||||
pvdisplay_single(cmd, pv, NULL);
|
||||
}
|
||||
} else {
|
||||
log_verbose("Scanning for physical volume names");
|
||||
if (!(pvs = get_pvs(cmd)))
|
||||
return ECMD_FAILED;
|
||||
|
||||
list_iterate(pvh, pvs)
|
||||
pvdisplay_single(cmd, list_item(pvh, struct pv_list)->pv,
|
||||
NULL);
|
||||
}
|
||||
process_each_pv(cmd, argc, argv, NULL, NULL, pvdisplay_single);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -29,8 +29,6 @@ void pvscan_display_single(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
char uuid[64];
|
||||
int vg_name_len = 0;
|
||||
|
||||
char *s1, *s2;
|
||||
|
||||
char pv_tmp_name[NAME_LEN] = { 0, };
|
||||
char vg_tmp_name[NAME_LEN] = { 0, };
|
||||
char vg_name_this[NAME_LEN] = { 0, };
|
||||
@@ -73,8 +71,7 @@ void pvscan_display_single(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
pv_max_name_len, pv_tmp_name,
|
||||
vg_max_name_len, " ",
|
||||
pv->fmt ? pv->fmt->name : " ",
|
||||
(s1 = display_size(pv->size / 2, SIZE_SHORT)));
|
||||
dbg_free(s1);
|
||||
display_size(cmd, pv->size / 2, SIZE_SHORT));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -83,14 +80,12 @@ void pvscan_display_single(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
log_print("PV %-*s is in exported VG %s "
|
||||
"[%s / %s free]",
|
||||
pv_max_name_len, pv_tmp_name,
|
||||
vg_name_this, (s1 =
|
||||
display_size(pv->pe_count *
|
||||
pv->pe_size / 2,
|
||||
SIZE_SHORT)),
|
||||
(s2 = display_size((pv->pe_count - pv->pe_alloc_count)
|
||||
* pv->pe_size / 2, SIZE_SHORT)));
|
||||
dbg_free(s1);
|
||||
dbg_free(s2);
|
||||
vg_name_this,
|
||||
display_size(cmd, pv->pe_count *
|
||||
pv->pe_size / 2,
|
||||
SIZE_SHORT),
|
||||
display_size(cmd, (pv->pe_count - pv->pe_alloc_count)
|
||||
* pv->pe_size / 2, SIZE_SHORT));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -99,13 +94,10 @@ void pvscan_display_single(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
("PV %-*s VG %-*s %s [%s / %s free]", pv_max_name_len,
|
||||
pv_tmp_name, vg_max_name_len, vg_tmp_name,
|
||||
pv->fmt ? pv->fmt->name : " ",
|
||||
(s1 = display_size(pv->pe_count * pv->pe_size / 2, SIZE_SHORT)),
|
||||
(s2 =
|
||||
display_size((pv->pe_count - pv->pe_alloc_count) * pv->pe_size /
|
||||
2, SIZE_SHORT)));
|
||||
dbg_free(s1);
|
||||
dbg_free(s2);
|
||||
|
||||
display_size(cmd, pv->pe_count * pv->pe_size / 2, SIZE_SHORT),
|
||||
display_size(cmd,
|
||||
(pv->pe_count - pv->pe_alloc_count) * pv->pe_size / 2,
|
||||
SIZE_SHORT));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -113,7 +105,6 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
|
||||
{
|
||||
int new_pvs_found = 0;
|
||||
int pvs_found = 0;
|
||||
char *s1, *s2, *s3;
|
||||
|
||||
struct list *pvs;
|
||||
struct list *pvh;
|
||||
@@ -205,14 +196,10 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
||||
log_print("Total: %d [%s] / in use: %d [%s] / in no VG: %d [%s]",
|
||||
pvs_found,
|
||||
(s1 = display_size(size_total / 2, SIZE_SHORT)),
|
||||
display_size(cmd, size_total / 2, SIZE_SHORT),
|
||||
pvs_found - new_pvs_found,
|
||||
(s2 =
|
||||
display_size((size_total - size_new) / 2, SIZE_SHORT)),
|
||||
new_pvs_found, (s3 = display_size(size_new / 2, SIZE_SHORT)));
|
||||
dbg_free(s1);
|
||||
dbg_free(s2);
|
||||
dbg_free(s3);
|
||||
display_size(cmd, (size_total - size_new) / 2, SIZE_SHORT),
|
||||
new_pvs_found, display_size(cmd, size_new / 2, SIZE_SHORT));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
235
tools/report.c
Normal file
235
tools/report.c
Normal file
@@ -0,0 +1,235 @@
|
||||
/*
|
||||
* Copyright (C) 2001 Sistina Software
|
||||
*
|
||||
* LVM is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* LVM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with LVM; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "tools.h"
|
||||
#include "report.h"
|
||||
#include "defaults.h"
|
||||
|
||||
static int _vgs_single(struct cmd_context *cmd, const char *vg_name,
|
||||
struct volume_group *vg, int consistent, void *handle)
|
||||
{
|
||||
if (!vg) {
|
||||
log_error("Volume group %s not found", vg_name);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!report_object(handle, vg, NULL, NULL, NULL))
|
||||
return ECMD_FAILED;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _lvs_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
void *handle)
|
||||
{
|
||||
if (!report_object(handle, lv->vg, lv, NULL, NULL))
|
||||
return ECMD_FAILED;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _segs_single(struct cmd_context *cmd, struct lv_segment *seg,
|
||||
void *handle)
|
||||
{
|
||||
if (!report_object(handle, seg->lv->vg, seg->lv, NULL, seg))
|
||||
return ECMD_FAILED;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _lvsegs_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
void *handle)
|
||||
{
|
||||
return process_each_segment_in_lv(cmd, lv, handle, _segs_single);
|
||||
}
|
||||
|
||||
static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg,
|
||||
struct physical_volume *pv, void *handle)
|
||||
{
|
||||
int consistent = 0;
|
||||
|
||||
if (!lock_vol(cmd, pv->vg_name, LCK_VG_READ)) {
|
||||
log_error("Can't lock %s: skipping", pv->vg_name);
|
||||
return 0;
|
||||
}
|
||||
vg = vg_read(cmd, pv->vg_name, &consistent);
|
||||
|
||||
if (!report_object(handle, vg, NULL, pv, NULL))
|
||||
return ECMD_FAILED;
|
||||
|
||||
unlock_vg(cmd, pv->vg_name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _report(struct cmd_context *cmd, int argc, char **argv,
|
||||
report_type_t report_type)
|
||||
{
|
||||
void *report_handle;
|
||||
char *opts, *str;
|
||||
const char *keys, *options, *separator;
|
||||
|
||||
int aligned, buffered, headings;
|
||||
|
||||
aligned = find_config_int(cmd->cf->root, "report/aligned", '/',
|
||||
DEFAULT_REP_ALIGNED);
|
||||
buffered = find_config_int(cmd->cf->root, "report/buffered", '/',
|
||||
DEFAULT_REP_BUFFERED);
|
||||
headings = find_config_int(cmd->cf->root, "report/headings", '/',
|
||||
DEFAULT_REP_HEADINGS);
|
||||
separator = find_config_str(cmd->cf->root, "report/separator", '/',
|
||||
DEFAULT_REP_SEPARATOR);
|
||||
|
||||
switch (report_type) {
|
||||
case LVS:
|
||||
keys = find_config_str(cmd->cf->root, "report/lvs_sort", '/',
|
||||
DEFAULT_LVS_SORT);
|
||||
if (!arg_count(cmd, verbose_ARG))
|
||||
options = find_config_str(cmd->cf->root,
|
||||
"report/lvs_cols", '/',
|
||||
DEFAULT_LVS_COLS);
|
||||
else
|
||||
options = find_config_str(cmd->cf->root,
|
||||
"report/lvs_cols_verbose",
|
||||
'/', DEFAULT_LVS_COLS_VERB);
|
||||
break;
|
||||
case VGS:
|
||||
keys = find_config_str(cmd->cf->root, "report/vgs_sort", '/',
|
||||
DEFAULT_VGS_SORT);
|
||||
if (!arg_count(cmd, verbose_ARG))
|
||||
options = find_config_str(cmd->cf->root,
|
||||
"report/vgs_cols", '/',
|
||||
DEFAULT_VGS_COLS);
|
||||
else
|
||||
options = find_config_str(cmd->cf->root,
|
||||
"report/vgs_cols_verbose",
|
||||
'/', DEFAULT_VGS_COLS_VERB);
|
||||
break;
|
||||
case PVS:
|
||||
keys = find_config_str(cmd->cf->root, "report/pvs_sort", '/',
|
||||
DEFAULT_PVS_SORT);
|
||||
if (!arg_count(cmd, verbose_ARG))
|
||||
options = find_config_str(cmd->cf->root,
|
||||
"report/pvs_cols", '/',
|
||||
DEFAULT_PVS_COLS);
|
||||
else
|
||||
options = find_config_str(cmd->cf->root,
|
||||
"report/pvs_cols_verbose",
|
||||
'/', DEFAULT_PVS_COLS_VERB);
|
||||
break;
|
||||
case SEGS:
|
||||
keys = find_config_str(cmd->cf->root, "report/segs_sort", '/',
|
||||
DEFAULT_SEGS_SORT);
|
||||
if (!arg_count(cmd, verbose_ARG))
|
||||
options = find_config_str(cmd->cf->root,
|
||||
"report/segs_cols", '/',
|
||||
DEFAULT_SEGS_COLS);
|
||||
else
|
||||
options = find_config_str(cmd->cf->root,
|
||||
"report/segs_cols_verbose",
|
||||
'/', DEFAULT_SEGS_COLS_VERB);
|
||||
break;
|
||||
}
|
||||
|
||||
/* If -o supplied use it, else use default for report_type */
|
||||
if (arg_count(cmd, options_ARG)) {
|
||||
opts = arg_str_value(cmd, options_ARG, "");
|
||||
if (!opts || !*opts) {
|
||||
log_error("Invalid options string: %s", opts);
|
||||
return 0;
|
||||
}
|
||||
if (*opts == '+') {
|
||||
*opts = ',';
|
||||
str =
|
||||
pool_alloc(cmd->mem,
|
||||
strlen(options) + strlen(opts) + 1);
|
||||
strcpy(str, options);
|
||||
strcat(str, opts);
|
||||
options = str;
|
||||
} else
|
||||
options = opts;
|
||||
}
|
||||
|
||||
/* -O overrides default sort settings */
|
||||
if (arg_count(cmd, sort_ARG))
|
||||
keys = arg_str_value(cmd, sort_ARG, "");
|
||||
|
||||
if (arg_count(cmd, separator_ARG))
|
||||
separator = arg_str_value(cmd, separator_ARG, " ");
|
||||
if (arg_count(cmd, separator_ARG))
|
||||
aligned = 0;
|
||||
if (arg_count(cmd, aligned_ARG))
|
||||
aligned = 1;
|
||||
if (arg_count(cmd, unbuffered_ARG) && !arg_count(cmd, sort_ARG))
|
||||
buffered = 0;
|
||||
if (arg_count(cmd, noheadings_ARG))
|
||||
headings = 0;
|
||||
|
||||
if (!(report_handle = report_init(cmd, options, keys, &report_type,
|
||||
separator, aligned, buffered,
|
||||
headings)))
|
||||
return 0;
|
||||
|
||||
switch (report_type) {
|
||||
case LVS:
|
||||
process_each_lv(cmd, argc, argv, LCK_VG_READ, report_handle,
|
||||
&_lvs_single);
|
||||
break;
|
||||
case VGS:
|
||||
process_each_vg(cmd, argc, argv, LCK_VG_READ, 0, report_handle,
|
||||
&_vgs_single);
|
||||
break;
|
||||
case PVS:
|
||||
process_each_pv(cmd, argc, argv, NULL, report_handle,
|
||||
&_pvs_single);
|
||||
break;
|
||||
case SEGS:
|
||||
process_each_lv(cmd, argc, argv, LCK_VG_READ, report_handle,
|
||||
&_lvsegs_single);
|
||||
break;
|
||||
}
|
||||
|
||||
report_output(report_handle);
|
||||
|
||||
report_free(report_handle);
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
int lvs(struct cmd_context *cmd, int argc, char **argv)
|
||||
{
|
||||
report_type_t type;
|
||||
|
||||
if (arg_count(cmd, segments_ARG))
|
||||
type = SEGS;
|
||||
else
|
||||
type = LVS;
|
||||
|
||||
return _report(cmd, argc, argv, type);
|
||||
}
|
||||
|
||||
int vgs(struct cmd_context *cmd, int argc, char **argv)
|
||||
{
|
||||
return _report(cmd, argc, argv, VGS);
|
||||
}
|
||||
|
||||
int pvs(struct cmd_context *cmd, int argc, char **argv)
|
||||
{
|
||||
return _report(cmd, argc, argv, PVS);
|
||||
}
|
||||
@@ -202,6 +202,28 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
|
||||
return ret_max;
|
||||
}
|
||||
|
||||
int process_each_segment_in_lv(struct cmd_context *cmd,
|
||||
struct logical_volume *lv,
|
||||
void *handle,
|
||||
int (*process_single) (struct cmd_context * cmd,
|
||||
struct lv_segment * seg,
|
||||
void *handle))
|
||||
{
|
||||
struct list *segh;
|
||||
struct lv_segment *seg;
|
||||
int ret_max = 0;
|
||||
int ret;
|
||||
|
||||
list_iterate(segh, &lv->segments) {
|
||||
seg = list_item(segh, struct lv_segment);
|
||||
ret = process_single(cmd, seg, handle);
|
||||
if (ret > ret_max)
|
||||
ret_max = ret;
|
||||
}
|
||||
|
||||
return ret_max;
|
||||
}
|
||||
|
||||
int process_each_vg(struct cmd_context *cmd, int argc, char **argv,
|
||||
int lock_type, int consistent, void *handle,
|
||||
int (*process_single) (struct cmd_context * cmd,
|
||||
@@ -303,23 +325,50 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
|
||||
int ret = 0;
|
||||
|
||||
struct pv_list *pvl;
|
||||
struct physical_volume *pv;
|
||||
struct list *pvs, *pvh;
|
||||
|
||||
if (argc) {
|
||||
log_verbose("Using physical volume(s) on command line");
|
||||
for (; opt < argc; opt++) {
|
||||
if (!(pvl = find_pv_in_vg(vg, argv[opt]))) {
|
||||
log_error("Physical Volume \"%s\" not found in "
|
||||
"Volume Group \"%s\"", argv[opt],
|
||||
vg->name);
|
||||
continue;
|
||||
if (vg) {
|
||||
if (!(pvl = find_pv_in_vg(vg, argv[opt]))) {
|
||||
log_error("Physical Volume \"%s\" not "
|
||||
"found in Volume Group "
|
||||
"\"%s\"", argv[opt],
|
||||
vg->name);
|
||||
continue;
|
||||
}
|
||||
pv = pvl->pv;
|
||||
} else {
|
||||
if (!(pv = pv_read(cmd, argv[opt], NULL, NULL))) {
|
||||
log_error("Failed to read physical "
|
||||
"volume \"%s\"", argv[opt]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
ret = process_single(cmd, vg, pvl->pv, handle);
|
||||
|
||||
ret = process_single(cmd, vg, pv, handle);
|
||||
if (ret > ret_max)
|
||||
ret_max = ret;
|
||||
}
|
||||
} else {
|
||||
log_verbose("Using all physical volume(s) in volume group");
|
||||
process_each_pv_in_vg(cmd, vg, handle, process_single);
|
||||
if (vg) {
|
||||
log_verbose("Using all physical volume(s) in "
|
||||
"volume group");
|
||||
process_each_pv_in_vg(cmd, vg, handle, process_single);
|
||||
} else {
|
||||
log_verbose("Scanning for physical volume names");
|
||||
if (!(pvs = get_pvs(cmd)))
|
||||
return ECMD_FAILED;
|
||||
|
||||
list_iterate(pvh, pvs) {
|
||||
pv = list_item(pvh, struct pv_list)->pv;
|
||||
ret = process_single(cmd, NULL, pv, handle);
|
||||
if (ret > ret_max)
|
||||
ret_max = ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret_max;
|
||||
|
||||
@@ -35,10 +35,9 @@ struct volume_group *recover_vg(struct cmd_context *cmd, const char *vgname,
|
||||
int process_each_vg(struct cmd_context *cmd, int argc, char **argv,
|
||||
int lock_type, int consistent, void *handle,
|
||||
int (*process_single) (struct cmd_context * cmd,
|
||||
const char *vg_name,
|
||||
struct volume_group *vg,
|
||||
int consistent,
|
||||
void *handle));
|
||||
const char *vg_name,
|
||||
struct volume_group * vg,
|
||||
int consistent, void *handle));
|
||||
|
||||
int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
|
||||
struct volume_group *vg, void *handle,
|
||||
@@ -53,6 +52,12 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
|
||||
struct logical_volume * lv,
|
||||
void *handle));
|
||||
|
||||
int process_each_segment_in_lv(struct cmd_context *cmd,
|
||||
struct logical_volume *lv, void *handle,
|
||||
int (*process_single) (struct cmd_context * cmd,
|
||||
struct lv_segment * seg,
|
||||
void *handle));
|
||||
|
||||
int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
|
||||
void *handle,
|
||||
int (*process_single) (struct cmd_context * cmd,
|
||||
|
||||
@@ -74,7 +74,8 @@ struct arg {
|
||||
int count;
|
||||
char *value;
|
||||
uint32_t i_value;
|
||||
uint64_t i64_value;
|
||||
int64_t i64_value;
|
||||
uint64_t ui64_value;
|
||||
sign_t sign;
|
||||
void *ptr;
|
||||
};
|
||||
@@ -94,13 +95,15 @@ void usage(const char *name);
|
||||
|
||||
/* the argument verify/normalise functions */
|
||||
int yes_no_arg(struct cmd_context *cmd, struct arg *a);
|
||||
int size_arg(struct cmd_context *cmd, struct arg *a);
|
||||
int size_kb_arg(struct cmd_context *cmd, struct arg *a);
|
||||
int size_mb_arg(struct cmd_context *cmd, struct arg *a);
|
||||
int int_arg(struct cmd_context *cmd, struct arg *a);
|
||||
int int_arg_with_sign(struct cmd_context *cmd, struct arg *a);
|
||||
int minor_arg(struct cmd_context *cmd, struct arg *a);
|
||||
int string_arg(struct cmd_context *cmd, struct arg *a);
|
||||
int permission_arg(struct cmd_context *cmd, struct arg *a);
|
||||
int metadatatype_arg(struct cmd_context *cmd, struct arg *a);
|
||||
int units_arg(struct cmd_context *cmd, struct arg *a);
|
||||
|
||||
char yes_no_prompt(const char *prompt, ...);
|
||||
|
||||
@@ -126,12 +129,18 @@ static inline uint32_t arg_int_value(struct cmd_context *cmd, int a,
|
||||
return arg_count(cmd, a) ? cmd->args[a].i_value : def;
|
||||
}
|
||||
|
||||
static inline uint64_t arg_int64_value(struct cmd_context *cmd, int a,
|
||||
uint64_t def)
|
||||
static inline int64_t arg_int64_value(struct cmd_context *cmd, int a,
|
||||
uint64_t def)
|
||||
{
|
||||
return arg_count(cmd, a) ? cmd->args[a].i64_value : def;
|
||||
}
|
||||
|
||||
static inline uint64_t arg_uint64_value(struct cmd_context *cmd, int a,
|
||||
uint64_t def)
|
||||
{
|
||||
return arg_count(cmd, a) ? cmd->args[a].ui64_value : def;
|
||||
}
|
||||
|
||||
static inline void *arg_ptr_value(struct cmd_context *cmd, int a, void *def)
|
||||
{
|
||||
return arg_count(cmd, a) ? cmd->args[a].ptr : def;
|
||||
|
||||
@@ -38,7 +38,6 @@ static int vgck_single(struct cmd_context *cmd, const char *vg_name,
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
/* FIXME: free */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
|
||||
uint64_t pvmetadatasize = 0;
|
||||
uint64_t pe_end = 0, pe_start = 0;
|
||||
struct list *pvh;
|
||||
int change_made = 0;
|
||||
|
||||
if (!vg) {
|
||||
log_error("Unable to find volume group \"%s\"", vg_name);
|
||||
@@ -62,7 +63,7 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
|
||||
}
|
||||
|
||||
if (cmd->fmt->features & FMT_MDAS) {
|
||||
pvmetadatasize = arg_int64_value(cmd, metadatasize_ARG, 0) * 2;
|
||||
pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG, 0) * 2;
|
||||
if (!pvmetadatasize)
|
||||
pvmetadatasize =
|
||||
find_config_int(cmd->cf->root,
|
||||
@@ -97,11 +98,15 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
|
||||
pvmetadatasize, &mdas))) {
|
||||
log_error("Failed to setup physical volume \"%s\"",
|
||||
dev_name(existing_pv->dev));
|
||||
log_error("Use pvcreate and vgcfgrestore to repair "
|
||||
"from archived metadata.");
|
||||
if (change_made)
|
||||
log_error("Use pvcreate and vgcfgrestore to "
|
||||
"repair from archived metadata.");
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
/* Need to revert manually if it fails after this point */
|
||||
change_made = 1;
|
||||
|
||||
log_verbose("Set up physical volume for \"%s\" with %" PRIu64
|
||||
" available sectors", dev_name(pv->dev), pv->size);
|
||||
|
||||
|
||||
@@ -62,6 +62,23 @@ static int vgdisplay_single(struct cmd_context *cmd, const char *vg_name,
|
||||
|
||||
int vgdisplay(struct cmd_context *cmd, int argc, char **argv)
|
||||
{
|
||||
if (arg_count(cmd, columns_ARG)) {
|
||||
if (arg_count(cmd, colon_ARG) ||
|
||||
arg_count(cmd, activevolumegroups_ARG) ||
|
||||
arg_count(cmd, short_ARG)) {
|
||||
log_error("Incompatible options selected");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
return vgs(cmd, argc, argv);
|
||||
} else if (arg_count(cmd, aligned_ARG) ||
|
||||
arg_count(cmd, noheadings_ARG) ||
|
||||
arg_count(cmd, options_ARG) ||
|
||||
arg_count(cmd, separator_ARG) ||
|
||||
arg_count(cmd, sort_ARG) || arg_count(cmd, unbuffered_ARG)) {
|
||||
log_error("Incompatible options selected");
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
if (arg_count(cmd, colon_ARG) && arg_count(cmd, short_ARG)) {
|
||||
log_error("Option -c is not allowed with option -s");
|
||||
return EINVALID_CMD_LINE;
|
||||
|
||||
Reference in New Issue
Block a user