diff --git a/Userspace/apps/sys/uname/Makefile b/Userspace/apps/sys/uname/Makefile
deleted file mode 100644
index 2b439d37..00000000
--- a/Userspace/apps/sys/uname/Makefile
+++ /dev/null
@@ -1,33 +0,0 @@
-default:
- $(error Do not run this Makefile directly!)
-
-S_SOURCES = $(shell find ./ -type f -name '*.S')
-C_SOURCES = $(shell find ./ -type f -name '*.c')
-CXX_SOURCES = $(shell find ./ -type f -name '*.cpp')
-
-OBJ = $(S_SOURCES:.S=.o) $(C_SOURCES:.c=.o) $(CXX_SOURCES:.cpp=.o)
-
-FILENAME = $(notdir $(shell pwd))
-WARNCFLAG = -Wall -Wextra
-
-build: $(FILENAME).elf
- cp $(FILENAME).elf $(WORKSPACE_DIR)/out/bin/$(FILENAME)
-
-$(FILENAME).elf: $(OBJ)
- $(info Linking $@)
- $(CC) $(LDFLAGS) $(SYSROOT) $(OBJ) -o $@
-
-%.o: %.c $(HEADERS)
- $(info Compiling $<)
- $(CC) $(CFLAGS) $(WARNCFLAG) -std=c17 -c $< -o $@
-
-%.o: %.cpp $(HEADERS)
- $(info Compiling $<)
- $(CXX) $(CFLAGS) $(WARNCFLAG) -std=c++20 -fexceptions -c $< -o $@ -fno-rtti
-
-%.o: %.S
- $(info Compiling $<)
- $(AS) -o $@ $<
-
-clean:
- rm -f $(OBJ) $(FILENAME).elf
diff --git a/Userspace/coreutils/.gitignore b/Userspace/coreutils/.gitignore
index 6f65c48b..378eac25 100644
--- a/Userspace/coreutils/.gitignore
+++ b/Userspace/coreutils/.gitignore
@@ -1 +1 @@
-./build
+build
diff --git a/Userspace/apps/sys/uname/uname.c b/Userspace/coreutils/src/uname.c
similarity index 58%
rename from Userspace/apps/sys/uname/uname.c
rename to Userspace/coreutils/src/uname.c
index 7da7f015..773d2b87 100644
--- a/Userspace/apps/sys/uname/uname.c
+++ b/Userspace/coreutils/src/uname.c
@@ -1,18 +1,18 @@
/*
- This file is part of Fennix Userspace.
+ This file is part of Fennix Core Utilities.
- Fennix Userspace is free software: you can redistribute it and/or
+ Fennix Core Utilities is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
- Fennix Userspace is distributed in the hope that it will be useful,
+ Fennix Core Utilities is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Fennix Userspace. If not, see .
+ along with Fennix Core Utilities. If not, see .
*/
#include
@@ -21,7 +21,89 @@
#include
#include
-void print_usage()
+const char *GetOperatingSystemName(const char *sysname)
+{
+ if (strcmp(sysname, "Fennix") == 0)
+ return "Fennix";
+ if (strncmp(sysname, "Linux", 5) == 0)
+ return "GNU/Linux";
+ if (strncmp(sysname, "Darwin", 6) == 0)
+ return "macOS";
+ if (strncmp(sysname, "FreeBSD", 7) == 0)
+ return "FreeBSD";
+ if (strncmp(sysname, "NetBSD", 6) == 0)
+ return "NetBSD";
+ if (strncmp(sysname, "OpenBSD", 7) == 0)
+ return "OpenBSD";
+ if (strncmp(sysname, "DragonFly", 9) == 0)
+ return "DragonFly BSD";
+ if (strncmp(sysname, "SunOS", 5) == 0)
+ return "SunOS";
+ if (strncmp(sysname, "AIX", 3) == 0)
+ return "AIX";
+ if (strncmp(sysname, "HP-UX", 5) == 0)
+ return "HP-UX";
+ if (strncmp(sysname, "GNU", 3) == 0)
+ return "GNU";
+ if (strncmp(sysname, "Minix", 5) == 0)
+ return "Minix";
+ if (strncmp(sysname, "QNX", 3) == 0)
+ return "QNX";
+ if (strncmp(sysname, "Haiku", 5) == 0)
+ return "Haiku";
+ if (strncmp(sysname, "OS/2", 4) == 0)
+ return "OS/2";
+
+ return sysname;
+}
+
+const char *GetProcessorType(const char *machine)
+{
+ if (strcmp(machine, "x86_64") == 0)
+ return "x86_64";
+ if (strcmp(machine, "i686") == 0 || strcmp(machine, "i386") == 0)
+ return "i686";
+ if (strncmp(machine, "arm", 3) == 0)
+ return "arm";
+ if (strncmp(machine, "aarch64", 7) == 0)
+ return "aarch64";
+ if (strncmp(machine, "riscv64", 7) == 0)
+ return "riscv64";
+ if (strncmp(machine, "mips", 4) == 0)
+ return "mips";
+ if (strncmp(machine, "powerpc", 7) == 0)
+ return "powerpc";
+ if (strncmp(machine, "sparc", 5) == 0)
+ return "sparc";
+
+ return "unknown";
+}
+
+const char *GetHardwarePlatform(const char *machine)
+{
+ if (strcmp(machine, "x86_64") == 0)
+ return "x86_64";
+ if (strcmp(machine, "i686") == 0 || strcmp(machine, "i386") == 0)
+ return "pc";
+ if (strncmp(machine, "arm", 3) == 0)
+ return "arm";
+ if (strncmp(machine, "aarch64", 7) == 0)
+ return "aarch64";
+ if (strncmp(machine, "riscv64", 7) == 0)
+ return "riscv64";
+ if (strncmp(machine, "mips", 4) == 0)
+ return "mips";
+ if (strncmp(machine, "powerpc64le", 11) == 0)
+ return "ppc64le";
+ if (strncmp(machine, "powerpc", 7) == 0)
+ return "powerpc";
+ if (strncmp(machine, "sparc", 5) == 0)
+ return "sparc";
+
+ return "unknown";
+}
+
+void PrintUsage()
{
printf("Usage: uname [OPTION]...\n");
printf("Display specific system information. With no OPTION, defaults to -s.\n\n");
@@ -86,13 +168,13 @@ int main(int argc, char *argv[])
print_operating_system = true;
else if (strcmp(argv[i], "--help") == 0)
{
- print_usage();
+ PrintUsage();
exit(EXIT_SUCCESS);
}
else
{
fprintf(stderr, "uname: invalid option -- '%s'\n", argv[i]);
- print_usage();
+ PrintUsage();
exit(EXIT_FAILURE);
}
}
@@ -109,11 +191,11 @@ int main(int argc, char *argv[])
if (print_all || print_machine)
printf("%s ", buffer.machine);
if (print_all || print_processor)
- printf("%s ", buffer.machine); /* FIXME */
+ printf("%s ", GetProcessorType(buffer.machine));
if (print_all || print_hardware_platform)
- printf("%s ", buffer.machine); /* FIXME */
+ printf("%s ", GetHardwarePlatform(buffer.machine));
if (print_all || print_operating_system)
- printf("%s ", buffer.sysname); /* FIXME */
+ printf("%s ", GetOperatingSystemName(buffer.sysname));
printf("\n");
return 0;
}