- Fix ntfsresize to unmount the volume when finished/exiting so it does

not leave the volume in an inconsistent state.  Somewhat crude
  solution using atexit() but it works...  (Anton)
This commit is contained in:
aia21 2006-11-28 11:00:52 +00:00
parent 5302d23f7b
commit a32aa26d0b
2 changed files with 18 additions and 1 deletions

View File

@ -84,6 +84,12 @@ xx/xx/2006 - x.xx.x - .
- Set the volume dirty bit at mount time (if it is not set already and
clear it again at umount time but only if it was not set to start
with. (Anton)
- Introduce NTFS_MNT_FORENSIC mount option for logfile dumping for
example otherwise the logfile gets wiped out by the mount attempt if
it is not read-only. (Anton)
- Fix ntfsresize to unmount the volume when finished/exiting so it does
not leave the volume in an inconsistent state. Somewhat crude
solution using atexit() but it works... (Anton)
21/06/2006 - 1.13.1 - Various fixes.

View File

@ -2359,6 +2359,13 @@ static void check_cluster_allocation(ntfs_volume *vol, ntfsck_t *fsck)
compare_bitmaps(vol, &fsck->lcn_bitmap);
}
static ntfs_volume *g_vol;
static void ntfsresize_atexit(void) {
if (g_vol && ntfs_umount(g_vol, 0) < 0)
perror("Failed to unmount volume");
}
int main(int argc, char **argv)
{
ntfsck_t fsck;
@ -2377,8 +2384,12 @@ int main(int argc, char **argv)
utils_set_locale();
if ((vol = mount_volume()) == NULL)
g_vol = NULL;
if (atexit(ntfsresize_atexit))
err_exit("Failed to register exit handler!");
if (!(vol = mount_volume()))
err_exit("Couldn't open volume '%s'!\n", opt.volume);
g_vol = vol;
device_size = ntfs_device_size_get(vol->dev, vol->sector_size);
device_size *= vol->sector_size;