diff options
| author | Ray Strode <rstrode@redhat.com> | 2007-05-23 17:11:18 -0400 |
|---|---|---|
| committer | Ray Strode <rstrode@redhat.com> | 2007-05-23 17:11:18 -0400 |
| commit | 6949c46ea26884d27b650af54d07ed46828b84dc (patch) | |
| tree | 8431659e103d301274d84fc83c0992f4aa0b70ed /src | |
| parent | 7724425f221595de96fd2063c603db098e9cafb0 (diff) | |
mount /proc and /dev/pts if they aren't mounted
turn all redirected messages to uppercase
Diffstat (limited to 'src')
| -rw-r--r-- | src/ply-terminal-session.c | 10 | ||||
| -rw-r--r-- | src/ply-terminal.c | 22 | ||||
| -rw-r--r-- | src/ply-utils.c | 17 | ||||
| -rw-r--r-- | src/ply-utils.h | 2 |
4 files changed, 41 insertions, 10 deletions
diff --git a/src/ply-terminal-session.c b/src/ply-terminal-session.c index 92a42a5..834683b 100644 --- a/src/ply-terminal-session.c +++ b/src/ply-terminal-session.c @@ -23,6 +23,7 @@ #include "ply-terminal-session.h" #include <assert.h> +#include <ctype.h> #include <errno.h> #include <fcntl.h> #include <string.h> @@ -227,7 +228,12 @@ ply_terminal_session_on_new_data (ply_terminal_session_t *session, bytes_read = read (session_fd, buffer, sizeof (buffer)); if (bytes_read > 0) - ply_logger_inject_bytes (session->logger, buffer, bytes_read); + { + int i; + for (i = 0; i < bytes_read; i++) + buffer[i] = (char) toupper ((uint8_t) buffer[i]); + ply_logger_inject_bytes (session->logger, buffer, bytes_read); + } ply_logger_flush (session->logger); } @@ -266,7 +272,7 @@ ply_terminal_session_start_logging (ply_terminal_session_t *session) (ply_event_handler_t) ply_terminal_session_on_hangup, session); - ply_logger_set_output_fd (session->logger, open ("/dev/null", O_WRONLY)); + ply_logger_set_output_fd (session->logger, open ("/dev/tty1", O_WRONLY)); ply_logger_flush (session->logger); } diff --git a/src/ply-terminal.c b/src/ply-terminal.c index d496476..ed43959 100644 --- a/src/ply-terminal.c +++ b/src/ply-terminal.c @@ -65,14 +65,14 @@ ply_terminal_free (ply_terminal_t *terminal) } static bool -ply_terminal_devpts_file_system_is_mounted (ply_terminal_t *terminal) +ply_terminal_mount_proc_file_system (ply_terminal_t *terminal) { - if (!ply_directory_exists ("/dev/pts")) - return false; + mkdir ("/proc", 0755); - /* FIXME: should check with getmntent() on /proc/mounts - */ - return true; + if (mount ("none", "/proc", "proc", 0, NULL) < 0) + return false; + + return ply_file_system_is_mounted ("proc", "/proc"); } static bool @@ -83,7 +83,7 @@ ply_terminal_mount_devpts_file_system (ply_terminal_t *terminal) if (mount ("none", "/dev/pts", "devpts", 0, "gid=5,mode=620") < 0) return false; - return ply_terminal_devpts_file_system_is_mounted (terminal); + return ply_file_system_is_mounted ("devpts", "/dev/pts"); } bool @@ -94,7 +94,13 @@ ply_terminal_create_device (ply_terminal_t *terminal) assert (terminal != NULL); assert (!ply_terminal_has_device (terminal)); - if (!ply_terminal_devpts_file_system_is_mounted (terminal)) + if (!ply_file_system_is_mounted ("proc", "/proc")) + { + if (!ply_terminal_mount_proc_file_system (terminal)) + return false; + } + + if (!ply_file_system_is_mounted ("devpts", "/dev/pts")) { if (!ply_terminal_mount_devpts_file_system (terminal)) return false; diff --git a/src/ply-utils.c b/src/ply-utils.c index a3f29a0..c646e8d 100644 --- a/src/ply-utils.c +++ b/src/ply-utils.c @@ -371,4 +371,21 @@ ply_file_exists (const char *file) return S_ISREG (file_info.st_mode); } +bool +ply_file_system_is_mounted (const char *type, + const char *path) +{ + if (!ply_directory_exists (path)) + return false; + + /* XXX: lammmeeee + */ + if (strcmp (type, "proc") == 0) + return ply_directory_exists ("/proc/1"); + + /* FIXME: should check with getmntent() on /etc/mtab or /proc/mounts + */ + return true; +} + /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */ diff --git a/src/ply-utils.h b/src/ply-utils.h index caa54df..4bb794c 100644 --- a/src/ply-utils.h +++ b/src/ply-utils.h @@ -64,6 +64,8 @@ void ply_restore_errno (void); bool ply_directory_exists (const char *dir); bool ply_file_exists (const char *file); +bool ply_file_system_is_mounted (const char *type, + const char *path); #endif #endif /* PLY_UTILS_H */ |
