diff options
author | Andreas Kling <awesomekling@gmail.com> | 2018-10-17 12:07:39 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2018-10-17 12:07:39 +0200 |
commit | 39fa1eb2c272671b09f3e9d6a5c9afb11a1ebee3 (patch) | |
tree | 21269fce78156239986f43ed89ce15495aa9539c | |
parent | 705832f3873c335eae38917fcca2e48bbb8e3354 (diff) | |
download | serenity-39fa1eb2c272671b09f3e9d6a5c9afb11a1ebee3.zip |
Print the contents of motd.txt on boot.
-rwxr-xr-x | Kernel/Boot/boot.asm | 2 | ||||
-rw-r--r-- | Kernel/Makefile | 3 | ||||
-rw-r--r-- | Kernel/StdLib.cpp | 13 | ||||
-rw-r--r-- | Kernel/init.cpp | 11 | ||||
-rw-r--r-- | VirtualFileSystem/FileHandle.cpp | 7 |
5 files changed, 28 insertions, 8 deletions
diff --git a/Kernel/Boot/boot.asm b/Kernel/Boot/boot.asm index 7a7569583e..6d0bf6e9e6 100755 --- a/Kernel/Boot/boot.asm +++ b/Kernel/Boot/boot.asm @@ -42,7 +42,7 @@ boot: inc word [cur_lba] mov cx, word [cur_lba] - cmp cx, 300 + cmp cx, 400 jz .sector_loop_end mov bx, es diff --git a/Kernel/Makefile b/Kernel/Makefile index b66032e407..4ac51e1a06 100644 --- a/Kernel/Makefile +++ b/Kernel/Makefile @@ -30,7 +30,8 @@ VFS_OBJS = \ ../VirtualFileSystem/DiskBackedFileSystem.o \ ../VirtualFileSystem/Ext2FileSystem.o \ ../VirtualFileSystem/InodeIdentifier.o \ - ../VirtualFileSystem/VirtualFileSystem.o + ../VirtualFileSystem/VirtualFileSystem.o \ + ../VirtualFileSystem/FileHandle.o AK_OBJS = \ ../AK/String.o \ diff --git a/Kernel/StdLib.cpp b/Kernel/StdLib.cpp index 1ecdc6c9af..4c4794ba7b 100644 --- a/Kernel/StdLib.cpp +++ b/Kernel/StdLib.cpp @@ -1,6 +1,7 @@ #include "types.h" #include "Assertions.h" #include "kmalloc.h" +#include <AK/Types.h> void memcpy(void *dest, const void *src, DWORD n) { @@ -51,11 +52,13 @@ char* strdup(const char *str) int memcmp(const void* v1, const void* v2, size_t n) { - size_t m; - const char* s1 = (const char*)v1; - const char* s2 = (const char*)v2; - for (m = 0; m < n && *s1 == *s2; ++s1, ++s2); - return m == n ? 0 : -1; + auto* s1 = (const byte*)v1; + auto* s2 = (const byte*)v2; + while (n-- > 0) { + if (*s1++ != *s2++) + return s1[-1] < s2[-1] ? -1 : 1; + } + return 0; } extern "C" void __cxa_pure_virtual() diff --git a/Kernel/init.cpp b/Kernel/init.cpp index 723770fc4d..b30fdab381 100644 --- a/Kernel/init.cpp +++ b/Kernel/init.cpp @@ -20,6 +20,7 @@ #include <VirtualFileSystem/RandomDevice.h> #include <VirtualFileSystem/Ext2FileSystem.h> #include <VirtualFileSystem/VirtualFileSystem.h> +#include <VirtualFileSystem/FileHandle.h> #include <AK/OwnPtr.h> #if 0 @@ -154,6 +155,16 @@ void init() vfs->listDirectory("/"); + { + auto motdFile = vfs->open("/motd.txt"); + ASSERT(motdFile); + auto motdData = motdFile->readEntireFile(); + + for (unsigned i = 0; i < motdData.size(); ++i) { + kprintf("%c", motdData[i]); + } + } + // The idle task will spend its eternity here for now. for (;;) { asm("hlt"); diff --git a/VirtualFileSystem/FileHandle.cpp b/VirtualFileSystem/FileHandle.cpp index 2f0819d1e9..e0c6bda02f 100644 --- a/VirtualFileSystem/FileHandle.cpp +++ b/VirtualFileSystem/FileHandle.cpp @@ -5,7 +5,7 @@ #include "UnixTypes.h" FileHandle::FileHandle(RetainPtr<VirtualFileSystem::Node>&& vnode) - : m_vnode(std::move(vnode)) + : m_vnode(move(vnode)) { } @@ -13,12 +13,14 @@ FileHandle::~FileHandle() { } +#ifndef SERENITY_KERNEL bool additionWouldOverflow(Unix::off_t a, Unix::off_t b) { ASSERT(a > 0); uint64_t ua = a; return (ua + b) > maxFileOffset; } +#endif int FileHandle::stat(Unix::stat* buffer) { @@ -67,14 +69,17 @@ Unix::off_t FileHandle::seek(Unix::off_t offset, int whence) break; case SEEK_CUR: newOffset = m_currentOffset + offset; +#ifndef SERENITY_KERNEL if (additionWouldOverflow(m_currentOffset, offset)) return -EOVERFLOW; +#endif if (newOffset < 0) return -EINVAL; break; case SEEK_END: // FIXME: Implement! notImplemented(); + newOffset = 0; break; default: return -EINVAL; |