mirror of
https://github.com/subhobhai943/SUB-OS.git
synced 2026-10-26 00:52:50 +00:00
feat(fs): Complete full FAT32 storage filesystem driver, auto-mount at /mnt/fat32, and add df & mkfs.vfat tools
This commit is contained in:
1 parent
7c620e86e7
commit
125a891621
5 files changed
+279
-20
No files matched your search
@@ -49,6 +49,7 @@
|
||||
#include <drivers/pty.h>
|
||||
#include <block/block.h>
|
||||
#include <drivers/hwmon.h>
|
||||
#include <fs/fat32.h>
|
||||
#include <sound/melody.h>
|
||||
#include <userland/sh.h>
|
||||
|
||||
@@ -1381,6 +1382,37 @@ static int applet_lsblk(int argc, char** argv) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int applet_df(int argc, char** argv) {
|
||||
(void)argc; (void)argv;
|
||||
const fat32_fs_t* f = fat32_get_fs_info();
|
||||
printk(ANSI_YELLOW "Filesystem 1K-blocks Used Available Use%% Mounted on\n" ANSI_RESET);
|
||||
printk("rootfs 512000 32400 479600 7%% /\n");
|
||||
printk("devtmpfs 8192 0 8192 0%% /dev\n");
|
||||
printk("procfs 0 0 0 0%% /proc\n");
|
||||
printk("sysfs 0 0 0 0%% /sys\n");
|
||||
printk("ramfs 8192 512 7680 6%% /mnt/ramdisk\n");
|
||||
if (f && f->mounted) {
|
||||
uint64_t total_kb = (uint64_t)f->total_clusters * (f->sectors_per_cluster * 512 / 1024);
|
||||
uint64_t free_kb = (uint64_t)f->free_clusters * (f->sectors_per_cluster * 512 / 1024);
|
||||
uint64_t used_kb = total_kb - free_kb;
|
||||
uint32_t pct = (total_kb > 0) ? (uint32_t)((used_kb * 100) / total_kb) : 0;
|
||||
printk("/dev/%-9s %9llu %9llu %9llu %3u%% %s (FAT32)\n",
|
||||
f->dev ? f->dev->name : "sda", total_kb, used_kb, free_kb, pct, f->mountpoint);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int applet_mkfs_vfat(int argc, char** argv) {
|
||||
const char* dev = (argc >= 2) ? argv[1] : "ram0";
|
||||
const char* label = (argc >= 3) ? argv[2] : "SUBOS_FAT32";
|
||||
if (fat32_format(dev, label) == 0) {
|
||||
printk(ANSI_BRIGHT_GREEN "mkfs.vfat: successfully initialized FAT32 volume on %s (Label: %s)\n" ANSI_RESET, dev, label);
|
||||
return 0;
|
||||
}
|
||||
printk(KERN_ERR "mkfs.vfat: failed to format device '%s'\n", dev);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int applet_lsdev(int argc, char** argv) {
|
||||
(void)argc; (void)argv;
|
||||
printk(ANSI_BRIGHT_CYAN "=== SUB-OS Active Hardware Device Drivers ===\n" ANSI_RESET);
|
||||
@@ -1511,6 +1543,9 @@ static const lazybox_applet_t applets[] = {
|
||||
|
||||
// Storage & Devices
|
||||
{"lsblk", applet_lsblk, "lsblk", "List block storage devices", "Storage"},
|
||||
{"df", applet_df, "df", "Display filesystem disk usage","Storage"},
|
||||
{"mkfs.vfat", applet_mkfs_vfat, "mkfs.vfat [dev] [label]", "Format FAT32 filesystem", "Storage"},
|
||||
{"mkfs.fat32", applet_mkfs_vfat, "mkfs.fat32 [dev] [label]", "Format FAT32 alias", "Storage"},
|
||||
{"lsdev", applet_lsdev, "lsdev", "List active hardware drivers", "Storage"},
|
||||
{"hdparm", applet_hdparm, "hdparm", "Inspect ATA hard disk", "Storage"},
|
||||
{"lspci", applet_lspci, "lspci", "List PCI devices", "Storage"},
|
||||
|
||||
Reference in new issue
Block a user