diff options
Diffstat (limited to 'lib/misc/lvm-exec.c')
-rw-r--r-- | lib/misc/lvm-exec.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/misc/lvm-exec.c b/lib/misc/lvm-exec.c index 5cad79e..4b74a41 100644 --- a/lib/misc/lvm-exec.c +++ b/lib/misc/lvm-exec.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -18,6 +18,7 @@ #include "locking.h" #include "lvm-exec.h" #include "toolcontext.h" +#include "activate.h" #include <unistd.h> #include <sys/wait.h> @@ -34,7 +35,7 @@ static char *_verbose_args(const char *const argv[], char *buf, size_t sz) buf[0] = '\0'; for (i = 0; argv[i]; i++) { if ((len = dm_snprintf(buf + pos, sz - pos, - "%s ", argv[i])) < 0) + " %s", argv[i])) < 0) /* Truncated */ break; pos += len; @@ -46,13 +47,22 @@ static char *_verbose_args(const char *const argv[], char *buf, size_t sz) /* * Execute and wait for external command */ -int exec_cmd(struct cmd_context *cmd, const char *const argv[], int *rstatus) +int exec_cmd(struct cmd_context *cmd, const char *const argv[], + int *rstatus, int sync_needed) { pid_t pid; int status; char buf[PATH_MAX * 2]; - log_verbose("Executing: %s", _verbose_args(argv, buf, sizeof(buf))); + + if (rstatus) + *rstatus = -1; + + if (sync_needed) + if (!sync_local_dev_names(cmd)) /* Flush ops and reset dm cookie */ + return_0; + + log_verbose("Executing:%s", _verbose_args(argv, buf, sizeof(buf))); if ((pid = fork()) == -1) { log_error("fork failed: %s", strerror(errno)); @@ -66,14 +76,11 @@ int exec_cmd(struct cmd_context *cmd, const char *const argv[], int *rstatus) /* FIXME Fix effect of reset_locking on cache then include this */ /* destroy_toolcontext(cmd); */ /* FIXME Use execve directly */ - execvp(argv[0], (char **const) argv); + execvp(argv[0], (char **) argv); log_sys_error("execvp", argv[0]); _exit(errno); } - if (rstatus) - *rstatus = -1; - /* Parent */ if (wait4(pid, &status, 0, NULL) != pid) { log_error("wait4 child process %u failed: %s", pid, |