1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

metadata: use outfc for comments

Few unecessary comments were written to on-disc metadata.
Use outfc() to have comments only in archived files.
(may also save couple bytes in ringbuffer).

TODO: needed validation against newline char...
This commit is contained in:
Zdenek Kabelac 2014-07-16 23:57:43 +02:00
parent f5d6c4b0f3
commit cac0722cac
2 changed files with 8 additions and 6 deletions

View File

@ -329,6 +329,7 @@ static int _print_header(struct formatter *f,
{ {
char *buf; char *buf;
time_t t; time_t t;
char com[PATH_MAX];
t = time(NULL); t = time(NULL);
@ -344,9 +345,10 @@ static int _print_header(struct formatter *f,
} }
outf(f, "description = \"%s\"", dm_escape_double_quotes(buf, desc)); outf(f, "description = \"%s\"", dm_escape_double_quotes(buf, desc));
outnl(f); outnl(f);
outf(f, "creation_host = \"%s\"\t# %s %s %s %s %s", _utsname.nodename, (void) dm_snprintf(com, sizeof(com), "# %s %s %s %s %s",
_utsname.sysname, _utsname.nodename, _utsname.release, _utsname.sysname, _utsname.nodename, _utsname.release,
_utsname.version, _utsname.machine); _utsname.version, _utsname.machine);
outfc(f, com, "creation_host = \"%s\"", _utsname.nodename);
outf(f, "creation_time = %lu\t# %s", t, ctime(&t)); outf(f, "creation_time = %lu\t# %s", t, ctime(&t));
return 1; return 1;
@ -396,7 +398,7 @@ static int _print_vg(struct formatter *f, struct volume_group *vg)
outf(f, "seqno = %u", vg->seqno); outf(f, "seqno = %u", vg->seqno);
if (vg->fid && vg->fid->fmt) if (vg->fid && vg->fid->fmt)
outf(f, "format = \"%s\" # informational", vg->fid->fmt->name); outfc(f, "# informational", "format = \"%s\"", vg->fid->fmt->name);
if (!_print_flag_config(f, vg->status, VG_FLAGS)) if (!_print_flag_config(f, vg->status, VG_FLAGS))
return_0; return_0;

View File

@ -94,8 +94,8 @@ static int _striped_text_import(struct lv_segment *seg, const struct dm_config_n
static int _striped_text_export(const struct lv_segment *seg, struct formatter *f) static int _striped_text_export(const struct lv_segment *seg, struct formatter *f)
{ {
outf(f, "stripe_count = %u%s", seg->area_count, outfc(f, (seg->area_count == 1) ? "# linear" : NULL,
(seg->area_count == 1) ? "\t# linear" : ""); "stripe_count = %u", seg->area_count);
if (seg->area_count > 1) if (seg->area_count > 1)
outsize(f, (uint64_t) seg->stripe_size, outsize(f, (uint64_t) seg->stripe_size,