Skip to content

Commit

Permalink
FEXInterpreter: Punch through a /sys/fex/rootfs node
Browse files Browse the repository at this point in the history
Currently pressure-vessel does a bit of a bodge to get the x86 rootfs
path when running inside of FEX. It does this by opening `/.` which
works around our pseudo-overlayfs tracking. While this worked, it wasn't
guaranteed to work forever. With #4225 working to fix more issues around
how rootfs is laid out, it had to break this path (while adding a
workaround for it to keep working).

Give pressure-vessel a blessed path from the EmulatedFiles code paths to
get a real fd back to the x86 rootfs, that way if we break this code
path it is entirely our problem to fix.

Still need to have a conversation with upstream pressure-vessel to see
if they'll accept this path or if we need to do something different.

We can also use this same mechanism in the future if we want to expose
more FEX specific data to the application through this.
  • Loading branch information
Sonicadvance1 committed Dec 20, 2024
1 parent 1e827ec commit 67dbe4b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion External/fmt
Submodule fmt updated 52 files
+0 −6 .clang-format
+3 −5 .github/workflows/cifuzz.yml
+1 −1 .github/workflows/doc.yml
+36 −8 .github/workflows/lint.yml
+13 −15 .github/workflows/linux.yml
+2 −6 .github/workflows/macos.yml
+4 −4 .github/workflows/scorecard.yml
+9 −4 .github/workflows/windows.yml
+5 −11 CMakeLists.txt
+0 −109 ChangeLog.md
+0 −1 README.md
+12 −14 doc/api.md
+2 −2 doc/index.md
+5 −4 doc/syntax.md
+28 −17 include/fmt/args.h
+2,073 −1,932 include/fmt/base.h
+470 −376 include/fmt/chrono.h
+22 −20 include/fmt/color.h
+24 −46 include/fmt/compile.h
+46 −65 include/fmt/format-inl.h
+1,292 −1,099 include/fmt/format.h
+55 −43 include/fmt/os.h
+87 −34 include/fmt/ostream.h
+130 −107 include/fmt/printf.h
+129 −95 include/fmt/ranges.h
+45 −73 include/fmt/std.h
+57 −103 include/fmt/xchar.h
+1 −17 src/fmt.cc
+1 −4 src/format.cc
+11 −6 src/os.cc
+3 −35 support/mkdocs
+290 −311 support/python/mkdocstrings_handlers/cxx/__init__.py
+19 −4 test/CMakeLists.txt
+144 −122 test/base-test.cc
+15 −40 test/chrono-test.cc
+27 −1 test/compile-error-test/CMakeLists.txt
+12 −22 test/compile-test.cc
+2 −2 test/format-impl-test.cc
+26 −142 test/format-test.cc
+11 −19 test/gtest/gmock-gtest-all.cc
+10 −24 test/gtest/gmock/gmock.h
+3 −4 test/gtest/gtest/gtest.h
+0 −24 test/no-builtin-types-test.cc
+1 −1 test/os-test.cc
+13 −13 test/ranges-test.cc
+3 −3 test/scan-test.cc
+5 −5 test/scan.h
+2 −18 test/std-test.cc
+1 −1 test/test-assert.h
+1 −1 test/unicode-test.cc
+5 −4 test/util.cc
+105 −15 test/xchar-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,12 @@ EmulatedFDManager::EmulatedFDManager(FEXCore::Context::Context* ctx)
fextl::string procCmdLine = fextl::fmt::format("/proc/{}/cmdline", getpid());
FDReadCreators[procCmdLine] = cmdline_handler;

// FEX-Emu specific file handles
FDReadCreators["/sys/fex/rootfs"] = [&](FEXCore::Context::Context* ctx, int32_t fd, const char* pathname, int32_t flags, mode_t mode) -> int32_t {
// Redirect to the guest rootfs
return ::syscall(SYSCALL_DEF(openat), fd, LDPath().c_str(), flags, mode);
};

if (ThreadsConfig > 1) {
cpus_online = fextl::fmt::format("0-{}", ThreadsConfig - 1);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,7 @@ class EmulatedFDManager {

static int32_t ProcAuxv(FEXCore::Context::Context* ctx, int32_t fd, const char* pathname, int32_t flags, mode_t mode);
const uint32_t ThreadsConfig;

FEX_CONFIG_OPT(LDPath, ROOTFS);
};
} // namespace FEX::EmulatedFile

0 comments on commit 67dbe4b

Please sign in to comment.