#include "ply-terminal-session.h"
#include <assert.h>
+#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
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);
}
(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);
}
}
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
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
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;
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: */
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 */