diff --git a/.gitmodules b/.gitmodules index d5c5452..dbc6337 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,13 +1,6 @@ [submodule "apps/user/games/doomgeneric"] path = apps/user/games/doomgeneric url = https://github.com/Fennix-Project/doomgeneric.git -[submodule "apps/base/bash"] - path = apps/base/bash - url = https://github.com/Fennix-Project/bash.git [submodule "musl"] path = musl url = https://github.com/Fennix-Project/musl.git -[submodule "apps/base/busybox"] - path = apps/base/busybox - url = git://busybox.net/busybox.git - branch = 1_36_stable \ No newline at end of file diff --git a/Makefile b/Makefile index 1bf1b2f..b1a4093 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,7 @@ endif cd out/lib && ln -s /lib/libc.so ./ld-musl-x86_64.so.1 && \ ln -s /lib/libc.so ./ld.so mkdir -p out/include/fennix - cp ../Kernel/syscalls.h out/include/fennix/syscall.h + cp ../Kernel/include/interface/syscalls.h out/include/fennix/syscall.h create_out: rm -rf out diff --git a/apps/base/Makefile b/apps/base/Makefile index 2db923b..badaa21 100644 --- a/apps/base/Makefile +++ b/apps/base/Makefile @@ -20,43 +20,11 @@ else export CFLAGS := --sysroot=$(cwd)/../../out/ -I$(cwd)/../../out/include/ endif -build_bash: -ifeq ($(wildcard $(CACHE_DIR)/bash),) - mkdir -p $(CACHE_DIR)/bash - cd $(CACHE_DIR)/bash && \ - ../../apps/base/bash/configure --prefix=$(PREFIX) \ - --host=$(TARGET) \ - --enable-minimal-config -endif - LDFLAGS="--static" make -C $(CACHE_DIR)/bash -j$(shell nproc) - make -C $(CACHE_DIR)/bash install - -BUSYBOX_CROSS_PATH := $(cwd)/../../../tools/cross/bin/$(TARGET)- - -build_busybox: -ifeq ($(wildcard $(CACHE_DIR)/busybox),) - mkdir -p $(CACHE_DIR)/busybox - cd $(CACHE_DIR)/busybox && \ - make KBUILD_SRC=../../apps/base/busybox \ - CROSS_COMPILE=$(BUSYBOX_CROSS_PATH) \ - -f ../../apps/base/busybox/Makefile \ - allnoconfig -endif - cd $(CACHE_DIR)/busybox && \ - make -C $(CACHE_DIR)/busybox \ - CROSS_COMPILE=$(BUSYBOX_CROSS_PATH) -j$(shell nproc) - cd $(CACHE_DIR)/busybox && \ - make -C $(CACHE_DIR)/busybox \ - CONFIG_PREFIX=$(PREFIX) \ - CROSS_COMPILE=$(BUSYBOX_CROSS_PATH) install - build: make -C utest build make -C cross_test build make -C echo build make -C fsh build -# $(MAKE) build_busybox -# $(MAKE) build_bash clean: make -C utest clean diff --git a/apps/base/bash b/apps/base/bash deleted file mode 160000 index 07d7e00..0000000 --- a/apps/base/bash +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 07d7e008172fd30d786917d7924c9aba9a2d14fc diff --git a/apps/base/busybox b/apps/base/busybox deleted file mode 160000 index 1a64f6a..0000000 --- a/apps/base/busybox +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1a64f6a20aaf6ea4dbba68bbfa8cc1ab7e5c57c4 diff --git a/apps/base/cross_test/linux_glibc.c b/apps/base/cross_test/linux_glibc.c index cf01af1..b5642c1 100644 --- a/apps/base/cross_test/linux_glibc.c +++ b/apps/base/cross_test/linux_glibc.c @@ -1,9 +1,97 @@ +#define _POSIX_SOURCE +#define _DEFAULT_SOURCE #include #include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef __GLIBC__ +#define __GLIBC__ 0 +#endif + +#ifndef __GLIBC_MINOR__ +#define __GLIBC_MINOR__ 0 +#endif + +int ptmx_test() +{ + int masterFD; + int slaveFD; + char slaveName[100]; + + masterFD = open("/dev/ptmx", O_RDWR | O_NOCTTY); + if (masterFD < 0) + { + perror("Failed to open /dev/ptmx"); + return 1; + } + + if (grantpt(masterFD) < 0) + { + perror("Failed to grantpt"); + return 1; + } + + if (unlockpt(masterFD) < 0) + { + perror("Failed to unlockpt"); + return 1; + } + + if (ptsname_r(masterFD, slaveName, sizeof(slaveName)) != 0) + { + perror("Failed to get slave name"); + return 1; + } + + printf("Slave terminal: %s\n", slaveName); + + slaveFD = open(slaveName, O_RDWR | O_NOCTTY); + if (slaveFD < 0) + { + perror("Failed to open slave terminal"); + return 1; + } + + struct termios t; + tcgetattr(slaveFD, &t); + cfmakeraw(&t); + tcsetattr(slaveFD, TCSANOW, &t); + + char *message = "Hello from master!\n"; + write(masterFD, message, strlen(message)); + + char buffer[100]; + int len = read(slaveFD, buffer, sizeof(buffer) - 1); + if (len > 0) + { + buffer[len] = '\0'; + printf("Received from slave: %s\n", buffer); + } + + close(masterFD); + close(slaveFD); + return 0; +} int main(int argc, char *argv[], char *envp[]) { - printf("glibc: Hello, World!\n"); + printf("glibc %d.%d: Hello, World!\n", __GLIBC__, __GLIBC_MINOR__); fflush(stdout); + ptmx_test(); return 0; } diff --git a/apps/base/utest/Makefile b/apps/base/utest/Makefile index 52122a4..81af0c7 100644 --- a/apps/base/utest/Makefile +++ b/apps/base/utest/Makefile @@ -32,10 +32,10 @@ FILENAME = utest HEADERS = $(sort $(dir $(wildcard $(WORKSPACE)out/include/*))) -LDFLAGS = +LDFLAGS = -static CFLAGS = -I$(WORKSPACE)out/include \ -DGIT_COMMIT='"$(GIT_COMMIT)"' \ - -DGIT_COMMIT_SHORT='"$(GIT_COMMIT_SHORT)"' + -DGIT_COMMIT_SHORT='"$(GIT_COMMIT_SHORT)"' -static WARNCFLAG = -Wall -Wextra ifeq ($(DEBUG), 1) diff --git a/libc/Makefile b/libc/Makefile index d072149..69c3b79 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -1,6 +1,6 @@ build: cp -r include/* ../out/include - cp ../../Kernel/syscalls.h ../out/include/fennix/syscall.h + cp ../Kernel/include/interface/syscalls.h ../out/include/fennix/syscall.h make -C runtime build make -C src build make -C ElfInterpreter build