diff --git a/kernel/src/init/InitRD.cpp b/kernel/src/init/InitRD.cpp index d7c7aae8..afde38a0 100644 --- a/kernel/src/init/InitRD.cpp +++ b/kernel/src/init/InitRD.cpp @@ -126,7 +126,7 @@ void InitRD::for_each(void (*callback)(File& f)) } } -#define INITRD_MAX_FILES_IN_DIR 16 +#define INITRD_MAX_FILES_IN_DIR 32 #define INITRD_MAX_FILES 64 namespace InitRD @@ -378,7 +378,7 @@ static bool initrd_register_file(InitRD::File& f, uint64_t inode) static void initrd_scan() { initrd_for_each_dir([](InitRD::Directory& dir) { - if (total_dirs >= 32) + if (total_dirs >= INITRD_MAX_FILES) { kwarnln("Failed to register directory %s: Too many directories in initrd", dir.name); return; @@ -387,7 +387,7 @@ static void initrd_scan() if (initrd_register_dir(dir, inode)) dirs[total_dirs++] = dir; }); InitRD::for_each([](InitRD::File& f) { - if (total_files >= 32) + if (total_files >= INITRD_MAX_FILES) { kwarnln("Failed to register file %s: Too many files in initrd", f.name); return; diff --git a/libs/libc/include/locale.h b/libs/libc/include/locale.h index e69de29b..2fc432d9 100644 --- a/libs/libc/include/locale.h +++ b/libs/libc/include/locale.h @@ -0,0 +1,19 @@ +#ifndef _LOCALE_H +#define _LOCALE_H + +#define LC_ALL 0 +#define LC_CTYPE 1 +#define LC_COLLATE 2 + +#ifdef __cplusplus +extern "C" +{ +#endif + + char* setlocale(int category, const char* locale); // Not implemented. + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/libs/libc/include/memory.h b/libs/libc/include/memory.h new file mode 100644 index 00000000..e69de29b diff --git a/libs/libc/include/stdlib.h b/libs/libc/include/stdlib.h index fb7f52cf..397c9d3d 100644 --- a/libs/libc/include/stdlib.h +++ b/libs/libc/include/stdlib.h @@ -48,6 +48,9 @@ extern "C" /* Registers a handler function to be run at normal program termination. */ int atexit(void (*handler)(void)); + /* Returns a floating point number parsed from the string str. */ + float atof(const char* str); + /* Returns an integer (of type int) parsed from the string str. */ int atoi(const char* str); diff --git a/libs/libc/include/sys/stat.h b/libs/libc/include/sys/stat.h index b2480f84..93a00ba6 100644 --- a/libs/libc/include/sys/stat.h +++ b/libs/libc/include/sys/stat.h @@ -68,6 +68,7 @@ extern "C" mode_t umask(mode_t cmask); int chmod(const char* pathname, mode_t mode); // Not implemented. + int fchmod(int fd, mode_t mode); // Not implemented. #ifdef __cplusplus } diff --git a/libs/libc/include/unistd.h b/libs/libc/include/unistd.h index 835b989f..146464d9 100644 --- a/libs/libc/include/unistd.h +++ b/libs/libc/include/unistd.h @@ -99,6 +99,9 @@ extern "C" char* getcwd(char* buf, size_t size); int unlink(const char* path); // Not implemented. + int rmdir(const char* path); // Not implemented. + int chdir(const char* path); // Not implemented. + int pipe(int fd[2]); // Not implemented. #ifdef __cplusplus } diff --git a/libs/libc/include/utime.h b/libs/libc/include/utime.h new file mode 100644 index 00000000..6111ecdb --- /dev/null +++ b/libs/libc/include/utime.h @@ -0,0 +1,23 @@ +#ifndef _UTIME_H +#define _UTIME_H + +#include + +struct utimbuf +{ + time_t actime; + time_t modtime; +}; + +#ifdef __cplusplus +extern "C" +{ +#endif + + int utime(const char*, const struct utimbuf*); // Not implemented. + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/libs/libc/src/init.cpp b/libs/libc/src/init.cpp index 54874acc..5c740b7b 100644 --- a/libs/libc/src/init.cpp +++ b/libs/libc/src/init.cpp @@ -4,6 +4,8 @@ #include #include +char** environ = {nullptr}; + static void terminate_libc() { fclose(stdout); diff --git a/libs/libc/src/locale.cpp b/libs/libc/src/locale.cpp new file mode 100644 index 00000000..bf6167c0 --- /dev/null +++ b/libs/libc/src/locale.cpp @@ -0,0 +1,12 @@ +#include +#include + +static char default_locale[] = "C"; + +extern "C" +{ + char* setlocale(int, const char*) + { + return default_locale; + } +} \ No newline at end of file diff --git a/libs/libc/src/stdlib.cpp b/libs/libc/src/stdlib.cpp index 192f8bb9..d924674e 100644 --- a/libs/libc/src/stdlib.cpp +++ b/libs/libc/src/stdlib.cpp @@ -26,6 +26,40 @@ template static T string_to_integer_type(const char* str) return (neg ? -val : val); } +template static T string_to_float_type(const char* str) +{ + bool neg = false; + T val = 0; + + T small = 0; + + switch (*str) + { + case '-': + neg = true; + str++; + break; + case '+': str++; break; + default: break; + } + + while (isdigit(*str)) { val = (10 * val) + (T)(*str++ - '0'); } + if (*str == '.') + { + str++; + T div = 10; + while (isdigit(*str)) + { + small = small + (T)(*str++ - '0') / div; + div *= 10; + } + + val += small; + } + + return (neg ? -val : val); +} + template static inline Struct common_div(Arg a, Arg b) { Struct result; @@ -48,6 +82,11 @@ extern "C" _Exit(-1); } + float atof(const char* str) + { + return string_to_float_type(str); + } + int atoi(const char* str) { return string_to_integer_type(str); diff --git a/libs/libc/src/sys/stat.cpp b/libs/libc/src/sys/stat.cpp index 7b9b96c1..f2820101 100644 --- a/libs/libc/src/sys/stat.cpp +++ b/libs/libc/src/sys/stat.cpp @@ -29,4 +29,9 @@ extern "C" { NOT_IMPLEMENTED("chmod"); } + + int fchmod(int, mode_t) + { + NOT_IMPLEMENTED("fchmod"); + } } \ No newline at end of file diff --git a/libs/libc/src/unistd.cpp b/libs/libc/src/unistd.cpp index efaadabb..304bcabf 100644 --- a/libs/libc/src/unistd.cpp +++ b/libs/libc/src/unistd.cpp @@ -148,4 +148,19 @@ extern "C" { NOT_IMPLEMENTED("unlink"); } + + int rmdir(const char*) + { + NOT_IMPLEMENTED("rmdir"); + } + + int chdir(const char*) + { + NOT_IMPLEMENTED("chdir"); + } + + int pipe(int[2]) + { + NOT_IMPLEMENTED("pipe"); + } } \ No newline at end of file diff --git a/libs/libc/src/utime.cpp b/libs/libc/src/utime.cpp new file mode 100644 index 00000000..b3ffb991 --- /dev/null +++ b/libs/libc/src/utime.cpp @@ -0,0 +1,10 @@ +#include +#include + +extern "C" +{ + int utime(const char*, const struct utimbuf*) + { + NOT_IMPLEMENTED("utime"); + } +} \ No newline at end of file