From 16ef26fd3a17e6a3f7dad444a77e81cd741a398e Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 27 Nov 2013 11:22:31 +0000 Subject: [PATCH] * 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. --- ChangeLog | 10 ++++++ grub-core/osdep/unix/exec.c | 60 +++++++++++++++++----------------- grub-core/osdep/unix/getroot.c | 10 +++--- 3 files changed, 45 insertions(+), 35 deletions(-) diff --git a/ChangeLog b/ChangeLog index 630bfa9cd..fe5c2c605 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2013-11-27 Colin Watson + + * 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 Generate Makefile.*.am directly from gentpl.py, eliminating the use diff --git a/grub-core/osdep/unix/exec.c b/grub-core/osdep/unix/exec.c index 9a50e5b9f..d4865f617 100644 --- a/grub-core/osdep/unix/exec.c +++ b/grub-core/osdep/unix/exec.c @@ -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; } } diff --git a/grub-core/osdep/unix/getroot.c b/grub-core/osdep/unix/getroot.c index 25234108c..260465844 100644 --- a/grub-core/osdep/unix/getroot.c +++ b/grub-core/osdep/unix/getroot.c @@ -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 */