MCPcopy Create free account
hub / github.com/FEX-Emu/FEX / UnmountRootFS

Function UnmountRootFS

Source/Tools/FEXServer/SquashFS.cpp:191–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189}
190
191void 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
230bool InitializeSquashFS() {
231 FEX_CONFIG_OPT(LDPath, ROOTFS);

Callers 1

mainFunction · 0.85

Calls 6

IsSquashFSFunction · 0.85
IsEroFSFunction · 0.85
ShutdownImagePIDFunction · 0.85
fprintfFunction · 0.85
exitFunction · 0.85
GetServerRootFSLockFileFunction · 0.85

Tested by

no test coverage detected