status_t mount(const char device[], const char dir[], const char type[], int, char*) { int error; int devfd = -1; if (strlen(device) > 0) { devfd = open(device, 0); if (devfd < 0) { printf("mount: error opening device\n"); return E_NO_SUCH_FILE; } } VNode *node; error = FileSystem::WalkPath(dir, strlen(dir), &node); if (error < 0) { printf("mount: mount point does not exist\n"); close_handle(devfd); return error; } if (node->GetCoveredBy() != 0) { // Attempting to re-mount an already mounted directory printf("mount: filesystem already mounted at this point\n"); node->ReleaseRef(); close_handle(devfd); return E_NOT_ALLOWED; } FileSystem *fs; error = FileSystem::InstantiateFsType(type, devfd, &fs); if (error < 0) { node->ReleaseRef(); close_handle(devfd); return error; } node->CoverWith(fs); fs->Cover(node); return 0; }