If there's a crash during kvtree_file_write(), it could result in a corrupted kvtree file (ECP-VeloC/AXL#83). @adammoody suggested that each kvtree_file_write() create a new file that gets rename()'d to the final filename. A rename() is atomic on Linux. This means that if there's a failure during the write, then kvtree_read_file() is going to return the kvtree state before the failed write rather than an error. We also may want to consider writing to the new kvtree file with O_DIRECT or O_ATOMIC for even more protection.