From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: <linux-btrfs@vger.kernel.org>
Subject: [PATCH v2 RESEND 4/4] btrfs-progs: Add mount point output for 'btrfs fi df'
Date: Thu, 10 Jul 2014 11:05:13 +0800 [thread overview]
Message-ID: <1404961513-14614-4-git-send-email-quwenruo@cn.fujitsu.com> (raw)
In-Reply-To: <1404961513-14614-1-git-send-email-quwenruo@cn.fujitsu.com>
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>
---
v2:
Call realpath() before find_mount_root() to deal with relative path
---
cmds-filesystem.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index 0a9b62a..d76a1a5 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -187,12 +187,28 @@ static int cmd_filesystem_df(int argc, char **argv)
int ret;
int fd;
char *path;
+ char *real_path = NULL;
+ char *mount_point = NULL;
DIR *dirstream = NULL;
if (check_argc_exact(argc, 2))
usage(cmd_filesystem_df_usage);
path = argv[1];
+ real_path = realpath(path, NULL);
+ if (!real_path) {
+ fprintf(stderr, "ERROR: Failed to resolve real path for %s: %s\n",
+ path, strerror(errno));
+ return 1;
+ }
+ ret = find_mount_root(real_path, &mount_point);
+ if (ret < 0) {
+ free(real_path);
+ return 1;
+ }
+ printf("Mounted on: %s\n", mount_point);
+ free(real_path);
+ free(mount_point);
fd = open_file_or_dir(path, &dirstream);
if (fd < 0) {
--
2.0.1
next prev parent reply other threads:[~2014-07-10 3:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Qu Wenruo [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1404961513-14614-4-git-send-email-quwenruo@cn.fujitsu.com \
--to=quwenruo@cn.fujitsu.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).