From 2c18d433594c268f98dba278f204d44c90cafb45 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sat, 27 Aug 2011 23:26:11 +0200 Subject: [PATCH] Added the programs ls and help. --- Makefile | 2 +- libmaxsi/hsrc/process.h | 1 + libmaxsi/process.cpp | 6 ++++++ sortix/initrd.cpp | 11 +++++++++++ sortix/initrd.h | 1 + sortix/syscall.cpp | 4 +++- utils/Makefile | 3 +++ utils/help.cpp | 15 +++++++++++++++ utils/ls.cpp | 9 +++++++++ 9 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 utils/help.cpp create mode 100644 utils/ls.cpp diff --git a/Makefile b/Makefile index 6dee455c..e8d71036 100644 --- a/Makefile +++ b/Makefile @@ -103,7 +103,7 @@ iso: all debsource mkdir -p $(INITRDDIR) cp hello/hello $(INITRDDIR) cp pong/pong $(INITRDDIR) - for F in init cat sh mxsh clear; do cp utils/$$F $(INITRDDIR); done + for F in init cat sh mxsh clear ls help uname; do cp utils/$$F $(INITRDDIR); done (cd $(INITRDDIR) && ../mkinitrd/mkinitrd * -o ../$(ISODIR)/boot/sortix.initrd) rm -rf $(INITRDDIR) cp builds/$(DEBSRCNAME)-src.tar.gz $(ISODIR) diff --git a/libmaxsi/hsrc/process.h b/libmaxsi/hsrc/process.h index 381d05f3..dea5773d 100644 --- a/libmaxsi/hsrc/process.h +++ b/libmaxsi/hsrc/process.h @@ -30,6 +30,7 @@ namespace Maxsi namespace Process { int Execute(const char* filepath, int argc, const char** argv); + void PrintPathFiles(); } } diff --git a/libmaxsi/process.cpp b/libmaxsi/process.cpp index 5aa75267..0eb8edb0 100644 --- a/libmaxsi/process.cpp +++ b/libmaxsi/process.cpp @@ -31,11 +31,17 @@ namespace Maxsi namespace Process { DEFN_SYSCALL3(int, SysExecute, 10, const char*, int, const char**); + DEFN_SYSCALL0_VOID(SysPrintPathFiles, 11); int Execute(const char* filepath, int argc, const char** argv) { return SysExecute(filepath, argc, argv); } + + void PrintPathFiles() + { + SysPrintPathFiles(); + } } } diff --git a/sortix/initrd.cpp b/sortix/initrd.cpp index 25f3f916..09534857 100644 --- a/sortix/initrd.cpp +++ b/sortix/initrd.cpp @@ -65,5 +65,16 @@ namespace Sortix return NULL; } + + void SysPrintPathFiles(CPU::InterruptRegisters* /*R*/) + { + Header* header = (Header*) initrd; + FileHeader* fhtbl = (FileHeader*) (initrd + sizeof(Header)); + for ( uint32_t i = 0; i < header->numfiles; i++ ) + { + FileHeader* fileheader = &(fhtbl[i]); + Log::PrintF("%s\n", fileheader->name); + } + } } } diff --git a/sortix/initrd.h b/sortix/initrd.h index 5a826a9a..ae5e1a3d 100644 --- a/sortix/initrd.h +++ b/sortix/initrd.h @@ -50,6 +50,7 @@ namespace Sortix }; #ifdef SORTIX_KERNEL + void SysPrintPathFiles(CPU::InterruptRegisters* R); void Init(byte* initrd, size_t size); byte* Open(const char* filepath, size_t* size); #endif diff --git a/sortix/syscall.cpp b/sortix/syscall.cpp index 020d12ac..212c3e9f 100644 --- a/sortix/syscall.cpp +++ b/sortix/syscall.cpp @@ -35,6 +35,7 @@ #include "keyboard.h" #include "sound.h" #include "process.h" +#include "initrd.h" namespace Sortix { @@ -51,7 +52,7 @@ namespace Sortix #endif } - const size_t NumSyscalls = 11; + const size_t NumSyscalls = 12; const Syscall Syscalls[NumSyscalls] = { &Scheduler::SysCreateThread, @@ -65,6 +66,7 @@ namespace Sortix &Keyboard::SysReceieveKeystroke, &Sound::SysSetFrequency, &SysExecute, + &InitRD::SysPrintPathFiles, }; void Init() diff --git a/utils/Makefile b/utils/Makefile index 6511e64f..b8018cdf 100644 --- a/utils/Makefile +++ b/utils/Makefile @@ -8,6 +8,9 @@ cat \ sh \ mxsh \ clear \ +ls \ +help \ +uname \ all: $(BINARIES) diff --git a/utils/help.cpp b/utils/help.cpp new file mode 100644 index 00000000..b129d06d --- /dev/null +++ b/utils/help.cpp @@ -0,0 +1,15 @@ +#include +#include + +int main(int argc, char* argv[]) +{ + // Reset the terminal's color and the rest of it. + printf("Please enter the name of one of the following programs:\n"); + + const char* programname = "ls"; + const char* newargv[] = { programname }; + + Maxsi::Process::Execute(programname, 1, newargv); + + return 1; +} diff --git a/utils/ls.cpp b/utils/ls.cpp new file mode 100644 index 00000000..5bda7289 --- /dev/null +++ b/utils/ls.cpp @@ -0,0 +1,9 @@ +#include +#include + +int main(int argc, char* argv[]) +{ + Maxsi::Process::PrintPathFiles(); + + return 0; +}