]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - spaceman/info.c
1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2018 Oracle. All Rights Reserved.
4 * Author: Darrick J. Wong <darrick.wong@oracle.com>
18 " Pretty-prints the filesystem geometry as derived from the superblock.\n"
19 " The output has the same format as mkfs.xfs, xfs_info, and other utilities.\n"
20 " The opened file must be an XFS mount point.\n"
31 struct xfs_fsop_geom geo
;
34 if (fs_table_lookup_mount(file
->name
) == NULL
) {
35 fprintf(stderr
, _("%s: Not a XFS mount point.\n"), file
->name
);
39 /* get the current filesystem size & geometry */
40 error
= ioctl(file
->fd
, XFS_IOC_FSGEOMETRY
, &geo
);
43 * OK, new xfsctl barfed - back off and try earlier version
44 * as we're probably running an older kernel version.
45 * Only field added in the v2 geometry xfsctl is "logsunit"
46 * so we'll zero that out for later display (as zero).
49 error
= ioctl(file
->fd
, XFS_IOC_FSGEOMETRY_V1
, &geo
);
52 "%s: cannot determine geometry of filesystem"
53 " mounted at %s: %s\n"),
54 progname
, file
->name
, strerror(errno
));
60 xfs_report_geom(&geo
, file
->fs_path
.fs_name
, file
->fs_path
.fs_log
,
65 static const struct cmdinfo info_cmd
= {
73 .flags
= CMD_FLAG_ONESHOT
,
74 .oneline
= N_("pretty-print superblock geometry info"),
81 add_command(&info_cmd
);