Changes by: aia21
Update of /cvs/linux-ntfs/ntfsprogs/ntfsprogs
In directory delta357:/tmp/cvs-serv8882/ntfsprogs
Modified Files:
ntfsresize.c
Log Message:
- 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)
Index: ntfsresize.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/ntfsprogs/ntfsresize.c,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -p -r1.124 -r1.125
--- ntfsresize.c 28 Nov 2006 10:09:57 -0000 1.124
+++ ntfsresize.c 28 Nov 2006 11:00:53 -0000 1.125
@@ -2359,6 +2359,13 @@ static void check_cluster_allocation(ntf
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;
|