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
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
-#include <syscall.h>
+#include <sys/mount.h>
#include <errno.h>
static void show_mounts(void) {
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;
* 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;
}