2 # SPDX-License-Identifier: GPL-2.0
4 # Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
8 USAGE
="Usage: xfs_info [-V] [-t mtab] [mountpoint|device|file]"
10 # Try to find a loop device associated with a file. We only want to return
11 # one loopdev (multiple loop devices can attach to a single file) so we grab
12 # the last line and return it if it's actually a block device.
13 try_find_loop_dev_for_file
() {
14 local x
="$(losetup -O NAME -j "$1" 2> /dev/null | tail -n 1)"
15 test -b "$x" && echo "$x"
21 t
) OPTS
="-t $OPTARG" ;;
22 V
) xfs_spaceman
-p xfs_info
-V
37 # See if we can map the arg to a loop device
38 loopdev
="$(try_find_loop_dev_for_file "${arg}")"
39 test -n "${loopdev}" && arg
="${loopdev}"
41 # If we find a mountpoint for the device, do a live query;
42 # otherwise try reading the fs with xfs_db.
43 if mountpt
="$(findmnt -t xfs -f -n -o TARGET "${arg}" 2> /dev/null)"; then
44 xfs_spaceman
-p xfs_info
-c "info" $OPTS "${mountpt}"
47 xfs_db
-p xfs_info
-c "info" $OPTS "${arg}"