* 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> 2013-11-27 Colin Watson <cjwatson@ubuntu.com>
Generate Makefile.*.am directly from gentpl.py, eliminating the use 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, grub_util_exec_redirect (const char *const *argv, const char *stdin_file,
const char *stdout_file) const char *stdout_file)
{ {
pid_t mdadm_pid; pid_t pid;
int status = -1; int status = -1;
char *str, *pstr; char *str, *pstr;
const char *const *ptr; 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_util_info ("executing %s", str);
grub_free (str); grub_free (str);
mdadm_pid = fork (); pid = fork ();
if (mdadm_pid < 0) if (pid < 0)
grub_util_error (_("Unable to fork: %s"), strerror (errno)); grub_util_error (_("Unable to fork: %s"), strerror (errno));
else if (mdadm_pid == 0) else if (pid == 0)
{ {
int in, out; int in, out;
/* Child. */ /* Child. */
@ -145,7 +145,7 @@ grub_util_exec_redirect (const char *const *argv, const char *stdin_file,
execvp ((char *) argv[0], (char **) argv); execvp ((char *) argv[0], (char **) argv);
exit (127); exit (127);
} }
waitpid (mdadm_pid, &status, 0); waitpid (pid, &status, 0);
if (!WIFEXITED (status)) if (!WIFEXITED (status))
return -1; return -1;
return WEXITSTATUS (status); return WEXITSTATUS (status);
@ -160,21 +160,21 @@ grub_util_exec_redirect_null (const char *const *argv)
pid_t pid_t
grub_util_exec_pipe (const char *const *argv, int *fd) grub_util_exec_pipe (const char *const *argv, int *fd)
{ {
int mdadm_pipe[2]; int pipe_fd[2];
pid_t mdadm_pid; pid_t pid;
*fd = 0; *fd = 0;
if (pipe (mdadm_pipe) < 0) if (pipe (pipe_fd) < 0)
{ {
grub_util_warn (_("Unable to create pipe: %s"), grub_util_warn (_("Unable to create pipe: %s"),
strerror (errno)); strerror (errno));
return 0; return 0;
} }
mdadm_pid = fork (); pid = fork ();
if (mdadm_pid < 0) if (pid < 0)
grub_util_error (_("Unable to fork: %s"), strerror (errno)); grub_util_error (_("Unable to fork: %s"), strerror (errno));
else if (mdadm_pid == 0) else if (pid == 0)
{ {
/* Child. */ /* Child. */
@ -187,39 +187,39 @@ grub_util_exec_pipe (const char *const *argv, int *fd)
/* Ensure child is not localised. */ /* Ensure child is not localised. */
setenv ("LC_ALL", "C", 1); setenv ("LC_ALL", "C", 1);
close (mdadm_pipe[0]); close (pipe_fd[0]);
dup2 (mdadm_pipe[1], STDOUT_FILENO); dup2 (pipe_fd[1], STDOUT_FILENO);
close (mdadm_pipe[1]); close (pipe_fd[1]);
execvp ((char *) argv[0], (char **) argv); execvp ((char *) argv[0], (char **) argv);
exit (127); exit (127);
} }
else else
{ {
close (mdadm_pipe[1]); close (pipe_fd[1]);
*fd = mdadm_pipe[0]; *fd = pipe_fd[0];
return mdadm_pid; return pid;
} }
} }
pid_t pid_t
grub_util_exec_pipe_stderr (const char *const *argv, int *fd) grub_util_exec_pipe_stderr (const char *const *argv, int *fd)
{ {
int mdadm_pipe[2]; int pipe_fd[2];
pid_t mdadm_pid; pid_t pid;
*fd = 0; *fd = 0;
if (pipe (mdadm_pipe) < 0) if (pipe (pipe_fd) < 0)
{ {
grub_util_warn (_("Unable to create pipe: %s"), grub_util_warn (_("Unable to create pipe: %s"),
strerror (errno)); strerror (errno));
return 0; return 0;
} }
mdadm_pid = fork (); pid = fork ();
if (mdadm_pid < 0) if (pid < 0)
grub_util_error (_("Unable to fork: %s"), strerror (errno)); grub_util_error (_("Unable to fork: %s"), strerror (errno));
else if (mdadm_pid == 0) else if (pid == 0)
{ {
/* Child. */ /* Child. */
@ -232,18 +232,18 @@ grub_util_exec_pipe_stderr (const char *const *argv, int *fd)
/* Ensure child is not localised. */ /* Ensure child is not localised. */
setenv ("LC_ALL", "C", 1); setenv ("LC_ALL", "C", 1);
close (mdadm_pipe[0]); close (pipe_fd[0]);
dup2 (mdadm_pipe[1], STDOUT_FILENO); dup2 (pipe_fd[1], STDOUT_FILENO);
dup2 (mdadm_pipe[1], STDERR_FILENO); dup2 (pipe_fd[1], STDERR_FILENO);
close (mdadm_pipe[1]); close (pipe_fd[1]);
execvp ((char *) argv[0], (char **) argv); execvp ((char *) argv[0], (char **) argv);
exit (127); exit (127);
} }
else else
{ {
close (mdadm_pipe[1]); close (pipe_fd[1]);
*fd = mdadm_pipe[0]; *fd = pipe_fd[0];
return mdadm_pid; return pid;
} }
} }

View file

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