diff options
author | Conrad Pankoff <deoxxa@fknsrs.biz> | 2019-08-12 21:24:11 +1000 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-08-12 13:52:20 +0200 |
commit | 67a4256a983e38e11e628595818ab847f0e4c8c2 (patch) | |
tree | 1853d1bb6058386c79387d7210770c92a2dcdcea | |
parent | 072bf8cbb9f573288b1f001c4e95357018b50a51 (diff) | |
download | serenity-67a4256a983e38e11e628595818ab847f0e4c8c2.zip |
Server: Add TTYServer, a rudimentary text console manager
This should probably call out to a login program at some point. Right now
it just puts a root terminal on tty{1,2,3}.
Remember not to leave your Serenity workstation unattended!
-rwxr-xr-x | Kernel/build-root-filesystem.sh | 1 | ||||
-rw-r--r-- | Kernel/init.cpp | 23 | ||||
-rwxr-xr-x | Kernel/makeall.sh | 1 | ||||
-rw-r--r-- | Servers/TTYServer/Makefile | 23 | ||||
-rw-r--r-- | Servers/TTYServer/main.cpp | 16 |
5 files changed, 63 insertions, 1 deletions
diff --git a/Kernel/build-root-filesystem.sh b/Kernel/build-root-filesystem.sh index b082e317a3..38921ec207 100755 --- a/Kernel/build-root-filesystem.sh +++ b/Kernel/build-root-filesystem.sh @@ -97,6 +97,7 @@ cp ../Servers/LookupServer/LookupServer mnt/bin/LookupServer cp ../Servers/SystemServer/SystemServer mnt/bin/SystemServer cp ../Servers/WindowServer/WindowServer mnt/bin/WindowServer cp ../Servers/AudioServer/AudioServer mnt/bin/AudioServer +cp ../Servers/TTYServer/TTYServer mnt/bin/TTYServer cp ../Shell/Shell mnt/bin/Shell cp ../Libraries/LibHTML/tho mnt/bin/tho echo "done" diff --git a/Kernel/init.cpp b/Kernel/init.cpp index edfe0e34d3..fa6c072bae 100644 --- a/Kernel/init.cpp +++ b/Kernel/init.cpp @@ -142,11 +142,32 @@ VFS* vfs; auto* system_server_process = Process::create_user_process("/bin/SystemServer", (uid_t)100, (gid_t)100, (pid_t)0, error, {}, {}, tty0); if (error != 0) { - dbgprintf("init_stage2: error spawning SystemServer: %d\n", error); + kprintf("init_stage2: error spawning SystemServer: %d\n", error); hang(); } system_server_process->set_priority(Process::HighPriority); + auto* tty1_process = Process::create_user_process("/bin/TTYServer", (uid_t)0, (gid_t)0, (pid_t)0, error, { "/bin/TTYServer", "tty1" }, {}, tty1); + if (error != 0) { + kprintf("init_stage2: error spawning TTYServer for tty1: %d\n", error); + hang(); + } + tty1_process->set_priority(Process::HighPriority); + + auto* tty2_process = Process::create_user_process("/bin/TTYServer", (uid_t)0, (gid_t)0, (pid_t)0, error, { "/bin/TTYServer", "tty2" }, {}, tty2); + if (error != 0) { + kprintf("init_stage2: error spawning TTYServer for tty2: %d\n", error); + hang(); + } + tty2_process->set_priority(Process::HighPriority); + + auto* tty3_process = Process::create_user_process("/bin/TTYServer", (uid_t)0, (gid_t)0, (pid_t)0, error, { "/bin/TTYServer", "tty3" }, {}, tty3); + if (error != 0) { + kprintf("init_stage2: error spawning TTYServer for tty3: %d\n", error); + hang(); + } + tty3_process->set_priority(Process::HighPriority); + current->process().sys$exit(0); ASSERT_NOT_REACHED(); } diff --git a/Kernel/makeall.sh b/Kernel/makeall.sh index dc83bb2f5b..f43468f612 100755 --- a/Kernel/makeall.sh +++ b/Kernel/makeall.sh @@ -25,6 +25,7 @@ build_targets="$build_targets ../Servers/SystemServer" build_targets="$build_targets ../Servers/LookupServer" build_targets="$build_targets ../Servers/WindowServer" build_targets="$build_targets ../Servers/AudioServer" +build_targets="$build_targets ../Servers/TTYServer" build_targets="$build_targets ../Libraries/LibAudio" build_targets="$build_targets ../Libraries/LibGUI" build_targets="$build_targets ../Libraries/LibHTML" diff --git a/Servers/TTYServer/Makefile b/Servers/TTYServer/Makefile new file mode 100644 index 0000000000..b65d1a8e65 --- /dev/null +++ b/Servers/TTYServer/Makefile @@ -0,0 +1,23 @@ +include ../../Makefile.common + +TTYSERVER_OBJS = \ + main.o + +APP = TTYServer +OBJS = $(TTYSERVER_OBJS) + +DEFINES += -DUSERLAND + +all: $(APP) + +$(APP): $(OBJS) + $(LD) -o $(APP) $(LDFLAGS) $(OBJS) -lc -lcore + +.cpp.o: + @echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $< + +-include $(OBJS:%.o=%.d) + +clean: + @echo "CLEAN"; rm -f $(APP) $(OBJS) *.d + diff --git a/Servers/TTYServer/main.cpp b/Servers/TTYServer/main.cpp new file mode 100644 index 0000000000..f16c226c6d --- /dev/null +++ b/Servers/TTYServer/main.cpp @@ -0,0 +1,16 @@ +#include <stdio.h> +#include <stdlib.h> + +int main(int argc, char** argv) +{ + if (argc < 2) + return -1; + + dbgprintf("Starting console server on %s\n", argv[1]); + + while (true) { + dbgprintf("Running shell on %s\n", argv[1]); + int rc = system("/bin/Shell"); + dbgprintf("Shell on %s exited with code %d\n", argv[1], rc); + } +} |