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

Function IsEroFS

Source/Common/FileFormatCheck.cpp:52–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52bool IsEroFS(const fextl::string& Filename) {
53 // v1 of EroFS has a 128byte header
54 // This lives within a fixed offset inside of the first superblock of the file
55 // Each superblock is 4096bytes
56 //
57 // We only care about the uint32_t at the start of this offset which is the cookie
58 struct EroFSHeader {
59 uint32_t Magic;
60 // Additional data after this if necessary in the future.
61 };
62
63 constexpr size_t HEADER_OFFSET = 1024;
64 constexpr uint32_t COOKIE_MAGIC_V1 = 0xE0F5E1E2;
65
66 EroFSHeader Header {};
67 int fd = open(Filename.c_str(), O_RDONLY | O_CLOEXEC);
68 if (fd == -1) {
69 return false;
70 }
71
72 if (pread(fd, reinterpret_cast<char*>(&Header), sizeof(EroFSHeader), HEADER_OFFSET) != sizeof(EroFSHeader)) {
73 close(fd);
74 return false;
75 }
76
77 close(fd);
78
79 return Header.Magic == COOKIE_MAGIC_V1;
80}
81} // namespace FEX::FormatCheck

Callers 3

UnmountRootFSFunction · 0.85
InitializeSquashFSFunction · 0.85
ReloadMethod · 0.85

Calls 1

closeFunction · 0.85

Tested by

no test coverage detected