mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Attempt cleanup in child before execing new binary in exec_cmd()
This commit is contained in:
parent
8a4e6cac0a
commit
ed82bfd2ba
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.45 - 26th February 2009
|
Version 2.02.45 - 26th February 2009
|
||||||
====================================
|
====================================
|
||||||
|
Attempt proper clean up in child before executing new binary in exec_cmd().
|
||||||
Do not scan devices if reporting only attributes from PV label.
|
Do not scan devices if reporting only attributes from PV label.
|
||||||
Use pkgconfig to obtain corosync library details during configuration.
|
Use pkgconfig to obtain corosync library details during configuration.
|
||||||
Fix error returns in clvmd-corosync interface to DLM.
|
Fix error returns in clvmd-corosync interface to DLM.
|
||||||
|
@ -141,7 +141,8 @@ int target_version(const char *target_name, uint32_t *maj,
|
|||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int target_present(const char *target_name, int use_modprobe)
|
int target_present(struct cmd_context *cmd, const char *target_name,
|
||||||
|
int use_modprobe)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -391,7 +392,7 @@ int target_version(const char *target_name, uint32_t *maj,
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
int module_present(const char *target_name)
|
int module_present(struct cmd_context *cmd, const char *target_name)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
#ifdef MODPROBE_CMD
|
#ifdef MODPROBE_CMD
|
||||||
@ -408,12 +409,13 @@ int module_present(const char *target_name)
|
|||||||
argv[1] = module;
|
argv[1] = module;
|
||||||
argv[2] = NULL;
|
argv[2] = NULL;
|
||||||
|
|
||||||
ret = exec_cmd(argv);
|
ret = exec_cmd(cmd, argv);
|
||||||
#endif
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int target_present(const char *target_name, int use_modprobe)
|
int target_present(struct cmd_context *cmd, const char *target_name,
|
||||||
|
int use_modprobe)
|
||||||
{
|
{
|
||||||
uint32_t maj, min, patchlevel;
|
uint32_t maj, min, patchlevel;
|
||||||
|
|
||||||
@ -425,7 +427,7 @@ int target_present(const char *target_name, int use_modprobe)
|
|||||||
if (target_version(target_name, &maj, &min, &patchlevel))
|
if (target_version(target_name, &maj, &min, &patchlevel))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (!module_present(target_name))
|
if (!module_present(cmd, target_name))
|
||||||
return_0;
|
return_0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -40,8 +40,9 @@ int driver_version(char *version, size_t size);
|
|||||||
int library_version(char *version, size_t size);
|
int library_version(char *version, size_t size);
|
||||||
int lvm1_present(struct cmd_context *cmd);
|
int lvm1_present(struct cmd_context *cmd);
|
||||||
|
|
||||||
int module_present(const char *target_name);
|
int module_present(struct cmd_context *cmd, const char *target_name);
|
||||||
int target_present(const char *target_name, int use_modprobe);
|
int target_present(struct cmd_context *cmd, const char *target_name,
|
||||||
|
int use_modprobe);
|
||||||
int target_version(const char *target_name, uint32_t *maj,
|
int target_version(const char *target_name, uint32_t *maj,
|
||||||
uint32_t *min, uint32_t *patchlevel);
|
uint32_t *min, uint32_t *patchlevel);
|
||||||
int list_segment_modules(struct dm_pool *mem, const struct lv_segment *seg,
|
int list_segment_modules(struct dm_pool *mem, const struct lv_segment *seg,
|
||||||
|
@ -51,7 +51,7 @@ static int _errseg_add_target_line(struct dev_manager *dm __attribute((unused)),
|
|||||||
return dm_tree_node_add_error_target(node, len);
|
return dm_tree_node_add_error_target(node, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _errseg_target_present(const struct lv_segment *seg __attribute((unused)),
|
static int _errseg_target_present(const struct lv_segment *seg,
|
||||||
unsigned *attributes __attribute((unused)))
|
unsigned *attributes __attribute((unused)))
|
||||||
{
|
{
|
||||||
static int _errseg_checked = 0;
|
static int _errseg_checked = 0;
|
||||||
@ -59,7 +59,8 @@ static int _errseg_target_present(const struct lv_segment *seg __attribute((unus
|
|||||||
|
|
||||||
/* Reported truncated in older kernels */
|
/* Reported truncated in older kernels */
|
||||||
if (!_errseg_checked &&
|
if (!_errseg_checked &&
|
||||||
(target_present("error", 0) || target_present("erro", 0)))
|
(target_present(seg->lv->vg->cmd, "error", 0) ||
|
||||||
|
target_present(seg->lv->vg->cmd, "erro", 0)))
|
||||||
_errseg_present = 1;
|
_errseg_present = 1;
|
||||||
|
|
||||||
_errseg_checked = 1;
|
_errseg_checked = 1;
|
||||||
|
@ -343,7 +343,7 @@ static int _mirrored_add_target_line(struct dev_manager *dm, struct dm_pool *mem
|
|||||||
return add_areas_line(dm, seg, node, start_area, area_count);
|
return add_areas_line(dm, seg, node, start_area, area_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _mirrored_target_present(const struct lv_segment *seg __attribute((unused)),
|
static int _mirrored_target_present(const struct lv_segment *seg,
|
||||||
unsigned *attributes)
|
unsigned *attributes)
|
||||||
{
|
{
|
||||||
static int _mirrored_checked = 0;
|
static int _mirrored_checked = 0;
|
||||||
@ -353,7 +353,7 @@ static int _mirrored_target_present(const struct lv_segment *seg __attribute((un
|
|||||||
char vsn[80];
|
char vsn[80];
|
||||||
|
|
||||||
if (!_mirrored_checked) {
|
if (!_mirrored_checked) {
|
||||||
_mirrored_present = target_present("mirror", 1);
|
_mirrored_present = target_present(seg->lv->vg->cmd, "mirror", 1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* block_on_error available with mirror target >= 1.1 and <= 1.11
|
* block_on_error available with mirror target >= 1.1 and <= 1.11
|
||||||
@ -375,7 +375,8 @@ static int _mirrored_target_present(const struct lv_segment *seg __attribute((un
|
|||||||
* FIXME: Fails incorrectly if cmirror was built into kernel.
|
* FIXME: Fails incorrectly if cmirror was built into kernel.
|
||||||
*/
|
*/
|
||||||
if (attributes) {
|
if (attributes) {
|
||||||
if (!_mirror_attributes && module_present("log-clustered"))
|
if (!_mirror_attributes && module_present(seg->lv->vg->cmd,
|
||||||
|
"log-clustered"))
|
||||||
_mirror_attributes |= MIRROR_LOG_CLUSTERED;
|
_mirror_attributes |= MIRROR_LOG_CLUSTERED;
|
||||||
*attributes = _mirror_attributes;
|
*attributes = _mirror_attributes;
|
||||||
}
|
}
|
||||||
|
@ -14,12 +14,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "lib.h"
|
#include "lib.h"
|
||||||
|
#include "device.h"
|
||||||
|
#include "locking.h"
|
||||||
#include "lvm-exec.h"
|
#include "lvm-exec.h"
|
||||||
|
#include "toolcontext.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create verbose string with list of parameters
|
* Create verbose string with list of parameters
|
||||||
*/
|
*/
|
||||||
@ -44,7 +46,7 @@ static char *_verbose_args(const char *const argv[], char *buf, size_t sz)
|
|||||||
/*
|
/*
|
||||||
* Execute and wait for external command
|
* Execute and wait for external command
|
||||||
*/
|
*/
|
||||||
int exec_cmd(const char *const argv[])
|
int exec_cmd(struct cmd_context *cmd, const char *const argv[])
|
||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int status;
|
int status;
|
||||||
@ -59,6 +61,10 @@ int exec_cmd(const char *const argv[])
|
|||||||
|
|
||||||
if (!pid) {
|
if (!pid) {
|
||||||
/* Child */
|
/* Child */
|
||||||
|
reset_locking();
|
||||||
|
dev_close_all();
|
||||||
|
/* FIXME Fix effect of reset_locking on cache then include this */
|
||||||
|
/* destroy_toolcontext(cmd); */
|
||||||
/* FIXME Use execve directly */
|
/* FIXME Use execve directly */
|
||||||
execvp(argv[0], (char **const) argv);
|
execvp(argv[0], (char **const) argv);
|
||||||
log_sys_error("execvp", argv[0]);
|
log_sys_error("execvp", argv[0]);
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "lib.h"
|
#include "lib.h"
|
||||||
|
|
||||||
int exec_cmd(const char *const argv[]);
|
struct cmd_context;
|
||||||
|
int exec_cmd(struct cmd_context *cmd, const char *const argv[]);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -108,15 +108,15 @@ static int _snap_target_percent(void **target_state __attribute((unused)),
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _snap_target_present(const struct lv_segment *seg __attribute((unused)),
|
static int _snap_target_present(const struct lv_segment *seg,
|
||||||
unsigned *attributes __attribute((unused)))
|
unsigned *attributes __attribute((unused)))
|
||||||
{
|
{
|
||||||
static int _snap_checked = 0;
|
static int _snap_checked = 0;
|
||||||
static int _snap_present = 0;
|
static int _snap_present = 0;
|
||||||
|
|
||||||
if (!_snap_checked)
|
if (!_snap_checked)
|
||||||
_snap_present = target_present("snapshot", 1) &&
|
_snap_present = target_present(seg->lv->vg->cmd, "snapshot", 1) &&
|
||||||
target_present("snapshot-origin", 0);
|
target_present(seg->lv->vg->cmd, "snapshot-origin", 0);
|
||||||
|
|
||||||
_snap_checked = 1;
|
_snap_checked = 1;
|
||||||
|
|
||||||
|
@ -175,15 +175,15 @@ static int _striped_add_target_line(struct dev_manager *dm,
|
|||||||
return add_areas_line(dm, seg, node, 0u, seg->area_count);
|
return add_areas_line(dm, seg, node, 0u, seg->area_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _striped_target_present(const struct lv_segment *seg __attribute((unused)),
|
static int _striped_target_present(const struct lv_segment *seg,
|
||||||
unsigned *attributes __attribute((unused)))
|
unsigned *attributes __attribute((unused)))
|
||||||
{
|
{
|
||||||
static int _striped_checked = 0;
|
static int _striped_checked = 0;
|
||||||
static int _striped_present = 0;
|
static int _striped_present = 0;
|
||||||
|
|
||||||
if (!_striped_checked)
|
if (!_striped_checked)
|
||||||
_striped_present = target_present("linear", 0) &&
|
_striped_present = target_present(seg->lv->vg->cmd, "linear", 0) &&
|
||||||
target_present("striped", 0);
|
target_present(seg->lv->vg->cmd, "striped", 0);
|
||||||
|
|
||||||
_striped_checked = 1;
|
_striped_checked = 1;
|
||||||
|
|
||||||
|
@ -50,14 +50,14 @@ static int _zero_add_target_line(struct dev_manager *dm __attribute((unused)),
|
|||||||
return dm_tree_node_add_zero_target(node, len);
|
return dm_tree_node_add_zero_target(node, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _zero_target_present(const struct lv_segment *seg __attribute((unused)),
|
static int _zero_target_present(const struct lv_segment *seg,
|
||||||
unsigned *attributes __attribute((unused)))
|
unsigned *attributes __attribute((unused)))
|
||||||
{
|
{
|
||||||
static int _zero_checked = 0;
|
static int _zero_checked = 0;
|
||||||
static int _zero_present = 0;
|
static int _zero_present = 0;
|
||||||
|
|
||||||
if (!_zero_checked)
|
if (!_zero_checked)
|
||||||
_zero_present = target_present("zero", 0);
|
_zero_present = target_present(seg->lv->vg->cmd, "zero", 0);
|
||||||
|
|
||||||
_zero_checked = 1;
|
_zero_checked = 1;
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ enum fsadm_cmd_e { FSADM_CMD_CHECK, FSADM_CMD_RESIZE };
|
|||||||
* FSADM_CMD --dry-run --verbose --force check lv_path
|
* FSADM_CMD --dry-run --verbose --force check lv_path
|
||||||
* FSADM_CMD --dry-run --verbose --force resize lv_path size
|
* FSADM_CMD --dry-run --verbose --force resize lv_path size
|
||||||
*/
|
*/
|
||||||
static int _fsadm_cmd(const struct cmd_context *cmd,
|
static int _fsadm_cmd(struct cmd_context *cmd,
|
||||||
const struct volume_group *vg,
|
const struct volume_group *vg,
|
||||||
const struct lvresize_params *lp,
|
const struct lvresize_params *lp,
|
||||||
enum fsadm_cmd_e fcmd)
|
enum fsadm_cmd_e fcmd)
|
||||||
@ -181,7 +181,7 @@ static int _fsadm_cmd(const struct cmd_context *cmd,
|
|||||||
|
|
||||||
argv[i] = NULL;
|
argv[i] = NULL;
|
||||||
|
|
||||||
return exec_cmd(argv);
|
return exec_cmd(cmd, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _lvresize_params(struct cmd_context *cmd, int argc, char **argv,
|
static int _lvresize_params(struct cmd_context *cmd, int argc, char **argv,
|
||||||
@ -579,7 +579,7 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
|
|||||||
if ((lp->resizefs || (lp->resize == LV_REDUCE)) &&
|
if ((lp->resizefs || (lp->resize == LV_REDUCE)) &&
|
||||||
!_request_confirmation(cmd, vg, lv, lp)) {
|
!_request_confirmation(cmd, vg, lv, lp)) {
|
||||||
stack;
|
stack;
|
||||||
return ECMD_FAILED;
|
// return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lp->resizefs) {
|
if (lp->resizefs) {
|
||||||
|
Loading…
Reference in New Issue
Block a user