Changes by: antona
Update of /cvsroot/linux-ntfs/linux-ntfs/ntfstools
In directory usw-pr-cvs1:/tmp/cvs-serv25870/ntfstools
Modified Files:
mkntfs.c ntfslabel.c
Log Message:
Fixup the force option in mkntfs.c. Change the ntfs_check_if_mounted so it works on system not implementing {set,get,end}mntent, too. Also make it more powerful in telling us not only if something is mounted but also if it is the fs root and if it is read-only.
Index: mkntfs.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/ntfstools/mkntfs.c,v
retrieving revision 1.72
retrieving revision 1.73
diff -U2 -r1.72 -r1.73
--- mkntfs.c 23 Apr 2002 19:37:18 -0000 1.72
+++ mkntfs.c 23 Apr 2002 23:27:33 -0000 1.73
@@ -91,7 +91,4 @@
(m) == SCSI_CDROM_MAJOR)
#endif
-#ifdef HAVE_MNTENT_H
-# include <mntent.h>
-#endif
#include <limits.h>
@@ -2671,4 +2668,5 @@
char *sd;
NTFS_BOOT_SECTOR *bs;
+ unsigned long mnt_flags;
/* Initialize the random number generator with the current time. */
@@ -2728,8 +2726,15 @@
#endif
/* Make sure the file system is not mounted. */
- if (ntfs_check_if_mounted(vol->dev_name)==1){
- err_exit("Device is mounted!\n");
+ if (ntfs_check_if_mounted(vol->dev_name, &mnt_flags))
+ Eprintf("Failed to determine whether %s is mounted: %s\n",
+ vol->dev_name, strerror(errno));
+ else if (mnt_flags & NTFS_MF_MOUNTED) {
+ Eprintf("%s is mounted.\n", vol->dev_name);
+ if (!opt.force)
+ err_exit("Refusing to make a filesystem here!\n");
+ fprintf(stderr, "mkntfs forced anyway. Hope /etc/mtab is "
+ "incorrect.\n");
}
-
+
/* Open the device for reading or reading and writing. */
if (opt.no_action) {
Index: ntfslabel.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/ntfstools/ntfslabel.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -U2 -r1.7 -r1.8
--- ntfslabel.c 23 Apr 2002 19:37:18 -0000 1.7
+++ ntfslabel.c 23 Apr 2002 23:27:33 -0000 1.8
@@ -52,6 +52,4 @@
void change_label(const char *dev, const char *label);
-int check_mount(const char *file);
-
int resize_resident_attribute_value(MFT_RECORD *m, ATTR_RECORD *a, const __u32 new_vsize);
@@ -104,9 +102,10 @@
int err;
+ unsigned long mnt_flags;
/* We should first make sure it is a valid block device */
- err = ntfs_check_if_mounted(dev);
- if (err == -1){
- if(errno = ENODEV){
+ err = ntfs_check_if_mounted(dev, &mnt_flags);
+ if (err){
+ if(errno == ENODEV){
printf("Error: %s is not a valid block device!\n",dev);
exit(1);
@@ -148,17 +147,17 @@
ntfs_attr_search_ctx *ctx = NULL;
int err;
+ unsigned long mnt_flags;
printf("now changing label - FIXME: Not implemented yet!\n");
/*First we need to make sure the device is not mounted*/
- err = ntfs_check_if_mounted(dev);
+ err = ntfs_check_if_mounted(dev, &mnt_flags);
- if (err == -1){
+ if (err){
if(errno == ENODEV){
printf("Error: %s is not a valid block device!\n",dev);
exit(1);
}
- }
- if (err == 1){
+ } else if (mnt_flags & NTFS_MF_MOUNTED){
printf("Error: %s is already mounted!\n",dev);
exit(1);
@@ -312,6 +311,6 @@
*/
if (size != ((size + 7) & ~7)) {
- Eprintf("make_room_for_attribute() received non 8-byte aligned"
- "size.\n");
+ fprintf(stderr, "make_room_for_attribute() received non "
+ "8-byte aligned size.\n");
return -EINVAL;
}
|