Truncate existing raw files when writing
Currently, if a raw file exists, it is not truncated when opened for writing. If the existing file has a larger size, the leftover bytes at the end will be left there and further reading will lead to segvs due to the corrupted file.
This MR simply adds the O_TRUNC
flag to the open
call and a
test that verifies the correct behaviour.
Not sure if this should go to 2017-patches. It is useful for interactive use but should have no effect in production.
@frankm, please check.