Changes by: szaka
Update of /cvsroot/linux-ntfs/linux-ntfs/ntfstools
In directory usw-pr-cvs1:/tmp/cvs-serv15049/ntfstools
Modified Files:
ntfsresize.c
Log Message:
Check if device mounted. Progress only if it's not or both ntfsresize
operation is read-only and device mounted read-only
Index: ntfsresize.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/ntfstools/ntfsresize.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -U2 -r1.11 -r1.12
--- ntfsresize.c 12 Jul 2002 12:38:54 -0000 1.11
+++ ntfsresize.c 14 Jul 2002 14:48:51 -0000 1.12
@@ -162,4 +162,8 @@
perr_exit("Couldn't open /dev/null");
+ /* If '-c clusters' isn't given then we mount read-only. opt.size = 0
+ basically means "give advice where volume could be resized. */
+ if (!opt.size)
+ opt.ro_flag = MS_RDONLY;
}
@@ -349,5 +353,5 @@
for (i = 0; rl[i].length; i++)
if (rl[i].lcn != LCN_HOLE)
- err_exit("Volume has bad sectors, not supported\n");
+ err_exit("Device has bad sectors, not supported\n");
free(rl);
@@ -610,8 +614,21 @@
{
struct bitmap on_disk_lcn_bitmap;
+ unsigned long mntflag;
int i;
parse_options(argc, argv);
+ if (ntfs_check_if_mounted(opt.volume, &mntflag))
+ perr_exit("Failed to check '%s' mount state", opt.volume);
+
+ if (mntflag & NTFS_MF_MOUNTED) {
+ if (!(mntflag & NTFS_MF_READONLY))
+ err_exit("Device %s is mounted read-write. "
+ "You must umount it first.\n", opt.volume);
+ if (!opt.ro_flag)
+ err_exit("Device %s is mounted. "
+ "You must umount it first.\n", opt.volume);
+ }
+
if (!(vol = ntfs_mount(opt.volume, opt.ro_flag)))
perr_exit("ntfs_mount failed");
@@ -662,5 +679,5 @@
/* FIXME: "call" ntfsfix: set the volume dirty, delete log, etc */
- printf("NTFS had been resized on volume %s. "
+ printf("NTFS had been resized on device %s. "
"Please run 'ntfsfix' on it.\n", vol->dev_name);
|