When only getting info for a wallet with the bitcoin-wallet tool, I was surprised to find it changing the file modification time (but happy that it didn’t also seem to modify the file contents):
0$ stat --format=%Y /tmp/test.dat ; sha256sum /tmp/test.dat
11552658778
28d932caabee0dc8d42c7ea362fb685325bd23f217557135282279f5b14233eec /tmp/test.dat
3
4$ bitcoin/src/bitcoin-wallet -wallet=/tmp/test.dat info
5Wallet info
6[...]
7
8$ stat --format=%Y /tmp/test.dat ; sha256sum /tmp/test.dat
91552658867
108d932caabee0dc8d42c7ea362fb685325bd23f217557135282279f5b14233eec /tmp/test.dat
Setting the file permissions to read-only also surprisingly causes the tool to fail:
0$ chmod 400 /tmp/test.dat
1$ bitcoin/src/bitcoin-wallet -wallet=/tmp/test.dat info
2Error loading /tmp/test.dat. Is wallet being used by another process?
It also fails on a read-only filesystem even if the permission bits are set to writable:
0$ chmod 600 /tmp/test.dat
1$ sudo mount -t tmpfs -o size=10000000 tmpfs /mnt
2$ sudo cp -a /tmp/test.dat /mnt
3$ sudo mount -o remount,ro /mnt
4$ bitcoin/src/bitcoin-wallet -wallet=/mnt/test.dat info
5Error loading /mnt/test.dat. Is wallet being used by other process?
6$ ls -lh /mnt/test.dat
7-rw------- 1 user user 1.4M Mar 15 10:07 /mnt/test.dat
I’d expect the tool to open files read-only when it doesn’t need to make any modifications in order to ensure it doesn’t make any modifications. Additionally, I’d expect the tool to be able to examine backup files that have been safeguarded by making them read-only in some way.
See also IRC discussion, including @laanwj mentioning a DB_RDONLY
flag.