Changes by: szaka
Update of /cvsroot/linux-ntfs/linux-ntfs/ntfstools
In directory usw-pr-cvs1:/tmp/cvs-serv10811
Modified Files:
ntfsresize.c
Log Message:
Quit if mounted volume is dirty unless -f (force) option was given
Index: ntfsresize.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/ntfstools/ntfsresize.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -U2 -r1.7 -r1.8
--- ntfsresize.c 11 Jul 2002 09:02:26 -0000 1.7
+++ ntfsresize.c 11 Jul 2002 12:49:48 -0000 1.8
@@ -49,4 +49,5 @@
int debug;
int ro_flag;
+ int force;
s64 size;
char *volume;
@@ -108,9 +109,11 @@
void usage(char *s)
{
- printf ("Usage: %s [-nv] [-c clusters] device\n", s);
- printf (" -n No write operations (read-only mode)\n");
- printf (" -v Verbose operation\n");
+ printf ("Usage: %s [-fhnv] [-c clusters] device\n", s);
printf (" -c clusters New NTFS size in clusters\n");
Dprintf(" -d Show debug information\n");
+ printf (" -f Force to progress (DANGEROUS)\n");
+ printf (" -h This help text\n");
+ printf (" -n No write operations (read-only mode)\n");
+ printf (" -v Verbose operation\n");
exit(1);
}
@@ -124,12 +127,6 @@
memset(&opt, 0, sizeof(opt));
- while ((i = getopt(argc, argv, "nvc:d")) != EOF)
+ while ((i = getopt(argc, argv, "c:dfhnv")) != EOF)
switch (i) {
- case 'n':
- opt.ro_flag = MS_RDONLY;
- break;
- case 'v':
- opt.verbose++;
- break;
case 'c':
opt.size = strtoll(optarg, &s, 0);
@@ -140,4 +137,15 @@
opt.debug = 1;
break;
+ case 'f':
+ opt.force++;
+ break;
+ case 'h':
+ usage(argv[0]);
+ case 'n':
+ opt.ro_flag = MS_RDONLY;
+ break;
+ case 'v':
+ opt.verbose++;
+ break;
default:
usage(argv[0]);
@@ -228,4 +236,5 @@
perr_exit("ntfs_lookup_attr");
+ /* FIXME: get_attribute_value_length() can't handle extents */
bm->size = get_attribute_value_length(ctx->attr);
@@ -358,10 +367,8 @@
* must be set. This region also encompasses the backup boot sector.
*/
-void bitmap_file_data_fixup(s64 clusters, struct bitmap *bm)
+void bitmap_file_data_fixup(s64 cluster, struct bitmap *bm)
{
- s64 i;
-
- for (i = clusters; i < bm->size << 3; i++)
- ntfs_set_bit(bm->bm, (u64)i, 1);
+ for (; cluster < bm->size << 3; cluster++)
+ ntfs_set_bit(bm->bm, (u64)cluster, 1);
}
@@ -610,4 +617,9 @@
perr_exit("ntfs_mount failed");
+ if (vol->flags & VOLUME_IS_DIRTY)
+ if (!opt.force--)
+ err_exit("Volume is dirty. Run chkdsk and "
+ "please try again (or see -f option).\n");
+
printf("Cluster size : %u\n", vol->cluster_size);
printf("Number of clusters: %lld\n", vol->nr_clusters);
|