public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs_fsr: Get the last mount on a specific mount point
@ 2012-02-07 18:41 Carlos Maiolino
  2012-02-13 17:42 ` Christoph Hellwig
  0 siblings, 1 reply; 7+ messages in thread
From: Carlos Maiolino @ 2012-02-07 18:41 UTC (permalink / raw)
  To: xfs; +Cc: Carlos Maiolino

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@redhat.com>
---
 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@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-04-24 20:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-07 18:41 [PATCH] xfs_fsr: Get the last mount on a specific mount point Carlos Maiolino
2012-02-13 17:42 ` Christoph Hellwig
2012-02-15 12:31   ` Carlos Maiolino
2012-02-17 17:26     ` Christoph Hellwig
2012-02-17 23:36   ` Eric Sandeen
2012-04-24 20:14     ` Carlos Maiolino
2012-04-24 20:57       ` Mark Tinguely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox