From 440740201a46ffbc3db181d1984dfc85155f9b52 Mon Sep 17 00:00:00 2001 From: Zygo Blaxell Date: Mon, 27 Jan 2025 11:39:36 -0500 Subject: [PATCH] main: the base directory for `--strip-paths` should be root_fd, not cwd The cwd is where core dumps and various profiling and verification libraries want to write their data, whereas root_fd is the root of the target filesystem. These are often intentionally different. When they are different, `--strip-paths` sets the wrong prefix to strip from paths. Once the root fd has been established, we can set the path prefix to the string prefix that we'll get from future calls to `name_fd`. Signed-off-by: Zygo Blaxell --- src/bees.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/bees.cc b/src/bees.cc index e4a96ab..7d51651 100644 --- a/src/bees.cc +++ b/src/bees.cc @@ -703,9 +703,8 @@ bees_main(int argc, char *argv[]) shared_ptr bc = make_shared(); BEESLOGDEBUG("context constructed"); - string cwd(readlink_or_die("/proc/self/cwd")); - // Defaults + bool use_relative_paths = false; bool chatter_prefix_timestamp = true; double thread_factor = 0; unsigned thread_count = 0; @@ -777,7 +776,7 @@ bees_main(int argc, char *argv[]) thread_min = stoul(optarg); break; case 'P': - crucible::set_relative_path(cwd); + use_relative_paths = true; break; case 'T': chatter_prefix_timestamp = false; @@ -795,7 +794,7 @@ bees_main(int argc, char *argv[]) root_scan_mode = static_cast(stoul(optarg)); break; case 'p': - crucible::set_relative_path(""); + use_relative_paths = false; break; case 't': chatter_prefix_timestamp = true; @@ -865,6 +864,11 @@ bees_main(int argc, char *argv[]) BEESLOGNOTICE("setting root path to '" << root_path << "'"); bc->set_root_path(root_path); + // Set path prefix + if (use_relative_paths) { + crucible::set_relative_path(name_fd(bc->root_fd())); + } + // Workaround for btrfs send bc->roots()->set_workaround_btrfs_send(workaround_btrfs_send);