| 189 | } |
| 190 | |
| 191 | void UnmountRootFS() { |
| 192 | FEX_CONFIG_OPT(LDPath, ROOTFS); |
| 193 | if (!FEX::FormatCheck::IsSquashFS(LDPath()) && !FEX::FormatCheck::IsEroFS(LDPath())) { |
| 194 | return; |
| 195 | } |
| 196 | |
| 197 | SquashFS::ShutdownImagePID(); |
| 198 | |
| 199 | // Handle final mount removal |
| 200 | // fusermount for unmounting the mountpoint, then the {erfsfuse, squashfuse} will exit automatically |
| 201 | int pid = fork(); |
| 202 | |
| 203 | if (pid == 0) { |
| 204 | const char* argv[5]; |
| 205 | argv[0] = "fusermount"; |
| 206 | argv[1] = "-u"; |
| 207 | argv[2] = "-q"; |
| 208 | argv[3] = MountFolder.c_str(); |
| 209 | argv[4] = nullptr; |
| 210 | |
| 211 | if (execvp(argv[0], (char* const*)argv) == -1) { |
| 212 | fprintf(stderr, "fusermount failed to execute. You may have an mount living at '%s' to clean up now\n", MountFolder.c_str()); |
| 213 | fprintf(stderr, "Try `%s %s %s %s`\n", argv[0], argv[1], argv[2], argv[3]); |
| 214 | exit(1); |
| 215 | } |
| 216 | } else { |
| 217 | // Wait for fusermount to leave |
| 218 | while (waitpid(pid, nullptr, 0) == -1 && errno == EINTR) |
| 219 | ; |
| 220 | |
| 221 | // Remove the mount path |
| 222 | rmdir(MountFolder.c_str()); |
| 223 | |
| 224 | // Remove the rootfs lock file |
| 225 | auto RootFSLockFile = FEXServerClient::GetServerRootFSLockFile(); |
| 226 | unlink(RootFSLockFile.c_str()); |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | bool InitializeSquashFS() { |
| 231 | FEX_CONFIG_OPT(LDPath, ROOTFS); |
no test coverage detected