sbin/hammer: Fix writeback against readonly fd
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Wed, 9 Mar 2016 15:03:02 +0000 (00:03 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sat, 19 Mar 2016 19:42:38 +0000 (04:42 +0900)
commitd4cbc307463efaefacabb1dfe36d7c4b215839a1
tree2335a116c95ebe25e9bc7470e82b0aece3cc59f7
parent5356b6e3ee79a952d7bd36a3eecf2c0b75fafccd
sbin/hammer: Fix writeback against readonly fd

writehammerbuf() needs to return 0 before it attempts to write
if the fd is readonly. Without this check flush_all_volumes()
may fail before all modified volume headers are written back
to the backing storage.

The only reason this hasn't become an issue so far is because
no existing hammer command creates readonly volume_info while
there are rw volume_info that need to be written back, which
could happen depending on the purpose of commands.
sbin/hammer/hammer_util.h
sbin/hammer/ondisk.c