init: log resolved datadir path when it differs #36373

pull LarryRuane wants to merge 1 commits into bitcoin:master from LarryRuane:2026-09-datadir-realpath changing 1 files +9 −1
  1. LarryRuane commented at 5:42 PM on September 28, 2026: contributor

    If the data directory (or a parent) is a symlink, also log the path it resolves to, so debug.log files show the actual location for that run.

    This patch would mostly help developers. I've been testing a potential performance PR across different data directories (for example, SSD versus HDD). Yes, we can specify -datadir= on the command line, but if a script starts bitcoind (e.g., on an RPi with a whole infrastructure, like Umbrel or myNode), changing the startup command arguments may be inconvenient or not even possible. But it's easy to change the default directory to be a symlink.

    If the resolved directory matches the specified directory, there's no need to log both (so no change from today). On macOS, /tmp and /var are symlinks into /private, so a datadir under those (like the functional test temp dirs) would show both.

    I don't think a separate test is needed. I haven't tested on all platforms, but this patch uses primitives already used elsewhere, so it should work everywhere.

    Here's a before and after example; this line occurs within the first few lines after startup (omitting the timestamp prefix):

    - Using data directory /home/larry/.bitcoin
    + Using data directory /home/larry/.bitcoin (/sd/.bitcoin)
    
  2. init: log resolved datadir path when it differs
    If the data directory (or a parent) is a symlink, also log the path
    it resolves to. This makes saved debug.log files record where the
    data actually lived for that run.
    3b43b3d2a3
  3. DrahtBot commented at 5:42 PM on September 28, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process. A summary of reviews will appear here.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. LarryRuane commented at 8:03 PM on October 3, 2026: contributor

    A better approach might be to print a separate line, instead of changing the existing one, in case there are scripts out there that grep for that line and extract the directory path by cutting everything up to a particular column (or taking everything after the third token). So the resolved path could immediately follow the line Using path:

    Resolved data directory /sd/.bitcoin
    

    I'd recommend always printing that line (not only if it differs from the nominal path) to simplify scripts that want to grab the resolved path (they don't have to search for "Resolved..." and, if not found, revert to "Using..."). Not much harm in printing one extra line.

Contributors

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-10-04 01:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me