From: Tulio A M Mendes Date: Sun, 19 Apr 2026 18:23:01 +0000 (-0300) Subject: Fix mount/umount commands: use proper syscall wrappers and error messages X-Git-Url: https://projects.tadryanom.me/?a=commitdiff_plain;h=c559f0125b8119b7b5f2564e08cbe91dcfedb395;p=AdrOS.git Fix mount/umount commands: use proper syscall wrappers and error messages mount.c: Replace direct _syscall3 call with mount() wrapper from sys/mount.h. Print strerror(errno) instead of raw -1 return value from __syscall_ret, which was always -1 and unhelpful for debugging. umount.c: Replace stub that always printed 'operation not supported' with a working implementation using the umount() wrapper from sys/mount.h. The SYS_UMOUNT2 syscall existed in the kernel but the umount command never used it. Tests: 103/103 PASS --- diff --git a/user/cmds/mount/mount.c b/user/cmds/mount/mount.c index f7e5db2f..0b7ed397 100644 --- a/user/cmds/mount/mount.c +++ b/user/cmds/mount/mount.c @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include static void show_mounts(void) { @@ -57,9 +57,9 @@ int main(int argc, char** argv) { return 1; } - int rc = __syscall_ret(_syscall3(SYS_MOUNT, (int)device, (int)mountpoint, (int)fstype)); + int rc = mount(device, mountpoint, fstype, 0, NULL); if (rc < 0) { - fprintf(stderr, "mount: mounting %s on %s failed: %d\n", device, mountpoint, rc); + fprintf(stderr, "mount: mounting %s on %s failed: %s\n", device, mountpoint, strerror(errno)); return 1; } return 0; diff --git a/user/cmds/umount/umount.c b/user/cmds/umount/umount.c index 16b9f515..3d649c43 100644 --- a/user/cmds/umount/umount.c +++ b/user/cmds/umount/umount.c @@ -7,14 +7,20 @@ * Source: https://github.com/tadryanom/AdrOS */ -/* AdrOS umount utility — stub (no SYS_UMOUNT syscall yet) */ +/* AdrOS umount utility — unmount filesystems */ #include +#include +#include +#include int main(int argc, char** argv) { if (argc <= 1) { fprintf(stderr, "umount: missing operand\n"); return 1; } - fprintf(stderr, "umount: %s: operation not supported\n", argv[1]); - return 1; + if (umount(argv[1]) < 0) { + fprintf(stderr, "umount: %s: %s\n", argv[1], strerror(errno)); + return 1; + } + return 0; }