+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
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;
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. */
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);
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. */
/* 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. */
/* 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;
}
}
const char *argv[8];
int fd;
pid_t pid;
- FILE *mdadm;
+ FILE *vgs;
char *buf = NULL;
size_t len = 0;
char *vgname = NULL;
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 */