]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
mount /proc and /dev/pts if they aren't mounted
authorRay Strode <rstrode@redhat.com>
Wed, 23 May 2007 21:11:18 +0000 (17:11 -0400)
committerRay Strode <rstrode@redhat.com>
Wed, 23 May 2007 21:11:18 +0000 (17:11 -0400)
turn all redirected messages to uppercase

src/ply-terminal-session.c
src/ply-terminal.c
src/ply-utils.c
src/ply-utils.h

index 92a42a5a1b00fe08311504af2a0d8945e9ff2230..834683b9bfa7c9cd10826a533a99aa8be5b0e01a 100644 (file)
@@ -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);
 }
 
index d49647615c686f4edf738566b2921b52af270fba..ed4395963bef8d37d6ef19a2a0538987d00211b6 100644 (file)
@@ -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;
index a3f29a09457f056de796f964084f14816eb8b2fa..c646e8dce1e0aba8ba5b7cedb5db61616f51c938 100644 (file)
@@ -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: */
index caa54df8522ac7063522548e3e3265c8d48b9ebc..4bb794cce0d22de06657d2b5f58142f9ef384390 100644 (file)
@@ -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 */