* grub-core/osdep/unix/exec.c (grub_util_exec_redirect): Remove

references to mdadm from otherwise generic code.
(grub_util_exec_pipe): Likewise.
(grub_util_exec_pipe_stderr): Likewise.
* grub-core/osdep/unix/getroot.c (grub_util_pull_lvm_by_command):
This function calls vgs, not mdadm; adjust variable names
accordingly.
This commit is contained in:
Colin Watson 2013-11-27 11:22:31 +00:00
parent cf8c80ff77
commit 16ef26fd3a
3 changed files with 45 additions and 35 deletions

View file

@ -1,3 +1,13 @@
2013-11-27 Colin Watson <cjwatson@ubuntu.com>
* grub-core/osdep/unix/exec.c (grub_util_exec_redirect): Remove
references to mdadm from otherwise generic code.
(grub_util_exec_pipe): Likewise.
(grub_util_exec_pipe_stderr): Likewise.
* grub-core/osdep/unix/getroot.c (grub_util_pull_lvm_by_command):
This function calls vgs, not mdadm; adjust variable names
accordingly.
2013-11-27 Colin Watson <cjwatson@ubuntu.com>
Generate Makefile.*.am directly from gentpl.py, eliminating the use

View file

@ -86,7 +86,7 @@ int
grub_util_exec_redirect (const char *const *argv, const char *stdin_file,
const char *stdout_file)
{
pid_t mdadm_pid;
pid_t pid;
int status = -1;
char *str, *pstr;
const char *const *ptr;
@ -112,10 +112,10 @@ grub_util_exec_redirect (const char *const *argv, const char *stdin_file,
grub_util_info ("executing %s", str);
grub_free (str);
mdadm_pid = fork ();
if (mdadm_pid < 0)
pid = fork ();
if (pid < 0)
grub_util_error (_("Unable to fork: %s"), strerror (errno));
else if (mdadm_pid == 0)
else if (pid == 0)
{
int in, out;
/* Child. */
@ -145,7 +145,7 @@ grub_util_exec_redirect (const char *const *argv, const char *stdin_file,
execvp ((char *) argv[0], (char **) argv);
exit (127);
}
waitpid (mdadm_pid, &status, 0);
waitpid (pid, &status, 0);
if (!WIFEXITED (status))
return -1;
return WEXITSTATUS (status);
@ -160,21 +160,21 @@ grub_util_exec_redirect_null (const char *const *argv)
pid_t
grub_util_exec_pipe (const char *const *argv, int *fd)
{
int mdadm_pipe[2];
pid_t mdadm_pid;
int pipe_fd[2];
pid_t pid;
*fd = 0;
if (pipe (mdadm_pipe) < 0)
if (pipe (pipe_fd) < 0)
{
grub_util_warn (_("Unable to create pipe: %s"),
strerror (errno));
return 0;
}
mdadm_pid = fork ();
if (mdadm_pid < 0)
pid = fork ();
if (pid < 0)
grub_util_error (_("Unable to fork: %s"), strerror (errno));
else if (mdadm_pid == 0)
else if (pid == 0)
{
/* Child. */
@ -187,39 +187,39 @@ grub_util_exec_pipe (const char *const *argv, int *fd)
/* Ensure child is not localised. */
setenv ("LC_ALL", "C", 1);
close (mdadm_pipe[0]);
dup2 (mdadm_pipe[1], STDOUT_FILENO);
close (mdadm_pipe[1]);
close (pipe_fd[0]);
dup2 (pipe_fd[1], STDOUT_FILENO);
close (pipe_fd[1]);
execvp ((char *) argv[0], (char **) argv);
exit (127);
}
else
{
close (mdadm_pipe[1]);
*fd = mdadm_pipe[0];
return mdadm_pid;
close (pipe_fd[1]);
*fd = pipe_fd[0];
return pid;
}
}
pid_t
grub_util_exec_pipe_stderr (const char *const *argv, int *fd)
{
int mdadm_pipe[2];
pid_t mdadm_pid;
int pipe_fd[2];
pid_t pid;
*fd = 0;
if (pipe (mdadm_pipe) < 0)
if (pipe (pipe_fd) < 0)
{
grub_util_warn (_("Unable to create pipe: %s"),
strerror (errno));
return 0;
}
mdadm_pid = fork ();
if (mdadm_pid < 0)
pid = fork ();
if (pid < 0)
grub_util_error (_("Unable to fork: %s"), strerror (errno));
else if (mdadm_pid == 0)
else if (pid == 0)
{
/* Child. */
@ -232,18 +232,18 @@ grub_util_exec_pipe_stderr (const char *const *argv, int *fd)
/* Ensure child is not localised. */
setenv ("LC_ALL", "C", 1);
close (mdadm_pipe[0]);
dup2 (mdadm_pipe[1], STDOUT_FILENO);
dup2 (mdadm_pipe[1], STDERR_FILENO);
close (mdadm_pipe[1]);
close (pipe_fd[0]);
dup2 (pipe_fd[1], STDOUT_FILENO);
dup2 (pipe_fd[1], STDERR_FILENO);
close (pipe_fd[1]);
execvp ((char *) argv[0], (char **) argv);
exit (127);
}
else
{
close (mdadm_pipe[1]);
*fd = mdadm_pipe[0];
return mdadm_pid;
close (pipe_fd[1]);
*fd = pipe_fd[0];
return pid;
}
}

View file

@ -567,7 +567,7 @@ grub_util_pull_lvm_by_command (const char *os_dev)
const char *argv[8];
int fd;
pid_t pid;
FILE *mdadm;
FILE *vgs;
char *buf = NULL;
size_t len = 0;
char *vgname = NULL;
@ -622,16 +622,16 @@ grub_util_pull_lvm_by_command (const char *os_dev)
if (!pid)
return;
/* Parent. Read mdadm's output. */
mdadm = fdopen (fd, "r");
if (! mdadm)
/* Parent. Read vgs' output. */
vgs = fdopen (fd, "r");
if (! vgs)
{
grub_util_warn (_("Unable to open stream from %s: %s"),
"vgs", strerror (errno));
goto out;
}
while (getline (&buf, &len, mdadm) > 0)
while (getline (&buf, &len, vgs) > 0)
{
char *ptr;
/* LVM adds two spaces as standard prefix */