]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commitdiff
Fix mount/umount commands: use proper syscall wrappers and error messages
authorTulio A M Mendes <[email protected]>
Sun, 19 Apr 2026 18:23:01 +0000 (15:23 -0300)
committerTulio A M Mendes <[email protected]>
Sun, 19 Apr 2026 18:23:01 +0000 (15:23 -0300)
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

user/cmds/mount/mount.c
user/cmds/umount/umount.c

index f7e5db2fe575f5c347fbaa1e2618ce548f1b9758..0b7ed397bd89e6dcc66ed86b4283b83403de97d9 100644 (file)
@@ -12,7 +12,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <fcntl.h>
-#include <syscall.h>
+#include <sys/mount.h>
 #include <errno.h>
 
 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;
index 16b9f5156334256e5f3011cbc29471fb9a80a645..3d649c43e8236780eb928eaa6fbf011f6928f62f 100644 (file)
@@ -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 <stdio.h>
+#include <string.h>
+#include <sys/mount.h>
+#include <errno.h>
 
 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;
 }