diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2011-01-13 14:51:32 +0000 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2011-01-13 14:51:32 +0000 |
commit | b1b38215ba6d9c45f2db4bbfc707064831b36c91 (patch) | |
tree | 55d25c16b3d7047692033f927577e973ee7b2608 /lib/misc/lvm-exec.c | |
parent | c6e087d54ae132416f3c6b945b178abc1b0284ac (diff) | |
download | lvm2-b1b38215ba6d9c45f2db4bbfc707064831b36c91.tar.gz lvm2-b1b38215ba6d9c45f2db4bbfc707064831b36c91.tar.xz lvm2-b1b38215ba6d9c45f2db4bbfc707064831b36c91.zip |
Add exec_cmd paramater sync_needed
As sync_local_dev_names() cannot be called within activation context,
add new parametr which allows to select if the sync call is needed
before executing new command.
Diffstat (limited to 'lib/misc/lvm-exec.c')
-rw-r--r-- | lib/misc/lvm-exec.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/misc/lvm-exec.c b/lib/misc/lvm-exec.c index 79291259..775b801f 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. * @@ -47,7 +47,8 @@ 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; @@ -55,7 +56,12 @@ int exec_cmd(struct cmd_context *cmd, const char *const argv[], int *rstatus) log_verbose("Executing: %s", _verbose_args(argv, buf, sizeof(buf))); - sync_local_dev_names(cmd); /* Flush ops and reset dm cookie */ + if (rstatus) + *rstatus = -1; + + if (sync_needed) + if (!sync_local_dev_names(cmd)) /* Flush ops and reset dm cookie */ + return_0; if ((pid = fork()) == -1) { log_error("fork failed: %s", strerror(errno)); @@ -74,9 +80,6 @@ int exec_cmd(struct cmd_context *cmd, const char *const argv[], int *rstatus) _exit(errno); } - if (rstatus) - *rstatus = -1; - /* Parent */ if (wait4(pid, &status, 0, NULL) != pid) { log_error("wait4 child process %u failed: %s", pid, |