Changes by: szaka
Update of /cvsroot/linux-ntfs/linux-ntfs/ntfstools
In directory usw-pr-cvs1:/tmp/cvs-serv29302/ntfstools
Modified Files:
ntfsresize.c
Log Message:
Reserve space for backup boot sector at the end of device
Index: ntfsresize.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/ntfstools/ntfsresize.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -U2 -r1.12 -r1.13
--- ntfsresize.c 14 Jul 2002 14:48:51 -0000 1.12
+++ ntfsresize.c 14 Jul 2002 15:43:35 -0000 1.13
@@ -335,5 +335,6 @@
if (ntfs_get_bit(lcn_bitmap.bm, i))
break;
- if (++i >= vol->nr_clusters)
+ i += 2; /* first free + we reserve one for the backup boot sector */
+ if (i >= vol->nr_clusters)
exit(1);
err_exit("However, you could resize at cluster %lld gaining %lld MB.\n",
@@ -615,4 +616,5 @@
struct bitmap on_disk_lcn_bitmap;
unsigned long mntflag;
+ s64 new_volume_size; /* in clusters */
int i;
@@ -654,12 +656,20 @@
free(on_disk_lcn_bitmap.bm);
- /* FIXME: check/adjust opt.size validity */
+ /* FIXME: check opt.size validity */
- if (opt.size > vol->nr_clusters)
+ new_volume_size = opt.size;
+
+ /* Backup boot sector at the end of device isn't counted in NTFS
+ volume size thus we have to reserve space for. We don't trust
+ the user does this for us: better to be on the safe side ;) */
+ if (new_volume_size)
+ --new_volume_size;
+
+ if (new_volume_size > vol->nr_clusters)
err_exit("Volume enlargement not yet supported\n");
- else if (opt.size == vol->nr_clusters)
- exit(0); /* FIXME: backup boot sector not counted! */
+ else if (new_volume_size == vol->nr_clusters)
+ exit(0);
- for (i = opt.size; i < vol->nr_clusters; i++)
+ for (i = new_volume_size; i < vol->nr_clusters; i++)
if (ntfs_get_bit(lcn_bitmap.bm, (u64)i))
/* FIXME: relocate cluster */
@@ -672,10 +682,10 @@
perr_exit("Failed to reset $LogFile");
- truncate_badclust_file(opt.size);
- truncate_bitmap_file(opt.size);
- update_bootsector(opt.size);
+ truncate_badclust_file(new_volume_size);
+ truncate_bitmap_file(new_volume_size);
+ update_bootsector(new_volume_size);
/* FIXME: create backup boot sector -- if possible*/
- /* FIXME: "call" ntfsfix: set the volume dirty, delete log, etc */
+ /* FIXME: set the volume dirty */
printf("NTFS had been resized on device %s. "
|