I think a good way to do this is, first, wait for #27039 to merge. This prevents flushing to blk files that are already full (128 mb), but still has the problem that if all blk files are set to read-only, then when the system tries to write to and flush the last partial blk file, it fails.
Why not, when this error occurs, pretend the blk file is full (leave it partially filled) and go and create a brand new one (which would be read-write).
https://github.com/bitcoin/bitcoin/pull/26535
I think a good way to do this is, first, wait for #27039 to merge. This prevents flushing to blk files that are already full (128 mb), but still has the problem that if all blk files are set to read-only, then when the system tries to write to and flush the last partial blk file, it fails.
Why not, when this error occurs, pretend the blk file is full (leave it partially filled) and go and create a brand new one (which would be read-write).