FS#11883 - Close all files and safely unmount disks before entering USB mode, shutting down, or rebooting
The attached patch implements a clean disk unmount by way of the following changes:
Patch 1: Allow disk_unmount_all to close all files and flush dirty buffers when unmounting a filesystem. (Before, we've been calling disk_unmount, which does not flush buffers because it's written to handle user-ejected storage media that aren't accessible any more.)
Patch 2: Call disk_unmount_all in the power-down and reboot paths.
Patch 3: Fix write to detect a bad file handle.
(Split out from FS#11877, in which I first theorized that an unclean filesystem may be responsible for some filesystem corruption I'm seeing, but which turned out to be a deeper problem. Related to r28693 /