diff --git a/.DS_Store b/.DS_Store index e9e4d4c..efd6406 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/boredos.iso b/boredos.iso index 9a88003..2a638ac 100644 Binary files a/boredos.iso and b/boredos.iso differ diff --git a/build/boredos.elf b/build/boredos.elf index 1391679..a26fb99 100755 Binary files a/build/boredos.elf and b/build/boredos.elf differ diff --git a/build/cli_apps/fs_commands.o b/build/cli_apps/fs_commands.o index 37d9697..c3697d1 100644 Binary files a/build/cli_apps/fs_commands.o and b/build/cli_apps/fs_commands.o differ diff --git a/build/cli_apps/reboot.o b/build/cli_apps/reboot.o index 59778e6..bb75786 100644 Binary files a/build/cli_apps/reboot.o and b/build/cli_apps/reboot.o differ diff --git a/build/cli_apps/shutdown.o b/build/cli_apps/shutdown.o index 6064f43..eab7135 100644 Binary files a/build/cli_apps/shutdown.o and b/build/cli_apps/shutdown.o differ diff --git a/iso_root/README.md b/iso_root/README.md index 830bd36..7a535bf 100644 --- a/iso_root/README.md +++ b/iso_root/README.md @@ -1,5 +1,5 @@ -# BoredOS 1.50 Beta -BoredOS is now in a Beta stage as i have brought over all apps from brewkernel and have made the DE a lot more usable and stable. +# BoredOS 1.50 +BoredOS has now exited Beta stage and is "stable enough" to be put out as a "stable" product.
BoredOS is a simple x86_64 hobbyist operating system. diff --git a/iso_root/boredos.elf b/iso_root/boredos.elf index 1391679..a26fb99 100755 Binary files a/iso_root/boredos.elf and b/iso_root/boredos.elf differ diff --git a/src/kernel/cli_apps/fs_commands.c b/src/kernel/cli_apps/fs_commands.c index f8bc464..1b3d0b3 100644 --- a/src/kernel/cli_apps/fs_commands.c +++ b/src/kernel/cli_apps/fs_commands.c @@ -106,26 +106,106 @@ void cli_cmd_mkdir(char *args) { } } +// Helper for recursive deletion +static bool rm_recursive(const char *path) { + if (fat32_exists(path) && !fat32_is_directory(path)) { + return fat32_delete(path); + } + + if (!fat32_exists(path)) { + return false; + } + + // It's a directory: delete contents first + while (1) { + FAT32_FileInfo entries[10]; + int count = fat32_list_directory(path, entries, 10); + if (count <= 0) break; + + for (int i = 0; i < count; i++) { + // Construct child path + char child_path[256]; + cli_strcpy(child_path, path); + int len = cli_strlen(child_path); + if (len > 0 && child_path[len-1] != '/') { + child_path[len++] = '/'; + child_path[len] = 0; + } + + // Append name + const char *name = entries[i].name; + int j = 0; + while (name[j] && len < 255) { + child_path[len++] = name[j++]; + } + child_path[len] = 0; + + // Recurse + if (!rm_recursive(child_path)) { + cli_write("Error: Failed to delete "); + cli_write(child_path); + cli_write("\n"); + } + } + } + + return fat32_rmdir(path); +} + void cli_cmd_rm(char *args) { if (!args || args[0] == 0) { - cli_write("Usage: rm \n"); + cli_write("Usage: rm [-r] \n"); + return; + } + + bool recursive = false; + + // Check for -r flag + int i = 0; + while (args[i] == ' ' || args[i] == '\t') i++; + + if (args[i] == '-' && args[i+1] == 'r' && (args[i+2] == ' ' || args[i+2] == '\t' || args[i+2] == 0)) { + recursive = true; + i += 2; + while (args[i] == ' ' || args[i] == '\t') i++; + } + + char *path_start = args + i; + if (path_start[0] == 0) { + cli_write("Usage: rm [-r] \n"); return; } char filename[256]; - int i = 0; - while (args[i] && args[i] != ' ' && args[i] != '\t') { - filename[i] = args[i]; - i++; + int j = 0; + while (path_start[j] && path_start[j] != ' ' && path_start[j] != '\t') { + filename[j] = path_start[j]; + j++; } - filename[i] = 0; + filename[j] = 0; - if (fat32_delete(filename)) { - cli_write("Deleted: "); - cli_write(filename); - cli_write("\n"); + if (recursive) { + if (rm_recursive(filename)) { + cli_write("Deleted recursively: "); + cli_write(filename); + cli_write("\n"); + } else { + cli_write("Error: Cannot delete "); + cli_write(filename); + cli_write("\n"); + } } else { - cli_write("Error: Cannot delete file\n"); + if (fat32_is_directory(filename)) { + cli_write("Error: Is a directory. Use -r to delete.\n"); + } else { + if (fat32_delete(filename)) { + cli_write("Deleted: "); + cli_write(filename); + cli_write("\n"); + } else { + cli_write("Error: Cannot delete file\n"); + } + } } } diff --git a/src/kernel/cli_apps/reboot.c b/src/kernel/cli_apps/reboot.c index 6b165ad..c022fe5 100644 --- a/src/kernel/cli_apps/reboot.c +++ b/src/kernel/cli_apps/reboot.c @@ -1,11 +1,38 @@ #include "cli_utils.h" #include "io.h" +struct idtr_t { + uint16_t limit; + uint64_t base; +} __attribute__((packed)); + void cli_cmd_reboot(char *args) { (void)args; cli_write("Rebooting...\n"); - cli_sleep(100); - while ((inb(0x64) & 2) != 0) cli_sleep(1); + + + for (int i = 0; i < 100; i++) { + if ((inb(0x64) & 1) != 0) (void)inb(0x60); + cli_delay(10000); + } + + // Pulse reset line + for (int i = 0; i < 100; i++) { + uint8_t temp = inb(0x64); + if ((temp & 2) == 0) break; + cli_delay(10000); + } outb(0x64, 0xFE); - asm volatile ("int $0x3"); + cli_delay(5000000); // Wait for reset + + + struct idtr_t idtr_invalid = { 0, 0 }; + + asm volatile ("cli"); + asm volatile ("lidt %0" : : "m"(idtr_invalid)); + asm volatile ("int $3"); + + while(1) { + asm volatile ("hlt"); + } } diff --git a/src/kernel/cli_apps/shutdown.c b/src/kernel/cli_apps/shutdown.c index cb19079..6a56462 100644 --- a/src/kernel/cli_apps/shutdown.c +++ b/src/kernel/cli_apps/shutdown.c @@ -4,7 +4,7 @@ void cli_cmd_shutdown(char *args) { (void)args; cli_write("Shutting down...\n"); - cli_sleep(100); + cli_delay(5000000); outb(0x64, 0xFE); outw(0x604, 0x2000); outw(0xB004, 0x2000);