linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs-progs: Add mount point output for 'btrfs fi df' command.
@ 2014-07-08  5:43 Qu Wenruo
  2014-07-10  0:41 ` Satoru Takeuchi
  0 siblings, 1 reply; 6+ messages in thread
From: Qu Wenruo @ 2014-07-08  5:43 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

Add mount point output for 'btrfs fi df'.
Also since the patch uses find_mount_root() to find mount point,
now 'btrfs fi df' can output more meaningful error message when given a
non-btrfs path.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
This patch needs to be merged after the following path:
btrfs-progs: Check fstype in find_mount_root()
---
 cmds-filesystem.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index 4b2d27e..d571765 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -187,12 +187,22 @@ static int cmd_filesystem_df(int argc, char **argv)
        int ret;
        int fd;
        char *path;
+       char *mount_point = NULL;
        DIR *dirstream = NULL;
 
        if (check_argc_exact(argc, 2))
                usage(cmd_filesystem_df_usage);
 
        path = argv[1];
+       ret = find_mount_root(path, &mount_point);
+       if (ret < 0) {
+	       if (ret != -ENOENT)
+		       fprintf(stderr, "ERROR: Failed to find mount root for path %s: %s\n",
+			       path, strerror(-ret));
+		return 1;
+       }
+       printf("Mounted on: %s\n", mount_point);
+       free(mount_point);
 
        fd = open_file_or_dir(path, &dirstream);
        if (fd < 0) {
-- 
2.0.1


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

end of thread, other threads:[~2014-07-10  1:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-08  5:43 [PATCH] btrfs-progs: Add mount point output for 'btrfs fi df' command Qu Wenruo
2014-07-10  0:41 ` Satoru Takeuchi
2014-07-10  0:59   ` Qu Wenruo
2014-07-10  1:17     ` Qu Wenruo
2014-07-10  1:18     ` Qu Wenruo
2014-07-10  1:22       ` Satoru Takeuchi

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).