master - cleanup: time: error out on incorrect time_format and indentation in config_settings.h
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=77f0e7a450dc2b...
Commit: 77f0e7a450dc2bc3e42bb4854e1032873d661c58
Parent: 621398ebb79760d6e86f8264e4198946d59e6522
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Jun 29 16:16:58 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jun 29 16:17:33 2015 +0200
cleanup: time: error out on incorrect time_format and indentation in config_settings.h
---
conf/example.conf.in | 7 ++++---
lib/commands/toolcontext.c | 7 ++++---
lib/config/config_settings.h | 8 ++++----
3 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/conf/example.conf.in b/conf/example.conf.in
index 41b9702..4520162 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -1416,7 +1416,7 @@ activation {
# Format specification is a string which may contain special character
# sequences and ordinary character sequences. Ordinary character sequences
# are copied verbatim. Each special character sequence is introduced by '%'
- # character and such sequence is then substitued with a value as described below:
+ # character and such sequence is then substituted with a value as described below:
# %a The abbreviated name of the day of the week according to the
# current locale.
# %A The full name of the day of the week according to the current locale.
@@ -1480,8 +1480,9 @@ activation {
# %y The year as a decimal number without a century (range 00 to 99). (alt E, alt O)
# %Y The year as a decimal number including the century. (alt E)
# %z The +hhmm or -hhmm numeric timezone (that is, the hour and minute
- # offset from UTC).%Z The timezone name or abbreviation.
- # %% A literal '%' character.
+ # offset from UTC).
+ # %Z The timezone name or abbreviation.
+ # %% A literal '%' character.
# time_format = "%Y-%m-%d %T %z"
# Configuration option report/devtypes_sort.
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 09c14a3..4265954 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -460,8 +460,8 @@ static const char *_set_time_format(struct cmd_context *cmd)
return tf;
bad:
- log_error("Incorrect time format specified. Using default time format instead.");
- return DEFAULT_TIME_FORMAT;
+ log_error("Invalid time format \"%s\" supplied.", tf);
+ return NULL;
}
int process_profilable_config(struct cmd_context *cmd)
@@ -477,7 +477,8 @@ int process_profilable_config(struct cmd_context *cmd)
cmd->report_binary_values_as_numeric = find_config_tree_bool(cmd, report_binary_values_as_numeric_CFG, NULL);
cmd->default_settings.suffix = find_config_tree_bool(cmd, global_suffix_CFG, NULL);
cmd->report_list_item_separator = find_config_tree_str(cmd, report_list_item_separator_CFG, NULL);
- cmd->time_format = _set_time_format(cmd);
+ if (!(cmd->time_format = _set_time_format(cmd)))
+ return 0;
return 1;
}
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index ac68906..fb05b85 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -81,7 +81,7 @@
* (see also lvmconfig ... --withversions)
*
* unconfigured_default_value: Unconfigured default value used as a default value which is
- * in "@...@" form and which is then substitued with concrete value
+ * in "@...@" form and which is then substituted with concrete value
* while running configure.
* (see also 'lvmconfig --type default --unconfigured')
*
@@ -1362,7 +1362,7 @@ cfg(report_time_format_CFG, "time_format", report_CFG_SECTION, CFG_PROFILABLE |
"Format specification is a string which may contain special character\n"
"sequences and ordinary character sequences. Ordinary character sequences\n"
"are copied verbatim. Each special character sequence is introduced by \'%\'\n"
- "character and such sequence is then substitued with a value as described below:\n"
+ "character and such sequence is then substituted with a value as described below:\n"
"\%a The abbreviated name of the day of the week according to the\n"
" current locale.\n"
"\%A The full name of the day of the week according to the current locale.\n"
@@ -1426,9 +1426,9 @@ cfg(report_time_format_CFG, "time_format", report_CFG_SECTION, CFG_PROFILABLE |
"\%y The year as a decimal number without a century (range 00 to 99). (alt E, alt O)\n"
"\%Y The year as a decimal number including the century. (alt E)\n"
"\%z The +hhmm or -hhmm numeric timezone (that is, the hour and minute\n"
- " offset from UTC)."
+ " offset from UTC).\n"
"\%Z The timezone name or abbreviation.\n"
- "\%\% A literal '\%' character.\n")
+ "\%\% A literal '\%' character.\n")
cfg(report_devtypes_sort_CFG, "devtypes_sort", report_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_DEVTYPES_SORT, vsn(2, 2, 101), NULL, 0, NULL,
"List of columns to sort by when reporting 'lvm devtypes' command.\n"
8 years, 10 months
master - lv: time: increase buffer to 4k in lv_time_dup
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=621398ebb79760...
Commit: 621398ebb79760d6e86f8264e4198946d59e6522
Parent: 158723608911fae1f18df5ea3c506434b521b5b5
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Jun 29 15:24:00 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jun 29 15:24:00 2015 +0200
lv: time: increase buffer to 4k in lv_time_dup
---
lib/metadata/lv.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index 2a87edd..f0a3d77 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -875,7 +875,7 @@ int lv_set_creation(struct logical_volume *lv,
char *lv_time_dup(struct dm_pool *mem, const struct logical_volume *lv, int iso_mode)
{
- char buffer[50];
+ char buffer[4096];
struct tm *local_tm;
time_t ts = (time_t)lv->timestamp;
const char *format = iso_mode ? DEFAULT_TIME_FORMAT : lv->vg->cmd->time_format;
8 years, 10 months
master - toolcontext: use proper set of chars to check time format against
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=158723608911fa...
Commit: 158723608911fae1f18df5ea3c506434b521b5b5
Parent: 125cd06698bc1c52b812faa1686988b92cc2e192
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Jun 29 14:45:45 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jun 29 14:45:53 2015 +0200
toolcontext: use proper set of chars to check time format against
---
lib/commands/toolcontext.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 0d243f2..09c14a3 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -443,10 +443,10 @@ static const char *_set_time_format(struct cmd_context *cmd)
chars_to_check = allowed_format_chars;
for (i = 0; chars_to_check[i]; i++) {
- if (c == allowed_format_chars[i])
+ if (c == chars_to_check[i])
break;
}
- if (!allowed_format_chars[i])
+ if (!chars_to_check[i])
goto_bad;
}
else if (isprint(c))
8 years, 10 months
master - conf: make time format configurable
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=125cd06698bc1c...
Commit: 125cd06698bc1c52b812faa1686988b92cc2e192
Parent: 6f793d34ca8993d1e70df58340d7c1897b368a09
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon May 25 16:13:07 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jun 29 14:30:35 2015 +0200
conf: make time format configurable
Make it possible to define format for time that is displayed.
The way the format is defined is equal to the way that is used
for strftime function, although not all formatting options as
used in strftime are available for LVM2 - the set is restricted
(e.g. we do not allow newline to be printed). The lvm.conf
comments contain the whole list that LVM2 accepts for time format
together with brief description (copied from strftime man page).
For example:
(defaults used - the format is the same as used before this patch)
$ lvs -o+time vg/lvol0 vg/lvol1
LV VG Attr LSize Time
lvol0 vg -wi-a----- 4.00m 2015-06-25 16:18:34 +0200
lvol1 vg -wi-a----- 4.00m 2015-06-29 09:17:11 +0200
(using 'time_format = "@%s"' in lvm.conf - number of seconds
since the Epoch)
$ lvs -o+time vg/lvol0 vg/lvol1
LV VG Attr LSize Time
lvol0 vg -wi-a----- 4.00m @1435241914
lvol1 vg -wi-a----- 4.00m @1435562231
---
WHATS_NEW | 1 +
conf/example.conf.in | 73 ++++++++++++++++++++++++++++++++++++++++++
lib/commands/toolcontext.c | 52 ++++++++++++++++++++++++++++++
lib/commands/toolcontext.h | 2 +
lib/config/config_settings.h | 73 ++++++++++++++++++++++++++++++++++++++++++
lib/config/defaults.h | 1 +
lib/display/display.c | 2 +-
lib/metadata/lv.c | 7 ++--
lib/metadata/lv.h | 2 +-
lib/report/properties.c | 2 +-
lib/report/report.c | 2 +-
11 files changed, 209 insertions(+), 8 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 813eb5e..9a7ebe1 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.123 -
=================================
+ Add report/time_format lvm.conf option to define time format for report.
Fix makefile shell compare == when building lvmetad lvmpolld (2.02.120).
Add --type full to lvmconfig for full configuration tree view.
Add undocumented environment variables to lvm man page. (2.02.119)
diff --git a/conf/example.conf.in b/conf/example.conf.in
index 3433508..41b9702 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -1411,6 +1411,79 @@ activation {
# value could not be determined).
# binary_values_as_numeric = 0
+ # Configuration option report/time_format.
+ # Set time format for fields reporting time values.
+ # Format specification is a string which may contain special character
+ # sequences and ordinary character sequences. Ordinary character sequences
+ # are copied verbatim. Each special character sequence is introduced by '%'
+ # character and such sequence is then substitued with a value as described below:
+ # %a The abbreviated name of the day of the week according to the
+ # current locale.
+ # %A The full name of the day of the week according to the current locale.
+ # %b The abbreviated month name according to the current locale.
+ # %B The full month name according to the current locale.
+ # %c The preferred date and time representation for the current locale. (alt E)
+ # %C The century number (year/100) as a 2-digit integer. (alt E)
+ # %d The day of the month as a decimal number (range 01 to 31). (alt O)
+ # %D Equivalent to %m/%d/%y. (For Americans only. Americans should
+ # note that in other countries%d/%m/%y is rather common. This means
+ # that in international context this format is ambiguous and should not
+ # be used.
+ # %e Like %d, the day of the month as a decimal number, but a leading zero
+ # is replaced by a space. (alt O)
+ # %E Modifier: use alternative local-dependent representation if available.
+ # %F Equivalent to %Y-%m-%d (the ISO 8601 date format).
+ # %G The ISO 8601 week-based year with century as adecimal number. The 4-digit
+ # year corresponding to the ISO week number (see %V). This has the same
+ # format and value as %Y, except that if the ISO week number belongs to
+ # the previous or next year, that year is used instead.
+ # %g Like %G, but without century, that is, with a 2-digit year (00-99).
+ # %h Equivalent to %b.
+ # %H The hour as a decimal number using a 24-hour clock (range 00 to 23). (alt O)
+ # %I The hour as a decimal number using a 12-hour clock (range 01 to 12). (alt O)
+ # %j The day of the year as a decimal number (range 001 to 366).
+ # %k The hour (24-hour clock) as a decimal number (range 0 to 23);
+ # single digits are preceded by a blank. (See also %H.)
+ # %l The hour (12-hour clock) as a decimal number (range 1 to 12);
+ # single digits are preceded by a blank. (See also %I.)
+ # %m The month as a decimal number (range 01 to 12). (alt O)
+ # %M The minute as a decimal number (range 00 to 59). (alt O)
+ # %O Modifier: use alternative numeric symbols.
+ # %p Either "AM" or "PM" according to the given time value,
+ # or the corresponding strings for the current locale. Noon is
+ # treated as "PM" and midnight as "AM".
+ # %P Like %p but in lowercase: "am" or "pm" or a corresponding
+ # string for the current locale.
+ # %r The time in a.m. or p.m. notation. In the POSIX locale this is
+ # equivalent to %I:%M:%S %p.
+ # %R The time in 24-hour notation (%H:%M). For a version including
+ # the seconds, see %T below.
+ # %s The number of seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC)
+ # %S The second as a decimal number (range 00 to 60).
+ # (The range is up to 60 to allow for occasional leap seconds.) (alt O)
+ # %t A tab character.
+ # %T The time in 24-hour notation (%H:%M:%S).
+ # %u The day of the week as a decimal, range 1 to 7, Monday being 1.
+ # See also %w. (alt O)
+ # %U The week number of the current year as a decimal number,
+ # range 00 to 53, starting with the first Sunday as the first
+ # day of week 01. See also %V and %W. (alt O)
+ # %V The ISO 8601 week number of the current year as a decimal number,
+ # range 01 to 53, where week 1 is the first week that has at least 4 days
+ # in the new year. See also %U and %W. (alt O)
+ # %w The day of the week as a decimal, range 0 to 6, Sunday being 0.
+ # See also %u. (alt O)
+ # %W The week number of the current year as a decimal number, range 00 to 53,
+ # starting with the first Monday as the first day of week 01. (alt O)
+ # %x The preferred date representation for the current locale without the time. (alt E)
+ # %X The preferred time representation for the current locale without the date. (alt E)
+ # %y The year as a decimal number without a century (range 00 to 99). (alt E, alt O)
+ # %Y The year as a decimal number including the century. (alt E)
+ # %z The +hhmm or -hhmm numeric timezone (that is, the hour and minute
+ # offset from UTC).%Z The timezone name or abbreviation.
+ # %% A literal '%' character.
+ # time_format = "%Y-%m-%d %T %z"
+
# Configuration option report/devtypes_sort.
# List of columns to sort by when reporting 'lvm devtypes' command.
# See 'lvm devtypes -o help' for the list of possible fields.
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 47aa209..0d243f2 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -413,6 +413,57 @@ static int _check_config(struct cmd_context *cmd)
return 1;
}
+static const char *_set_time_format(struct cmd_context *cmd)
+{
+ /* Compared to strftime, we do not allow "newline" character - the %n in format. */
+ static const char *allowed_format_chars = "aAbBcCdDeFGghHIjklmMpPrRsStTuUVwWxXyYzZ%";
+ static const char *allowed_alternative_format_chars_e = "cCxXyY";
+ static const char *allowed_alternative_format_chars_o = "deHImMSuUVwWy";
+ static const char *chars_to_check;
+ const char *tf = find_config_tree_str(cmd, report_time_format_CFG, NULL);
+ const char *p_fmt;
+ size_t i;
+ char c;
+
+ if (!*tf) {
+ log_error("Configured time format is empty string.");
+ goto bad;
+ } else {
+ p_fmt = tf;
+ while ((c = *p_fmt)) {
+ if (c == '%') {
+ c = *++p_fmt;
+ if (c == 'E') {
+ c = *++p_fmt;
+ chars_to_check = allowed_alternative_format_chars_e;
+ } else if (c == 'O') {
+ c = *++p_fmt;
+ chars_to_check = allowed_alternative_format_chars_o;
+ } else
+ chars_to_check = allowed_format_chars;
+
+ for (i = 0; chars_to_check[i]; i++) {
+ if (c == allowed_format_chars[i])
+ break;
+ }
+ if (!allowed_format_chars[i])
+ goto_bad;
+ }
+ else if (isprint(c))
+ p_fmt++;
+ else {
+ log_error("Configured time format contains non-printable characters.");
+ goto bad;
+ }
+ }
+ }
+
+ return tf;
+bad:
+ log_error("Incorrect time format specified. Using default time format instead.");
+ return DEFAULT_TIME_FORMAT;
+}
+
int process_profilable_config(struct cmd_context *cmd)
{
if (!(cmd->default_settings.unit_factor =
@@ -426,6 +477,7 @@ int process_profilable_config(struct cmd_context *cmd)
cmd->report_binary_values_as_numeric = find_config_tree_bool(cmd, report_binary_values_as_numeric_CFG, NULL);
cmd->default_settings.suffix = find_config_tree_bool(cmd, global_suffix_CFG, NULL);
cmd->report_list_item_separator = find_config_tree_str(cmd, report_list_item_separator_CFG, NULL);
+ cmd->time_format = _set_time_format(cmd);
return 1;
}
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index 66bea5f..46d83b3 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -95,6 +95,8 @@ struct cmd_context {
unsigned ignore_clustered_vgs:1;
unsigned threaded:1; /* Set if running within a thread e.g. clvmd */
+ const char *time_format;
+
unsigned independent_metadata_areas:1; /* Active formats have MDAs outside PVs */
unsigned unknown_system_id:1;
unsigned include_foreign_vgs:1;
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index 2c5e2f8..ac68906 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -1357,6 +1357,79 @@ cfg(report_binary_values_as_numeric_CFG, "binary_values_as_numeric", report_CFG_
"(not counting the 'unknown' value which denotes that the\n"
"value could not be determined).\n")
+cfg(report_time_format_CFG, "time_format", report_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_TIME_FORMAT, vsn(2, 2, 121), NULL, 0, NULL,
+ "Set time format for fields reporting time values.\n"
+ "Format specification is a string which may contain special character\n"
+ "sequences and ordinary character sequences. Ordinary character sequences\n"
+ "are copied verbatim. Each special character sequence is introduced by \'%\'\n"
+ "character and such sequence is then substitued with a value as described below:\n"
+ "\%a The abbreviated name of the day of the week according to the\n"
+ " current locale.\n"
+ "\%A The full name of the day of the week according to the current locale.\n"
+ "\%b The abbreviated month name according to the current locale.\n"
+ "\%B The full month name according to the current locale.\n"
+ "\%c The preferred date and time representation for the current locale. (alt E)\n"
+ "\%C The century number (year/100) as a 2-digit integer. (alt E)\n"
+ "\%d The day of the month as a decimal number (range 01 to 31). (alt O)\n"
+ "\%D Equivalent to \%m/\%d/\%y. (For Americans only. Americans should\n"
+ " note that in other countries\%d/\%m/\%y is rather common. This means\n"
+ " that in international context this format is ambiguous and should not\n"
+ " be used.\n"
+ "\%e Like \%d, the day of the month as a decimal number, but a leading zero\n"
+ " is replaced by a space. (alt O)\n"
+ "\%E Modifier: use alternative local-dependent representation if available.\n"
+ "\%F Equivalent to \%Y-\%m-\%d (the ISO 8601 date format).\n"
+ "\%G The ISO 8601 week-based year with century as adecimal number. The 4-digit\n"
+ " year corresponding to the ISO week number (see \%V). This has the same\n"
+ " format and value as \%Y, except that if the ISO week number belongs to\n"
+ " the previous or next year, that year is used instead.\n"
+ "\%g Like \%G, but without century, that is, with a 2-digit year (00-99).\n"
+ "\%h Equivalent to \%b.\n"
+ "\%H The hour as a decimal number using a 24-hour clock (range 00 to 23). (alt O)\n"
+ "\%I The hour as a decimal number using a 12-hour clock (range 01 to 12). (alt O)\n"
+ "\%j The day of the year as a decimal number (range 001 to 366).\n"
+ "\%k The hour (24-hour clock) as a decimal number (range 0 to 23);\n"
+ " single digits are preceded by a blank. (See also \%H.)\n"
+ "\%l The hour (12-hour clock) as a decimal number (range 1 to 12);\n"
+ " single digits are preceded by a blank. (See also \%I.)\n"
+ "\%m The month as a decimal number (range 01 to 12). (alt O)\n"
+ "\%M The minute as a decimal number (range 00 to 59). (alt O)\n"
+ "\%O Modifier: use alternative numeric symbols.\n"
+ "\%p Either \"AM\" or \"PM\" according to the given time value,\n"
+ " or the corresponding strings for the current locale. Noon is\n"
+ " treated as \"PM\" and midnight as \"AM\".\n"
+ "\%P Like \%p but in lowercase: \"am\" or \"pm\" or a corresponding\n"
+ " string for the current locale.\n"
+ "\%r The time in a.m. or p.m. notation. In the POSIX locale this is\n"
+ " equivalent to \%I:\%M:\%S \%p.\n"
+ "\%R The time in 24-hour notation (\%H:\%M). For a version including\n"
+ " the seconds, see \%T below.\n"
+ "\%s The number of seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC)\n"
+ "\%S The second as a decimal number (range 00 to 60).\n"
+ " (The range is up to 60 to allow for occasional leap seconds.) (alt O)\n"
+ "\%t A tab character.\n"
+ "\%T The time in 24-hour notation (\%H:\%M:\%S).\n"
+ "\%u The day of the week as a decimal, range 1 to 7, Monday being 1.\n"
+ " See also \%w. (alt O)\n"
+ "\%U The week number of the current year as a decimal number,\n"
+ " range 00 to 53, starting with the first Sunday as the first\n"
+ " day of week 01. See also \%V and \%W. (alt O)\n"
+ "\%V The ISO 8601 week number of the current year as a decimal number,\n"
+ " range 01 to 53, where week 1 is the first week that has at least 4 days\n"
+ " in the new year. See also \%U and \%W. (alt O)\n"
+ "\%w The day of the week as a decimal, range 0 to 6, Sunday being 0.\n"
+ " See also \%u. (alt O)\n"
+ "\%W The week number of the current year as a decimal number, range 00 to 53,\n"
+ " starting with the first Monday as the first day of week 01. (alt O)\n"
+ "\%x The preferred date representation for the current locale without the time. (alt E)\n"
+ "\%X The preferred time representation for the current locale without the date. (alt E)\n"
+ "\%y The year as a decimal number without a century (range 00 to 99). (alt E, alt O)\n"
+ "\%Y The year as a decimal number including the century. (alt E)\n"
+ "\%z The +hhmm or -hhmm numeric timezone (that is, the hour and minute\n"
+ " offset from UTC)."
+ "\%Z The timezone name or abbreviation.\n"
+ "\%\% A literal '\%' character.\n")
+
cfg(report_devtypes_sort_CFG, "devtypes_sort", report_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_DEVTYPES_SORT, vsn(2, 2, 101), NULL, 0, NULL,
"List of columns to sort by when reporting 'lvm devtypes' command.\n"
"See 'lvm devtypes -o help' for the list of possible fields.\n")
diff --git a/lib/config/defaults.h b/lib/config/defaults.h
index d764ec9..3745639 100644
--- a/lib/config/defaults.h
+++ b/lib/config/defaults.h
@@ -197,6 +197,7 @@
#define DEFAULT_REP_QUOTED 1
#define DEFAULT_REP_SEPARATOR " "
#define DEFAULT_REP_LIST_ITEM_SEPARATOR ","
+#define DEFAULT_TIME_FORMAT "%Y-%m-%d %T %z"
#define DEFAULT_LVS_COLS "lv_name,vg_name,lv_attr,lv_size,pool_lv,origin,data_percent,metadata_percent,move_pv,mirror_log,copy_percent,convert_lv"
#define DEFAULT_VGS_COLS "vg_name,pv_count,lv_count,snap_count,vg_attr,vg_size,vg_free"
diff --git a/lib/display/display.c b/lib/display/display.c
index 8f075d9..059bc8f 100644
--- a/lib/display/display.c
+++ b/lib/display/display.c
@@ -489,7 +489,7 @@ int lvdisplay_full(struct cmd_context *cmd,
log_print("LV UUID %s", uuid);
log_print("LV Write Access %s", access_str);
log_print("LV Creation host, time %s, %s",
- lv_host_dup(cmd->mem, lv), lv_time_dup(cmd->mem, lv));
+ lv_host_dup(cmd->mem, lv), lv_time_dup(cmd->mem, lv, 1));
if (lv_is_origin(lv)) {
log_print("LV snapshot status source of");
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index 9a99c8d..2a87edd 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -873,17 +873,16 @@ int lv_set_creation(struct logical_volume *lv,
return 1;
}
-char *lv_time_dup(struct dm_pool *mem, const struct logical_volume *lv)
+char *lv_time_dup(struct dm_pool *mem, const struct logical_volume *lv, int iso_mode)
{
char buffer[50];
struct tm *local_tm;
time_t ts = (time_t)lv->timestamp;
+ const char *format = iso_mode ? DEFAULT_TIME_FORMAT : lv->vg->cmd->time_format;
if (!ts ||
!(local_tm = localtime(&ts)) ||
- /* FIXME: make this lvm.conf configurable */
- !strftime(buffer, sizeof(buffer),
- "%Y-%m-%d %T %z", local_tm))
+ !strftime(buffer, sizeof(buffer), format, local_tm))
buffer[0] = 0;
return dm_pool_strdup(mem, buffer);
diff --git a/lib/metadata/lv.h b/lib/metadata/lv.h
index 4475085..f7bbb1e 100644
--- a/lib/metadata/lv.h
+++ b/lib/metadata/lv.h
@@ -91,7 +91,7 @@ char *lvseg_monitor_dup(struct dm_pool *mem, const struct lv_segment *seg);
char *lvseg_tags_dup(const struct lv_segment *seg);
char *lvseg_devices(struct dm_pool *mem, const struct lv_segment *seg);
char *lvseg_seg_pe_ranges(struct dm_pool *mem, const struct lv_segment *seg);
-char *lv_time_dup(struct dm_pool *mem, const struct logical_volume *lv);
+char *lv_time_dup(struct dm_pool *mem, const struct logical_volume *lv, int iso_mode);
char *lv_host_dup(struct dm_pool *mem, const struct logical_volume *lv);
int lv_set_creation(struct logical_volume *lv,
const char *hostname, uint64_t timestamp);
diff --git a/lib/report/properties.c b/lib/report/properties.c
index b0a91a7..5cd3c4d 100644
--- a/lib/report/properties.c
+++ b/lib/report/properties.c
@@ -342,7 +342,7 @@ GET_LV_NUM_PROPERTY_FN(metadata_percent, _metadata_percent(lv))
#define _metadata_percent_set prop_not_implemented_set
GET_LV_NUM_PROPERTY_FN(lv_metadata_size, lv_metadata_size(lv) * SECTOR_SIZE)
#define _lv_metadata_size_set prop_not_implemented_set
-GET_LV_STR_PROPERTY_FN(lv_time, lv_time_dup(lv->vg->vgmem, lv))
+GET_LV_STR_PROPERTY_FN(lv_time, lv_time_dup(lv->vg->vgmem, lv, 0))
#define _lv_time_set prop_not_implemented_set
GET_LV_STR_PROPERTY_FN(lv_host, lv_host_dup(lv->vg->vgmem, lv))
#define _lv_host_set prop_not_implemented_set
diff --git a/lib/report/report.c b/lib/report/report.c
index a107669..30b3767 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1474,7 +1474,7 @@ static int _lvtime_disp(struct dm_report *rh, struct dm_pool *mem,
char *repstr;
uint64_t *sortval;
- if (!(repstr = lv_time_dup(mem, lv)) ||
+ if (!(repstr = lv_time_dup(mem, lv, 0)) ||
!(sortval = dm_pool_alloc(mem, sizeof(uint64_t)))) {
log_error("Failed to allocate buffer for time.");
return 0;
8 years, 10 months
master - config: regenerate lvm.conf.in and lvmlocal.conf.in
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6f793d34ca8993...
Commit: 6f793d34ca8993d1e70df58340d7c1897b368a09
Parent: 7b45a1fc60859faa4163bde8332ac7c173802640
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Jun 29 13:43:28 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jun 29 13:43:28 2015 +0200
config: regenerate lvm.conf.in and lvmlocal.conf.in
---
conf/example.conf.in | 19 -------------------
conf/lvmlocal.conf.in | 1 -
2 files changed, 0 insertions(+), 20 deletions(-)
diff --git a/conf/example.conf.in b/conf/example.conf.in
index 41d219a..3433508 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -103,7 +103,6 @@ devices {
# Example:
# preferred_names = [ "^/dev/mpath/", "^/dev/mapper/mpath", "^/dev/[hs]d" ]
# This configuration option does not have a default value defined.
- # preferred_names = [ ]
# Configuration option devices/filter.
# Limit the block devices that are used by LVM commands.
@@ -176,7 +175,6 @@ devices {
# types = [ "fd", 16 ]
# This configuration option is advanced.
# This configuration option does not have a default value defined.
- # types = [ ]
# Configuration option devices/sysfs_scan.
# Restrict device scanning to block devices appearing in sysfs.
@@ -325,7 +323,6 @@ allocation {
# they are situated.
# cling_tag_list = [ "@site1", "@site2" ]
# This configuration option does not have a default value defined.
- # cling_tag_list = [ ]
# Configuration option allocation/maximise_cling.
# Use a previous allocation algorithm.
@@ -398,7 +395,6 @@ allocation {
# end of the spectrum. Supported values range from 32(kiB) to
# 1048576 in multiples of 32.
# This configuration option does not have a default value defined.
- # cache_pool_chunk_size = 128
# Configuration option allocation/thin_pool_metadata_require_separate_pvs.
# Thin pool metdata and data will always use different PVs.
@@ -436,7 +432,6 @@ allocation {
# chunk size starting from 64KB. Supported values are in
# the range 64 to 1048576.
# This configuration option does not have a default value defined.
- # thin_pool_chunk_size = 128
# Configuration option allocation/physical_extent_size.
# Default physical extent size to use for new VGs (in KB).
@@ -470,7 +465,6 @@ log {
# Configuration option log/file.
# Write error and debug log messages to a file specified here.
# This configuration option does not have a default value defined.
- # file = ""
# Configuration option log/overwrite.
# Overwrite the log file each time the program is run.
@@ -621,11 +615,9 @@ global {
# If support for LVM1 metadata was compiled as a shared library use
# format_libraries = "liblvm2format1.so"
# This configuration option does not have a default value defined.
- # format_libraries = [ ]
# Configuration option global/segment_libraries.
# This configuration option does not have a default value defined.
- # segment_libraries = [ ]
# Configuration option global/proc.
# Location of proc filesystem.
@@ -702,7 +694,6 @@ global {
# Configuration option global/library_dir.
# Search this directory first for shared libraries.
# This configuration option does not have a default value defined.
- # library_dir = ""
# Configuration option global/locking_library.
# The external locking library to use for locking_type 2.
@@ -869,7 +860,6 @@ global {
# Configuration option global/thin_repair_options.
# List of options passed to the thin_repair command.
# This configuration option does not have a default value defined.
- # thin_repair_options = [ ]
# Configuration option global/thin_disabled_features.
# Features to not use in the thin driver.
@@ -881,7 +871,6 @@ global {
# Example:
# thin_disabled_features = [ "discards", "block_size" ]
# This configuration option does not have a default value defined.
- # thin_disabled_features = [ ]
# Configuration option global/cache_check_executable.
# The full path to the cache_check command.
@@ -917,7 +906,6 @@ global {
# Configuration option global/cache_repair_options.
# List of options passed to the cache_repair command.
# This configuration option does not have a default value defined.
- # cache_repair_options = [ ]
# Configuration option global/system_id_source.
# The method LVM uses to set the local system ID.
@@ -945,7 +933,6 @@ global {
# This is used when system_id_source is set to 'file'.
# Comments starting with the character # are ignored.
# This configuration option does not have a default value defined.
- # system_id_file = ""
# Configuration option global/use_lvmpolld.
# Use lvmpolld to supervise long running LVM commands.
@@ -1057,7 +1044,6 @@ activation {
# Example:
# volume_list = [ "vg1", "vg2/lvol1", "@tag1", "@*" ]
# This configuration option does not have a default value defined.
- # volume_list = [ ]
# Configuration option activation/auto_activation_volume_list.
# Only LVs selected by this list are auto-activated.
@@ -1089,7 +1075,6 @@ activation {
# Possible options are: vgname, vgname/lvname, @tag, @*
# See volume_list for how these options are matched to LVs.
# This configuration option does not have a default value defined.
- # auto_activation_volume_list = [ ]
# Configuration option activation/read_only_volume_list.
# LVs in this list are activated in read-only mode.
@@ -1101,7 +1086,6 @@ activation {
# Possible options are: vgname, vgname/lvname, @tag, @*
# See volume_list for how these options are matched to LVs.
# This configuration option does not have a default value defined.
- # read_only_volume_list = [ ]
# Configuration option activation/raid_region_size.
# Size in KiB of each raid or mirror synchronization region.
@@ -1249,7 +1233,6 @@ activation {
# mlock_filter = [ "locale/locale-archive", "gconv/gconv-modules.cache" ]
# This configuration option is advanced.
# This configuration option does not have a default value defined.
- # mlock_filter = [ ]
# Configuration option activation/use_mlockall.
# Use the old behavior of mlockall to pin all memory.
@@ -1370,7 +1353,6 @@ activation {
# dirs = [ "/etc/lvm/metadata", "/mnt/disk2/lvm/metadata2" ]
# This configuration option is advanced.
# This configuration option does not have a default value defined.
- # dirs = [ ]
# }
# Configuration section report.
@@ -1590,6 +1572,5 @@ dmeventd {
# matches an entry in this list, the name of the
# subsection is applied to the machine as a 'host tag'.
# This configuration option does not have a default value defined.
- # host_list = [ ]
# }
# }
diff --git a/conf/lvmlocal.conf.in b/conf/lvmlocal.conf.in
index ec3b081..0e82d5c 100644
--- a/conf/lvmlocal.conf.in
+++ b/conf/lvmlocal.conf.in
@@ -48,5 +48,4 @@ local {
# Use this only after consulting 'man lvmsystemid'
# to be certain of correct usage and possible dangers.
# This configuration option does not have a default value defined.
- # extra_system_ids = [ ]
}
8 years, 10 months
master - refactor: rename _out_tags fn to _out_list and use it for string lists in general
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7b45a1fc60859f...
Commit: 7b45a1fc60859faa4163bde8332ac7c173802640
Parent: f143ad3a9340eb3c90fa37cf912ce163ad107e1a
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed May 6 14:06:44 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jun 29 09:43:55 2015 +0200
refactor: rename _out_tags fn to _out_list and use it for string lists in general
---
lib/format_text/export.c | 23 ++++++++++++-----------
1 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/lib/format_text/export.c b/lib/format_text/export.c
index a1af06b..11766ac 100644
--- a/lib/format_text/export.c
+++ b/lib/format_text/export.c
@@ -414,18 +414,19 @@ bad:
return_NULL;
}
-static int _out_tags(struct formatter *f, struct dm_list *tagsl)
+static int _out_list(struct formatter *f, struct dm_list *list,
+ const char *list_name)
{
- char *tag_buffer;
+ char *buffer;
- if (!dm_list_empty(tagsl)) {
- if (!(tag_buffer = _alloc_printed_str_list(tagsl)))
+ if (!dm_list_empty(list)) {
+ if (!(buffer = _alloc_printed_str_list(list)))
return_0;
- if (!out_text(f, "tags = %s", tag_buffer)) {
- dm_free(tag_buffer);
+ if (!out_text(f, "%s = %s", list_name, buffer)) {
+ dm_free(buffer);
return_0;
}
- dm_free(tag_buffer);
+ dm_free(buffer);
}
return 1;
@@ -463,7 +464,7 @@ static int _print_vg(struct formatter *f, struct volume_group *vg)
if (!_print_flag_config(f, status, VG_FLAGS))
return_0;
- if (!_out_tags(f, &vg->tags))
+ if (!_out_list(f, &vg->tags, "tags"))
return_0;
if (vg->system_id && *vg->system_id)
@@ -550,7 +551,7 @@ static int _print_pvs(struct formatter *f, struct volume_group *vg)
if (!_print_flag_config(f, pv->status, PV_FLAGS))
return_0;
- if (!_out_tags(f, &pv->tags))
+ if (!_out_list(f, &pv->tags, "tags"))
return_0;
outsize(f, pv->size, "dev_size = %" PRIu64, pv->size);
@@ -586,7 +587,7 @@ static int _print_segment(struct formatter *f, struct volume_group *vg,
outnl(f);
outf(f, "type = \"%s\"", seg->segtype->name);
- if (!_out_tags(f, &seg->tags))
+ if (!_out_list(f, &seg->tags, "tags"))
return_0;
if (seg->segtype->ops->text_export &&
@@ -682,7 +683,7 @@ static int _print_lv(struct formatter *f, struct logical_volume *lv)
if (!_print_flag_config(f, status, LV_FLAGS))
return_0;
- if (!_out_tags(f, &lv->tags))
+ if (!_out_list(f, &lv->tags, "tags"))
return_0;
if (lv->timestamp) {
8 years, 10 months
master - cleanup: remove unused tags.c file
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f143ad3a9340eb...
Commit: f143ad3a9340eb3c90fa37cf912ce163ad107e1a
Parent: e29d4773f4de731d8483a12684d5f4b96092088b
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed May 6 13:59:49 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jun 29 09:43:47 2015 +0200
cleanup: remove unused tags.c file
---
lib/Makefile.in | 1 -
lib/format_text/tags.c | 21 ---------------------
2 files changed, 0 insertions(+), 22 deletions(-)
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 4a282eb..ffe18f0 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -82,7 +82,6 @@ SOURCES =\
format_text/format-text.c \
format_text/import.c \
format_text/import_vsn1.c \
- format_text/tags.c \
format_text/text_label.c \
freeseg/freeseg.c \
label/label.c \
diff --git a/lib/format_text/tags.c b/lib/format_text/tags.c
deleted file mode 100644
index e22ca28..0000000
--- a/lib/format_text/tags.c
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2003-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
- *
- * This file is part of LVM2.
- *
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License v.2.1.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "lib.h"
-#include "metadata.h"
-#include "import-export.h"
-#include "str_list.h"
-#include "lvm-string.h"
-
8 years, 10 months
master - refactor: rename alloc_printed_tags fn to _alloc_printed_str_list and use it for string lists in general
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e29d4773f4de73...
Commit: e29d4773f4de731d8483a12684d5f4b96092088b
Parent: 77c2d11657d0b1bdb82e02cbbc6cf025d8b2f43e
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed May 6 13:58:17 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jun 29 09:43:41 2015 +0200
refactor: rename alloc_printed_tags fn to _alloc_printed_str_list and use it for string lists in general
---
lib/format_text/export.c | 43 ++++++++++++++++++++++++++++++++++++++-
lib/format_text/import-export.h | 2 -
lib/format_text/tags.c | 41 -------------------------------------
3 files changed, 42 insertions(+), 44 deletions(-)
diff --git a/lib/format_text/export.c b/lib/format_text/export.c
index 018772e..a1af06b 100644
--- a/lib/format_text/export.c
+++ b/lib/format_text/export.c
@@ -372,13 +372,54 @@ static int _print_flag_config(struct formatter *f, uint64_t status, int type)
return 1;
}
+static char *_alloc_printed_str_list(struct dm_list *list)
+{
+ struct dm_str_list *sl;
+ int first = 1;
+ size_t size = 0;
+ char *buffer, *buf;
+
+ dm_list_iterate_items(sl, list)
+ /* '"' + item + '"' + ',' + ' ' */
+ size += strlen(sl->str) + 4;
+ /* '[' + ']' + '\0' */
+ size += 3;
+
+ if (!(buffer = buf = dm_malloc(size))) {
+ log_error("Could not allocate memory for string list buffer.");
+ return NULL;
+ }
+
+ if (!emit_to_buffer(&buf, &size, "["))
+ goto_bad;
+
+ dm_list_iterate_items(sl, list) {
+ if (!first) {
+ if (!emit_to_buffer(&buf, &size, ", "))
+ goto_bad;
+ } else
+ first = 0;
+
+ if (!emit_to_buffer(&buf, &size, "\"%s\"", sl->str))
+ goto_bad;
+ }
+
+ if (!emit_to_buffer(&buf, &size, "]"))
+ goto_bad;
+
+ return buffer;
+
+bad:
+ dm_free(buffer);
+ return_NULL;
+}
static int _out_tags(struct formatter *f, struct dm_list *tagsl)
{
char *tag_buffer;
if (!dm_list_empty(tagsl)) {
- if (!(tag_buffer = alloc_printed_tags(tagsl)))
+ if (!(tag_buffer = _alloc_printed_str_list(tagsl)))
return_0;
if (!out_text(f, "tags = %s", tag_buffer)) {
dm_free(tag_buffer);
diff --git a/lib/format_text/import-export.h b/lib/format_text/import-export.h
index 18561d3..be88994 100644
--- a/lib/format_text/import-export.h
+++ b/lib/format_text/import-export.h
@@ -61,8 +61,6 @@ struct text_vg_version_ops *text_vg_vsn1_init(void);
int print_flags(uint64_t status, int type, char *buffer, size_t size);
int read_flags(uint64_t *status, int type, const struct dm_config_value *cv);
-char *alloc_printed_tags(struct dm_list *tags);
-
int text_vg_export_file(struct volume_group *vg, const char *desc, FILE *fp);
size_t text_vg_export_raw(struct volume_group *vg, const char *desc, char **buf);
struct volume_group *text_vg_import_file(struct format_instance *fid,
diff --git a/lib/format_text/tags.c b/lib/format_text/tags.c
index c081167..e22ca28 100644
--- a/lib/format_text/tags.c
+++ b/lib/format_text/tags.c
@@ -19,44 +19,3 @@
#include "str_list.h"
#include "lvm-string.h"
-char *alloc_printed_tags(struct dm_list *tagsl)
-{
- struct dm_str_list *sl;
- int first = 1;
- size_t size = 0;
- char *buffer, *buf;
-
- dm_list_iterate_items(sl, tagsl)
- /* '"' + tag + '"' + ',' + ' ' */
- size += strlen(sl->str) + 4;
- /* '[' + ']' + '\0' */
- size += 3;
-
- if (!(buffer = buf = dm_malloc(size))) {
- log_error("Could not allocate memory for tag list buffer.");
- return NULL;
- }
-
- if (!emit_to_buffer(&buf, &size, "["))
- goto_bad;
-
- dm_list_iterate_items(sl, tagsl) {
- if (!first) {
- if (!emit_to_buffer(&buf, &size, ", "))
- goto_bad;
- } else
- first = 0;
-
- if (!emit_to_buffer(&buf, &size, "\"%s\"", sl->str))
- goto_bad;
- }
-
- if (!emit_to_buffer(&buf, &size, "]"))
- goto_bad;
-
- return buffer;
-
-bad:
- dm_free(buffer);
- return_NULL;
-}
8 years, 10 months
master - refactor: rename read_tags fn to _read_str_list and use it for string lists in general
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=77c2d11657d0b1...
Commit: 77c2d11657d0b1bdb82e02cbbc6cf025d8b2f43e
Parent: 02767c5eb1f9e4a15c5f5134903c292ea499213d
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed May 6 13:19:21 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jun 29 09:43:32 2015 +0200
refactor: rename read_tags fn to _read_str_list and use it for string lists in general
---
lib/format_text/import-export.h | 1 -
lib/format_text/import_vsn1.c | 29 +++++++++++++++++++++++++----
lib/format_text/tags.c | 20 --------------------
3 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/lib/format_text/import-export.h b/lib/format_text/import-export.h
index f60496f..18561d3 100644
--- a/lib/format_text/import-export.h
+++ b/lib/format_text/import-export.h
@@ -62,7 +62,6 @@ int print_flags(uint64_t status, int type, char *buffer, size_t size);
int read_flags(uint64_t *status, int type, const struct dm_config_value *cv);
char *alloc_printed_tags(struct dm_list *tags);
-int read_tags(struct dm_pool *mem, struct dm_list *tags, const struct dm_config_value *cv);
int text_vg_export_file(struct volume_group *vg, const char *desc, FILE *fp);
size_t text_vg_export_raw(struct volume_group *vg, const char *desc, char **buf);
diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c
index 048c8fe..931aff8 100644
--- a/lib/format_text/import_vsn1.c
+++ b/lib/format_text/import_vsn1.c
@@ -25,6 +25,7 @@
#include "segtype.h"
#include "text_import.h"
#include "defaults.h"
+#include "str_list.h"
typedef int (*section_fn) (struct format_instance * fid,
struct volume_group * vg, const struct dm_config_node * pvn,
@@ -153,6 +154,26 @@ static int _read_flag_config(const struct dm_config_node *n, uint64_t *status, i
return 1;
}
+static int _read_str_list(struct dm_pool *mem, struct dm_list *list, const struct dm_config_value *cv)
+{
+ if (cv->type == DM_CFG_EMPTY_ARRAY)
+ return 1;
+
+ while (cv) {
+ if (cv->type != DM_CFG_STRING) {
+ log_error("Found an item that is not a string");
+ return 0;
+ }
+
+ if (!str_list_add(mem, list, dm_pool_strdup(mem, cv->v.str)))
+ return_0;
+
+ cv = cv->next;
+ }
+
+ return 1;
+}
+
static int _read_pv(struct format_instance *fid,
struct volume_group *vg, const struct dm_config_node *pvn,
const struct dm_config_node *vgn __attribute__((unused)),
@@ -269,7 +290,7 @@ static int _read_pv(struct format_instance *fid,
/* Optional tags */
if (dm_config_get_list(pvn, "tags", &cv) &&
- !(read_tags(mem, &pv->tags, cv))) {
+ !(_read_str_list(mem, &pv->tags, cv))) {
log_error("Couldn't read tags for physical volume %s in %s.",
pv_dev_name(pv), vg->name);
return 0;
@@ -380,7 +401,7 @@ static int _read_segment(struct logical_volume *lv, const struct dm_config_node
/* Optional tags */
if (dm_config_get_list(sn_child, "tags", &cv) &&
- !(read_tags(mem, &seg->tags, cv))) {
+ !(_read_str_list(mem, &seg->tags, cv))) {
log_error("Couldn't read tags for a segment of %s/%s.",
lv->vg->name, lv->name);
return 0;
@@ -616,7 +637,7 @@ static int _read_lvnames(struct format_instance *fid __attribute__((unused)),
/* Optional tags */
if (dm_config_get_list(lvn, "tags", &cv) &&
- !(read_tags(mem, &lv->tags, cv))) {
+ !(_read_str_list(mem, &lv->tags, cv))) {
log_error("Couldn't read tags for logical volume %s/%s.",
vg->name, lv->name);
return 0;
@@ -891,7 +912,7 @@ static struct volume_group *_read_vg(struct format_instance *fid,
/* Optional tags */
if (dm_config_get_list(vgn, "tags", &cv) &&
- !(read_tags(vg->vgmem, &vg->tags, cv))) {
+ !(_read_str_list(vg->vgmem, &vg->tags, cv))) {
log_error("Couldn't read tags for volume group %s.", vg->name);
goto bad;
}
diff --git a/lib/format_text/tags.c b/lib/format_text/tags.c
index dc138d1..c081167 100644
--- a/lib/format_text/tags.c
+++ b/lib/format_text/tags.c
@@ -60,23 +60,3 @@ bad:
dm_free(buffer);
return_NULL;
}
-
-int read_tags(struct dm_pool *mem, struct dm_list *tagsl, const struct dm_config_value *cv)
-{
- if (cv->type == DM_CFG_EMPTY_ARRAY)
- return 1;
-
- while (cv) {
- if (cv->type != DM_CFG_STRING) {
- log_error("Found a tag that is not a string");
- return 0;
- }
-
- if (!str_list_add(mem, tagsl, dm_pool_strdup(mem, cv->v.str)))
- return_0;
-
- cv = cv->next;
- }
-
- return 1;
-}
8 years, 10 months
master - tests: tests needs pre 1.13 thin-pool extorg
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=02767c5eb1f9e4...
Commit: 02767c5eb1f9e4a15c5f5134903c292ea499213d
Parent: 03c4fee5a7afeeae0b3c215779d24b5faaa1ac26
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jun 26 22:16:01 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Jun 26 22:16:01 2015 +0200
tests: tests needs pre 1.13 thin-pool extorg
This test is testing older style, so disable feature when present.
---
test/shell/lvcreate-thin-external.sh | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/test/shell/lvcreate-thin-external.sh b/test/shell/lvcreate-thin-external.sh
index 9e907a6..8507836 100644
--- a/test/shell/lvcreate-thin-external.sh
+++ b/test/shell/lvcreate-thin-external.sh
@@ -30,6 +30,10 @@ aux prepare_pvs 2 64
vgcreate $vg -s 64K $(cat DEVICES)
+# Newer thin-pool target (>= 1.13) supports unaligned external origin
+# But this test is written to test and expect older behavior
+aux lvmconf 'global/thin_disabled_features = [ "external_origin_extend" ]'
+
# Test validation for external origin being multiple of thin pool chunk size
lvcreate -L10M -T $vg/pool192 -c 192k
lvcreate -an -pr -Zn -l1 -n $lv1 $vg
8 years, 10 months