From: Ray Strode Date: Wed, 23 May 2007 21:11:18 +0000 (-0400) Subject: mount /proc and /dev/pts if they aren't mounted X-Git-Tag: 0.1.0~251 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6949c46ea26884d27b650af54d07ed46828b84dc;p=thirdparty%2Fplymouth.git mount /proc and /dev/pts if they aren't mounted turn all redirected messages to uppercase --- diff --git a/src/ply-terminal-session.c b/src/ply-terminal-session.c index 92a42a5a..834683b9 100644 --- a/src/ply-terminal-session.c +++ b/src/ply-terminal-session.c @@ -23,6 +23,7 @@ #include "ply-terminal-session.h" #include +#include #include #include #include @@ -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 d4964761..ed439596 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 a3f29a09..c646e8dc 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 caa54df8..4bb794cc 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 */