]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - io/stat.c
libfrog: convert fsgeom.c functions to negative error codes
[thirdparty/xfsprogs-dev.git] / io / stat.c
index b97ccedc4ecbb1cb901181774ab867ec5e952b99..d125a0f78539779d99a7d0679cdc9cab32ab5c5b 100644 (file)
--- a/io/stat.c
+++ b/io/stat.c
@@ -1,22 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2003-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
  * Copyright (C) 2015, 2017 Red Hat, Inc.
  * Portions of statx support written by David Howells (dhowells@redhat.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 #include "command.h"
@@ -25,6 +12,8 @@
 #include "io.h"
 #include "statx.h"
 #include "libxfs.h"
+#include "libfrog/logging.h"
+#include "libfrog/fsgeom.h"
 
 #include <fcntl.h>
 
@@ -90,7 +79,8 @@ dump_raw_stat(struct stat *st)
        return 0;
 }
 
-void print_file_info(void)
+static void
+print_file_info(void)
 {
        printf(_("fd.path = \"%s\"\n"), file->name);
        printf(_("fd.flags = %s,%s,%s%s%s%s%s\n"),
@@ -103,7 +93,8 @@ void print_file_info(void)
                file->flags & IO_TMPFILE ? _(",tmpfile") : "");
 }
 
-void print_xfs_info(int verbose)
+static void
+print_xfs_info(int verbose)
 {
        struct dioattr  dio;
        struct fsxattr  fsx, fsxa;
@@ -189,6 +180,7 @@ statfs_f(
        struct xfs_fsop_counts  fscounts;
        struct xfs_fsop_geom    fsgeo;
        struct statfs           st;
+       int                     ret;
 
        printf(_("fd.path = \"%s\"\n"), file->name);
        if (platform_fstatfs(file->fd, &st) < 0) {
@@ -199,12 +191,15 @@ statfs_f(
                printf(_("statfs.f_bavail = %lld\n"), (long long) st.f_bavail);
                printf(_("statfs.f_files = %lld\n"), (long long) st.f_files);
                printf(_("statfs.f_ffree = %lld\n"), (long long) st.f_ffree);
-               printf(_("statfs.f_fflags = 0x%llx\n"), (long long) st.f_flags);
+#ifdef HAVE_STATFS_FLAGS
+               printf(_("statfs.f_flags = 0x%llx\n"), (long long) st.f_flags);
+#endif
        }
        if (file->flags & IO_FOREIGN)
                return 0;
-       if ((xfsctl(file->name, file->fd, XFS_IOC_FSGEOMETRY_V1, &fsgeo)) < 0) {
-               perror("XFS_IOC_FSGEOMETRY_V1");
+       ret = -xfrog_geometry(file->fd, &fsgeo);
+       if (ret) {
+               xfrog_perror(ret, "XFS_IOC_FSGEOMETRY");
        } else {
                printf(_("geom.bsize = %u\n"), fsgeo.blocksize);
                printf(_("geom.agcount = %u\n"), fsgeo.agcount);
@@ -281,6 +276,7 @@ dump_raw_statx(struct statx *stx)
        printf("stat.ino = %llu\n", (unsigned long long)stx->stx_ino);
        printf("stat.size = %llu\n", (unsigned long long)stx->stx_size);
        printf("stat.blocks = %llu\n", (unsigned long long)stx->stx_blocks);
+       printf("stat.attributes_mask = 0x%llx\n", (unsigned long long)stx->stx_attributes_mask);
        printf("stat.atime.tv_sec = %lld\n", (long long)stx->stx_atime.tv_sec);
        printf("stat.atime.tv_nsec = %d\n", stx->stx_atime.tv_nsec);
        printf("stat.btime.tv_sec = %lld\n", (long long)stx->stx_btime.tv_sec);
@@ -302,7 +298,7 @@ dump_raw_statx(struct statx *stx)
  *     - output style for flags (and all else?) (chars vs. hex?)
  *     - output - mask out incidental flag or not?
  */
-int
+static int
 statx_f(
        int             argc,
        char            **argv)