[PATCH] xfs_fsr: Get the last mount on a specific mount point

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Actually xfs_fsr uses the first mount matching the mount point specified. Since
Linux allows more than one mount over the same mount point, the best to do is to
use the last mount found in /proc/mounts, instead of the first one.

Thanks to Eric Sandeen for suggesting the patch

Signed-off-by: Carlos Maiolino <cmaiolino@xxxxxxxxxx>
---
 fsr/xfs_fsr.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
index 40c2e6f..4e6d706 100644
--- a/fsr/xfs_fsr.c
+++ b/fsr/xfs_fsr.c
@@ -1646,7 +1646,9 @@ getmntany(FILE *fp, struct mntent *mp, struct mntent *mpref, struct stat64 *s)
 {
 	struct mntent *t;
 	struct stat64 ms;
+	int found = 0;
 
+	memset(mp, 0, sizeof(struct mntent));
 	while ((t = getmntent(fp))) {
 		if (mpref->mnt_fsname) {	/* device */
 			if (stat64(t->mnt_fsname, &ms) < 0)
@@ -1660,10 +1662,16 @@ getmntany(FILE *fp, struct mntent *mp, struct mntent *mpref, struct stat64 *s)
 			if (s->st_ino != ms.st_ino || s->st_dev != ms.st_dev)
 				continue;
 		}
-		*mp = *t;
-		break;
+
+		found = 1;
+		free(mp->mnt_fsname);
+		free(mp->mnt_dir);
+		free(mp->mnt_type);
+		mp->mnt_fsname = strdup(t->mnt_fsname);
+		mp->mnt_dir = strdup(t->mnt_dir);
+		mp->mnt_type = strdup(t->mnt_type);
 	}
-	return (t != NULL);
+	return (found);
 }
 
 
-- 
1.7.6.5

_______________________________________________
xfs mailing list
xfs@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs


[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux