1
0
mirror of https://github.com/Zygo/bees.git synced 2025-05-17 13:25:45 +02:00

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 <bees@furryterror.org>
This commit is contained in:
Zygo Blaxell 2025-01-27 11:39:36 -05:00
parent f6908420ad
commit 440740201a

View File

@ -703,9 +703,8 @@ bees_main(int argc, char *argv[])
shared_ptr<BeesContext> bc = make_shared<BeesContext>();
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<BeesRoots::ScanMode>(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);