Changes by: mattjf
Update of /cvsroot/linux-ntfs/linux-ntfs/ntfstools
In directory usw-pr-cvs1:/tmp/cvs-serv22375/ntfstools
Modified Files:
mkntfs.c ntfslabel.c
Log Message:
Removed the check_mount() function and added ntfs_check_if_mounted() to
mkntfs
Index: mkntfs.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/ntfstools/mkntfs.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -U2 -r1.71 -r1.72
--- mkntfs.c 22 Apr 2002 10:34:32 -0000 1.71
+++ mkntfs.c 23 Apr 2002 19:37:18 -0000 1.72
@@ -2444,67 +2444,6 @@
}
-#define NTFS_MF_MOUNTED 1
-#define NTFS_MF_ISROOT 2
-#define NTFS_MF_READONLY 4
-
-#ifdef HAVE_MNTENT_H
-/* Only check if the mount is readonly when it's the root filesystem. */
-int check_mntent(const char *file, int *mnt_flags)
-{
- FILE *m_f;
- struct mntent *mnt;
- int m_fd;
-
- *mnt_flags = 0;
- if ((m_f = setmntent(MOUNTED, "r")) == NULL)
- return -errno;
- while ((mnt = getmntent(m_f)) != NULL)
- if (strcmp(file, mnt->mnt_fsname) == 0)
- break;
- endmntent(m_f);
- if (mnt == 0)
- return 0;
- *mnt_flags = NTFS_MF_MOUNTED;
- if (!strcmp(mnt->mnt_dir, "/")) {
- *mnt_flags |= NTFS_MF_ISROOT;
- m_fd = open(MOUNTED, O_RDWR);
- if (m_fd < 0) {
- if (errno == EROFS)
- *mnt_flags |= NTFS_MF_READONLY;
- } else
- close(m_fd);
- }
- return 0;
-}
-#endif
-
-/* Return 0 on success or -errno on error. */
-int ntfs_check_if_mounted(const char *file, int *mnt_flags)
-{
-#ifdef HAVE_MNTENT_H
- return check_mntent(file, mnt_flags);
-#else
- *mnt_flags = 0;
- return 0;
-#endif
-}
-void check_mount(void)
-{
- int r, mnt_flags;
- r = ntfs_check_if_mounted(vol->dev_name, &mnt_flags);
- if (r) {
- Eprintf("Failed to determine whether %s is mounted: %s\n",
- vol->dev_name, strerror(-r));
- return;
- }
- if (!(mnt_flags & NTFS_MF_MOUNTED))
- return;
- 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");
-}
void init_options()
@@ -2789,5 +2728,8 @@
#endif
/* Make sure the file system is not mounted. */
- check_mount();
+ if (ntfs_check_if_mounted(vol->dev_name)==1){
+ err_exit("Device is mounted!\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.6
retrieving revision 1.7
diff -U2 -r1.6 -r1.7
--- ntfslabel.c 23 Apr 2002 08:25:41 -0000 1.6
+++ ntfslabel.c 23 Apr 2002 19:37:18 -0000 1.7
@@ -122,5 +122,5 @@
}
- printf("%s\n", vol->vol_name);
+ printf("%s\n",vol->vol_name);
ntfs_umount(vol, 0);
}
|