linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND 1/4] btrfs-progs: Check fstype in find_mount_root()
@ 2014-07-10  3:05 Qu Wenruo
  2014-07-10  3:05 ` [PATCH 2/4] btrfs-progs: Integrate error message output into find_mount_root() Qu Wenruo
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Qu Wenruo @ 2014-07-10  3:05 UTC (permalink / raw)
  To: linux-btrfs

When calling find_mount_root(), caller in fact wants to find the mount
point of *BTRFS*.

So also check ent->fstype in find_mount_root() and output proper error
messages if needed.
This will suppress a lot of "Inapproiate ioctl for device" error
message.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
 utils.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/utils.c b/utils.c
index 993d085..507ec6c 100644
--- a/utils.c
+++ b/utils.c
@@ -2412,6 +2412,7 @@ int find_mount_root(const char *path, char **mount_root)
 	struct mntent *ent;
 	int len;
 	int ret;
+	int not_btrfs;
 	int longest_matchlen = 0;
 	char *longest_match = NULL;
 
@@ -2432,6 +2433,10 @@ int find_mount_root(const char *path, char **mount_root)
 				free(longest_match);
 				longest_matchlen = len;
 				longest_match = strdup(ent->mnt_dir);
+				if (strcmp(ent->mnt_type, "btrfs"))
+					not_btrfs = 1;
+				else
+					not_btrfs = 0;
 			}
 		}
 	}
@@ -2443,6 +2448,12 @@ int find_mount_root(const char *path, char **mount_root)
 			path);
 		return -ENOENT;
 	}
+	if (not_btrfs) {
+		fprintf(stderr,
+			"ERROR: %s does not belong to a btrfs mount points.\n",
+			path);
+		return -EINVAL;
+	}
 
 	ret = 0;
 	*mount_root = realpath(longest_match, NULL);
-- 
2.0.1


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

end of thread, other threads:[~2014-07-29 12:02 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-10  3:05 [PATCH RESEND 1/4] btrfs-progs: Check fstype in find_mount_root() Qu Wenruo
2014-07-10  3:05 ` [PATCH 2/4] btrfs-progs: Integrate error message output into find_mount_root() Qu Wenruo
2014-07-10  7:33   ` Satoru Takeuchi
2014-07-10  8:10     ` Miao Xie
2014-07-10  8:26       ` Qu Wenruo
2014-07-10 23:24         ` Satoru Takeuchi
2014-07-10  3:05 ` [PATCH 3/4] btrfs-progs: Fix wrong indent in btrfs-progs Qu Wenruo
2014-07-10  7:34   ` Satoru Takeuchi
2014-07-29 12:02   ` David Sterba
2014-07-10  3:05 ` [PATCH v2 RESEND 4/4] btrfs-progs: Add mount point output for 'btrfs fi df' Qu Wenruo
2014-07-10 12:35 ` [PATCH RESEND 1/4] btrfs-progs: Check fstype in find_mount_root() Martin Steigerwald
2014-07-22 19:15 ` David Sterba
2014-07-23  1:23   ` Qu Wenruo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).