wasmfs_unmount is similar to __syscall_unlinkat, but assumes AT_REMOVEDIR is true and will only unlink mountpoints (Empty and nonempty).
| 876 | // wasmfs_unmount is similar to __syscall_unlinkat, but assumes AT_REMOVEDIR is |
| 877 | // true and will only unlink mountpoints (Empty and nonempty). |
| 878 | int wasmfs_unmount(const char* path) { |
| 879 | auto parsed = path::parseParent(path, AT_FDCWD); |
| 880 | if (auto err = parsed.getError()) { |
| 881 | return err; |
| 882 | } |
| 883 | auto& [parent, childNameView] = parsed.getParentChild(); |
| 884 | std::string childName(childNameView); |
| 885 | auto lockedParent = parent->locked(); |
| 886 | auto file = lockedParent.getChild(childName); |
| 887 | if (!file) { |
| 888 | return -ENOENT; |
| 889 | } |
| 890 | // Disallow removing the root directory, even if it is empty. |
| 891 | if (file == wasmFS.getRootDirectory()) { |
| 892 | return -EBUSY; |
| 893 | } |
| 894 | |
| 895 | if (!file->dynCast<Directory>()) { |
| 896 | // A normal file or symlink. |
| 897 | return -ENOTDIR; |
| 898 | } |
| 899 | |
| 900 | if (parent->getBackend() == file->getBackend()) { |
| 901 | // The child is not a valid mountpoint. |
| 902 | return -EINVAL; |
| 903 | } |
| 904 | |
| 905 | // Input is valid, perform the unlink. |
| 906 | return lockedParent.removeChild(childName); |
| 907 | } |
| 908 | |
| 909 | int __syscall_getdents64(int fd, void* dirp, size_t count) { |
| 910 | dirent* result = (dirent*)dirp; |
nothing calls this directly
no test coverage detected