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

buffering: use unbuffered silent mode for liblvm

Disable private buffering when using liblvm.
When private stdin/stdout buffering is not used always use silent
mode.
This commit is contained in:
Alasdair G Kergon 2012-08-26 00:15:45 +01:00
parent 438e0050df
commit 3acc85caa8
6 changed files with 23 additions and 5 deletions

View File

@ -1,5 +1,7 @@
Version 2.02.98 -
=================================
Disable private buffering when using liblvm.
When private stdin/stdout buffering is not used always use silent mode.
Add log/silent to lvm.conf equivalent to -qq.
Suppress non-essential stdout with -qq.
Switch non-essential log_print messages to log_print_unless_silent.

View File

@ -241,6 +241,8 @@ log {
# pvs, version, vgcfgrestore -l, vgdisplay, vgs.
# Non-essential messages are shifted from log level 4 to log level 5
# for syslog and lvm2_log_fn purposes.
# Any 'yes' or 'no' questions not overridden by other arguments
# are suppressed and default to 'no'.
silent = 0
# Should we send log messages through syslog?

View File

@ -144,8 +144,12 @@ static void _init_logging(struct cmd_context *cmd)
find_config_tree_int(cmd, "log/level", DEFAULT_LOGLEVEL);
init_debug(cmd->default_settings.debug);
/* Suppress all non-essential stdout? */
cmd->default_settings.silent =
/*
* Suppress all non-essential stdout?
* -qq can override the default of 0 to 1 later.
* Once set to 1, there is no facility to change it back to 0.
*/
cmd->default_settings.silent = silent_mode() ? :
find_config_tree_int(cmd, "log/silent", DEFAULT_SILENT);
init_silent(cmd->default_settings.silent);
@ -1296,7 +1300,9 @@ struct cmd_context *create_toolcontext(unsigned is_long_lived,
goto out;
}
/* Buffers are used for lines without '\n' */
}
} else
/* Without buffering, must not use stdin/stdout */
init_silent(1);
/*
* Environment variable LVM_SYSTEM_DIR overrides this below.

View File

@ -902,11 +902,19 @@ void display_segtypes(const struct cmd_context *cmd)
}
}
/*
* Prompt for y or n from stdin.
* Defaults to 'no' in silent mode.
* All callers should support --yes and/or --force to override this.
*/
char yes_no_prompt(const char *prompt, ...)
{
int c = 0, ret = 0;
va_list ap;
if (silent_mode())
return 'n';
sigint_allow();
do {
if (c == '\n' || !c) {
@ -939,4 +947,3 @@ char yes_no_prompt(const char *prompt, ...)
return ret;
}

View File

@ -2741,6 +2741,7 @@ int lv_extend(struct logical_volume *lv,
log_error("%s/%s is not active."
" Unable to get sync percent.",
lv->vg->name, lv->name);
/* FIXME Support --force */
if (yes_no_prompt("Do full resync of extended "
"portion of %s/%s? [y/n]: ",
lv->vg->name, lv->name) == 'y')

View File

@ -37,7 +37,7 @@ lvm_t lvm_init(const char *system_dir)
/* create context */
/* FIXME: split create_toolcontext */
/* FIXME: make all globals configurable */
cmd = create_toolcontext(0, system_dir, 1, 0);
cmd = create_toolcontext(0, system_dir, 0, 0);
if (!cmd)
return NULL;