You can now delete folders with rm -r >folder< and the restart and shutdown commands now work again :D
This commit is contained in:
Chris 2026-02-13 14:17:21 +01:00
parent 60ea9defc0
commit 22b99e051d
11 changed files with 124 additions and 17 deletions

BIN
.DS_Store vendored

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,5 +1,5 @@
# BoredOS 1.50 Beta # BoredOS 1.50
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 has now exited Beta stage and is "stable enough" to be put out as a "stable" product.
<img src="bored.svg" width="200" /> </br> <img src="bored.svg" width="200" /> </br>
BoredOS is a simple x86_64 hobbyist operating system. BoredOS is a simple x86_64 hobbyist operating system.

Binary file not shown.

View file

@ -106,20 +106,98 @@ 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) { void cli_cmd_rm(char *args) {
if (!args || args[0] == 0) { if (!args || args[0] == 0) {
cli_write("Usage: rm <filename>\n"); cli_write("Usage: rm [-r] <path>\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] <path>\n");
return; return;
} }
char filename[256]; char filename[256];
int i = 0; int j = 0;
while (args[i] && args[i] != ' ' && args[i] != '\t') { while (path_start[j] && path_start[j] != ' ' && path_start[j] != '\t') {
filename[i] = args[i]; filename[j] = path_start[j];
i++; j++;
} }
filename[i] = 0; filename[j] = 0;
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 {
if (fat32_is_directory(filename)) {
cli_write("Error: Is a directory. Use -r to delete.\n");
} else {
if (fat32_delete(filename)) { if (fat32_delete(filename)) {
cli_write("Deleted: "); cli_write("Deleted: ");
cli_write(filename); cli_write(filename);
@ -127,6 +205,8 @@ void cli_cmd_rm(char *args) {
} else { } else {
cli_write("Error: Cannot delete file\n"); cli_write("Error: Cannot delete file\n");
} }
}
}
} }
void cli_cmd_echo(char *args) { void cli_cmd_echo(char *args) {

View file

@ -1,11 +1,38 @@
#include "cli_utils.h" #include "cli_utils.h"
#include "io.h" #include "io.h"
struct idtr_t {
uint16_t limit;
uint64_t base;
} __attribute__((packed));
void cli_cmd_reboot(char *args) { void cli_cmd_reboot(char *args) {
(void)args; (void)args;
cli_write("Rebooting...\n"); 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); 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");
}
} }

View file

@ -4,7 +4,7 @@
void cli_cmd_shutdown(char *args) { void cli_cmd_shutdown(char *args) {
(void)args; (void)args;
cli_write("Shutting down...\n"); cli_write("Shutting down...\n");
cli_sleep(100); cli_delay(5000000);
outb(0x64, 0xFE); outb(0x64, 0xFE);
outw(0x604, 0x2000); outw(0x604, 0x2000);
outw(0xB004, 0x2000); outw(0xB004, 0x2000);