* [PATCH] btrfs-progs: fix find_mount_root() to handle duplicated mount point correctly
@ 2014-09-04 2:27 Qu Wenruo
2014-09-14 7:46 ` Omar Sandoval
0 siblings, 1 reply; 3+ messages in thread
From: Qu Wenruo @ 2014-09-04 2:27 UTC (permalink / raw)
To: linux-btrfs
Original find_mount_root() will use the first mount point match and
return it.
It was OK until the following commit, which will also check the fstype:
de22c28ef31d9721606ba059 btrfs-progs: Check fstype in find_mount_root()
With fstype check, we should check the last match, not only the first
one.
Or the following mount will not pass the find_mount_root():
/dev/sdc on /mnt/test type ext4 (rw,relatime,data=ordered)
/dev/sdb on /mnt/test type btrfs (rw,relatime,space_cache)
This patch will use the last match to do the fstype check.
Reported-by: Remco Hosman <remco@yerf-it.nl>
Signed-off-bu: Remco Hosman <remco@yerf-it.nl>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
utils.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/utils.c b/utils.c
index 6c09366..6a16b06 100644
--- a/utils.c
+++ b/utils.c
@@ -2359,8 +2359,8 @@ int find_mount_root(const char *path, char **mount_root)
while ((ent = getmntent(mnttab))) {
len = strlen(ent->mnt_dir);
if (strncmp(ent->mnt_dir, path, len) == 0) {
- /* match found */
- if (longest_matchlen < len) {
+ /* match found and use the latest match */
+ if (longest_matchlen <= len) {
free(longest_match);
longest_matchlen = len;
longest_match = strdup(ent->mnt_dir);
--
2.1.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs-progs: fix find_mount_root() to handle duplicated mount point correctly
2014-09-04 2:27 [PATCH] btrfs-progs: fix find_mount_root() to handle duplicated mount point correctly Qu Wenruo
@ 2014-09-14 7:46 ` Omar Sandoval
2014-09-18 5:00 ` Omar Sandoval
0 siblings, 1 reply; 3+ messages in thread
From: Omar Sandoval @ 2014-09-14 7:46 UTC (permalink / raw)
To: Qu Wenruo; +Cc: linux-btrfs
Reviewed-by: Omar Sandoval <osandov@osandov.com>
--
Omar
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs-progs: fix find_mount_root() to handle duplicated mount point correctly
2014-09-14 7:46 ` Omar Sandoval
@ 2014-09-18 5:00 ` Omar Sandoval
0 siblings, 0 replies; 3+ messages in thread
From: Omar Sandoval @ 2014-09-18 5:00 UTC (permalink / raw)
To: Qu Wenruo, Chris Mason, Josef Bacik; +Cc: linux-btrfs
What's the status on this patch? There have been at least a couple of bug
reports that this fixes, including
https://bugzilla.kernel.org/show_bug.cgi?id=83741.
--
Omar
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-09-18 5:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-04 2:27 [PATCH] btrfs-progs: fix find_mount_root() to handle duplicated mount point correctly Qu Wenruo
2014-09-14 7:46 ` Omar Sandoval
2014-09-18 5:00 ` Omar Sandoval
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.