if (!out || out_size == 0) return;
if (source_name && source_name[0] != '\0') {
+ if (!bdev) {
+ strncpy(out, source_name, out_size - 1);
+ out[out_size - 1] = '\0';
+ return;
+ }
+
if (strncmp(source_name, "/dev/", 5) == 0) {
strncpy(out, source_name, out_size - 1);
out[out_size - 1] = '\0';
return -EINVAL;
}
+ if ((fst->flags & FS_NEEDS_BDEV) && !bdev) {
+ kprintf("[MOUNT] Filesystem %s requires a block device\n", fstype);
+ return -ENODEV;
+ }
+
char devname[32];
init_build_mount_source_name(source_name, bdev, devname, sizeof(devname));
}
kprintf("[MOUNT] %s on /dev/%s -> %s\n",
- fstype, bdev ? bdev->name : "?",
+ fstype, devname,
mountpoint);
return 0;
}
* mounts ensure the system is functional. */
{
int rc;
+ rc = vfs_mkdir("/tmp");
+ if (rc < 0 && rc != -EEXIST) kprintf("[INIT] mkdir /tmp failed: %d\n", rc);
rc = vfs_mkdir("/dev");
if (rc < 0 && rc != -EEXIST) kprintf("[INIT] mkdir /dev failed: %d\n", rc);
rc = vfs_mkdir("/proc");
if (rc < 0 && rc != -EEXIST) kprintf("[INIT] mkdir /disk failed: %d\n", rc);
}
- fs_node_t* tmp = tmpfs_create_root();
- if (tmp) {
- (void)vfs_mount_full("/tmp", tmp, "tmpfs", "none", 0, NULL, NULL);
- }
+ (void)init_mount_fs("tmpfs", NULL, 0, "/tmp", 0, "none");
/* Register hardware drivers with HAL and init in priority order */
pci_driver_register(); /* priority 10: bus */
* (including fulltest) has /dev available. When /sbin/init runs
* it re-mounts devfs via mount() syscall; vfs_mount replaces the
* existing entry so this is a harmless overlap. */
- fs_node_t* dev = devfs_create_root();
- if (dev) {
- (void)vfs_mount_full("/dev", dev, "devfs", "none", 0, NULL, NULL);
- }
+ (void)init_mount_fs("devfs", NULL, 0, "/dev", 0, "none");
vbe_register_devfs();
keyboard_register_devfs();
- fs_node_t* proc = procfs_create_root();
- if (proc) {
- (void)vfs_mount_full("/proc", proc, "procfs", "none", 0, NULL, NULL);
- }
+ (void)init_mount_fs("procfs", NULL, 0, "/proc", 0, "none");
/* Initialize ATA subsystem — probe all 4 drives
* (primary/secondary x master/slave). */
block_device_t* bdev = NULL;
uint32_t lba = 0;
- if (init_resolve_mount_device(device, &bdev, &lba) < 0) {
- kprintf("mount: unknown device: %s\n", device);
- return;
+ if (strcmp(fstype, "tmpfs") != 0 && strcmp(fstype, "devfs") != 0 && strcmp(fstype, "procfs") != 0) {
+ if (init_resolve_mount_device(device, &bdev, &lba) < 0) {
+ kprintf("mount: unknown device: %s\n", device);
+ return;
+ }
}
(void)init_mount_fs(fstype, bdev, lba, mountpoint, 0, device);
if (!mp_node) { sc_ret(regs) = (uint32_t)-ENOENT; return; }
if (!(mp_node->flags & FS_DIRECTORY)) { sc_ret(regs) = (uint32_t)-ENOTDIR; return; }
- /* Virtual filesystems — no device argument needed */
- if (strcmp(ktype, "tmpfs") == 0) {
- fs_node_t* tmp = tmpfs_create_root();
- if (!tmp) { sc_ret(regs) = (uint32_t)-ENOMEM; return; }
- sc_ret(regs) = (uint32_t)vfs_mount_full(kmp, tmp, "tmpfs", kdev, mount_flags, NULL, NULL);
- return;
- }
- if (strcmp(ktype, "devfs") == 0) {
- extern fs_node_t* devfs_create_root(void);
- fs_node_t* dev = devfs_create_root();
- if (!dev) { sc_ret(regs) = (uint32_t)-ENOMEM; return; }
- sc_ret(regs) = (uint32_t)vfs_mount_full(kmp, dev, "devfs", kdev, mount_flags, NULL, NULL);
- return;
- }
- if (strcmp(ktype, "procfs") == 0) {
- extern fs_node_t* procfs_create_root(void);
- fs_node_t* proc = procfs_create_root();
- if (!proc) { sc_ret(regs) = (uint32_t)-ENOMEM; return; }
- sc_ret(regs) = (uint32_t)vfs_mount_full(kmp, proc, "procfs", kdev, mount_flags, NULL, NULL);
- return;
- }
-
block_device_t* bdev = NULL;
uint32_t lba = 0;
- if (init_resolve_mount_device(kdev, &bdev, &lba) < 0) {
- sc_ret(regs) = (uint32_t)-ENODEV;
- return;
+ if (strcmp(ktype, "tmpfs") != 0 && strcmp(ktype, "devfs") != 0 && strcmp(ktype, "procfs") != 0) {
+ if (init_resolve_mount_device(kdev, &bdev, &lba) < 0) {
+ sc_ret(regs) = (uint32_t)-ENODEV;
+ return;
+ }
}
int rc = init_mount_fs(ktype, bdev, lba, kmp, mount_flags, kdev);