From patchwork Tue Jul 8 05:43:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 4502591 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EF0F4BEEAA for ; Tue, 8 Jul 2014 05:43:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 35A3C20218 for ; Tue, 8 Jul 2014 05:43:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 466B220212 for ; Tue, 8 Jul 2014 05:43:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752169AbaGHFn2 (ORCPT ); Tue, 8 Jul 2014 01:43:28 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:50548 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751852AbaGHFn1 (ORCPT ); Tue, 8 Jul 2014 01:43:27 -0400 X-IronPort-AV: E=Sophos;i="5.00,855,1396972800"; d="scan'208";a="32977566" Received: from localhost (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 08 Jul 2014 13:40:41 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id s685hNZs009620; Tue, 8 Jul 2014 13:43:23 +0800 Received: from adam-work.lan (10.167.226.24) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Tue, 8 Jul 2014 13:43:28 +0800 From: Qu Wenruo To: CC: Subject: [PATCH] btrfs-progs: Add mount point output for 'btrfs fi df' command. Date: Tue, 8 Jul 2014 13:43:23 +0800 Message-ID: <1404798203-17122-1-git-send-email-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.0.1 MIME-Version: 1.0 X-Originating-IP: [10.167.226.24] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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) {