[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[PATCH] Log all calls to mount to /tmp/program.log as well.
- From: Chris Lumens <clumens redhat com>
- To: anaconda-devel-list redhat com
- Cc:
- Subject: [PATCH] Log all calls to mount to /tmp/program.log as well.
- Date: Tue, 6 Jan 2009 16:14:33 -0500
---
isys/imount.c | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/isys/imount.c b/isys/imount.c
index f44ed4b..e102206 100644
--- a/isys/imount.c
+++ b/isys/imount.c
@@ -71,6 +71,7 @@ static int readFD(int fd, char **buf) {
int doPwMount(char *dev, char *where, char *fs, char *options, char **err) {
int rc, child, status, pipefd[2];
char *opts = NULL, *device;
+ int programLogFD;
if (mkdirChain(where))
return IMOUNT_ERR_ERRNO;
@@ -104,6 +105,8 @@ int doPwMount(char *dev, char *where, char *fs, char *options, char **err) {
opts = strdup(options);
}
+ programLogFD = open("/tmp/program.log", O_APPEND|O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
+
if (pipe(pipefd))
return IMOUNT_ERR_ERRNO;
@@ -112,18 +115,17 @@ int doPwMount(char *dev, char *where, char *fs, char *options, char **err) {
close(pipefd[0]);
- /* Close stdin entirely, redirect stdout to tty5, and redirect stderr
- * to a pipe so we can put error messages into exceptions. We'll
- * only use these messages should mount also return an error code.
+ /* Close stdin entirely, redirect stdout to /tmp/program.log, and
+ * redirect stderr to a pipe so we can put error messages into exceptions.
+ * We'll only use these messages should mount also return an error code.
*/
fd = open("/dev/tty5", O_RDONLY);
close(STDIN_FILENO);
dup2(fd, STDIN_FILENO);
close(fd);
- fd = open("/dev/tty5", O_WRONLY);
close(STDOUT_FILENO);
- dup2(fd, STDOUT_FILENO);
+ dup2(programLogFD, STDOUT_FILENO);
dup2(pipefd[1], STDERR_FILENO);
@@ -144,12 +146,16 @@ int doPwMount(char *dev, char *where, char *fs, char *options, char **err) {
close(pipefd[1]);
- if (err != NULL)
+ if (err != NULL) {
rc = readFD(pipefd[0], err);
+ rc = write(programLogFD, err, 4096);
+ }
close(pipefd[0]);
waitpid(child, &status, 0);
+ close(programLogFD);
+
free(opts);
free(device);
if (!WIFEXITED(status) || (WIFEXITED(status) && WEXITSTATUS(status)))
--
1.6.0.3
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]