From patchwork Fri Mar 1 23:28:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10836245 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8B2521390 for ; Fri, 1 Mar 2019 23:28:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74F692F0C2 for ; Fri, 1 Mar 2019 23:28:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 695332F0AF; Fri, 1 Mar 2019 23:28:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0EEB52F0AF for ; Fri, 1 Mar 2019 23:28:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725966AbfCAX2v (ORCPT ); Fri, 1 Mar 2019 18:28:51 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:35996 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726002AbfCAX2v (ORCPT ); Fri, 1 Mar 2019 18:28:51 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x21NSoO6127312 for ; Fri, 1 Mar 2019 23:28:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=aoW1C4NW7S0VXVHh6CFkHwfULuV/Vy83hMeoY8gpj98=; b=OAQokEKMBtyJ0U0F30xYheQjOW3Kc/2TkLG/7MUOMa4ybWWXY1i2JbptRgpefagUXnej Lx8aJptTpBQaoDu3PZI117Ts5iTF2plr+x3jFRykeryTPimAiNwqoJtPxOa+Cw+TjHXi CS2QTxBRYrjGazPqg492i7uIeOio3dy4v11zI0/OL5rGMucIq+eIIcs5v6zchZQdHLqW 2B9XXyzgf1OStjGjA5G41kCukc+Xq6Kb1Tv69bwjn+hU1F2k8riTyNuOGl+OVQQnozwB PILHc4MXLiK82F+1/IyCkE3aeT71wqwtcaPLOrR1gRrMk+EOEZuIg6l8lqPCI+KEomJW SA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2qtxtsa56q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 01 Mar 2019 23:28:49 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x21NSlXn023020 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 1 Mar 2019 23:28:47 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x21NSlV7021411 for ; Fri, 1 Mar 2019 23:28:47 GMT Received: from localhost (/10.159.229.175) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 01 Mar 2019 15:28:46 -0800 Subject: [PATCH 18/23] xfs_info: use findmnt to handle mounted block devices From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Fri, 01 Mar 2019 15:28:45 -0800 Message-ID: <155148292592.16677.1870426029411000280.stgit@magnolia> In-Reply-To: <155148280859.16677.6057998944865066232.stgit@magnolia> References: <155148280859.16677.6057998944865066232.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9182 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903010162 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Use findmnt to determine if the passed-in argument is associated with a mount point, and if so, use spaceman to query the mounted filesystem. Signed-off-by: Darrick J. Wong --- debian/control | 2 +- spaceman/xfs_info.sh | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/debian/control b/debian/control index f4f807b0..0b3205f5 100644 --- a/debian/control +++ b/debian/control @@ -8,7 +8,7 @@ Standards-Version: 4.0.0 Homepage: https://xfs.wiki.kernel.org/ Package: xfsprogs -Depends: ${shlibs:Depends}, ${misc:Depends}, python3:any +Depends: ${shlibs:Depends}, ${misc:Depends}, python3:any, util-linux Provides: fsck-backend Suggests: xfsdump, acl, attr, quota Breaks: xfsdump (<< 3.0.0) diff --git a/spaceman/xfs_info.sh b/spaceman/xfs_info.sh index ecf17f61..70978164 100755 --- a/spaceman/xfs_info.sh +++ b/spaceman/xfs_info.sh @@ -24,11 +24,19 @@ set -- extra "$@" shift $OPTIND case $# in 1) - if [ -b "$1" ] || [ -f "$1" ]; then - xfs_db -p xfs_info -c "info" $OPTS "$1" + arg="$1" + + # See if we can map the arg to a loop device + loopdev="$(losetup -n -O NAME -j "${arg}" 2> /dev/null)" + test -n "${loopdev}" && arg="${loopdev}" + + # If we find a mountpoint for the device, do a live query; + # otherwise try reading the fs with xfs_db. + if mountpt="$(findmnt -f -n -o TARGET "${arg}" 2> /dev/null)"; then + xfs_spaceman -p xfs_info -c "info" $OPTS "${mountpt}" status=$? else - xfs_spaceman -p xfs_info -c "info" $OPTS "$1" + xfs_db -p xfs_info -c "info" $OPTS "${arg}" status=$? fi ;;