]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - spaceman/info.c
2 * Copyright (C) 2018 Oracle. All Rights Reserved.
4 * Author: Darrick J. Wong <darrick.wong@oracle.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it would be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
32 " Pretty-prints the filesystem geometry as derived from the superblock.\n"
33 " The output has the same format as mkfs.xfs, xfs_info, and other utilities.\n"
34 " The opened file must be an XFS mount point.\n"
45 struct xfs_fsop_geom geo
;
48 if (fs_table_lookup_mount(file
->name
) == NULL
) {
49 fprintf(stderr
, _("%s: Not a XFS mount point.\n"), file
->name
);
53 /* get the current filesystem size & geometry */
54 error
= ioctl(file
->fd
, XFS_IOC_FSGEOMETRY
, &geo
);
57 * OK, new xfsctl barfed - back off and try earlier version
58 * as we're probably running an older kernel version.
59 * Only field added in the v2 geometry xfsctl is "logsunit"
60 * so we'll zero that out for later display (as zero).
63 error
= ioctl(file
->fd
, XFS_IOC_FSGEOMETRY_V1
, &geo
);
66 "%s: cannot determine geometry of filesystem"
67 " mounted at %s: %s\n"),
68 progname
, file
->name
, strerror(errno
));
74 xfs_report_geom(&geo
, file
->fs_path
.fs_name
, file
->fs_path
.fs_log
,
79 static const struct cmdinfo info_cmd
= {
87 .flags
= CMD_FLAG_ONESHOT
,
88 .oneline
= N_("pretty-print superblock geometry info"),
95 add_command(&info_cmd
);