(root)/
strace-6.5/
src/
print_statfs.c
       1  /*
       2   * Copyright (c) 2014-2021 Dmitry V. Levin <ldv@strace.io>
       3   * All rights reserved.
       4   *
       5   * SPDX-License-Identifier: LGPL-2.1-or-later
       6   */
       7  
       8  #include "defs.h"
       9  #include "statfs.h"
      10  #include "xlat/fsmagic.h"
      11  #include "xlat/statfs_flags.h"
      12  
      13  #if defined HAVE_STRUCT_STATFS_F_FSID_VAL \
      14   || defined HAVE_STRUCT_STATFS_F_FSID___VAL \
      15   || defined HAVE_STRUCT_STATFS64_F_FSID_VAL \
      16   || defined HAVE_STRUCT_STATFS64_F_FSID___VAL
      17  static void
      18  print_f_fsid(const typeof_field(struct strace_statfs, f_fsid) *const p,
      19  	     struct tcb *const tcp)
      20  {
      21  	tprint_struct_begin();
      22  	PRINT_FIELD_ARRAY(*p, val, tcp, print_xint_array_member);
      23  	tprint_struct_end();
      24  }
      25  #endif
      26  
      27  void
      28  print_struct_statfs(struct tcb *const tcp, const kernel_ulong_t addr)
      29  {
      30  #ifdef HAVE_STRUCT_STATFS
      31  	struct strace_statfs b;
      32  
      33  	if (!fetch_struct_statfs(tcp, addr, &b))
      34  		return;
      35  
      36  	tprint_struct_begin();
      37  	PRINT_FIELD_XVAL(b, f_type, fsmagic, NULL);
      38  	tprint_struct_next();
      39  	PRINT_FIELD_U(b, f_bsize);
      40  	tprint_struct_next();
      41  	PRINT_FIELD_U(b, f_blocks);
      42  	tprint_struct_next();
      43  	PRINT_FIELD_U(b, f_bfree);
      44  	tprint_struct_next();
      45  	PRINT_FIELD_U(b, f_bavail);
      46  	tprint_struct_next();
      47  	PRINT_FIELD_U(b, f_files);
      48  	tprint_struct_next();
      49  	PRINT_FIELD_U(b, f_ffree);
      50  # if defined HAVE_STRUCT_STATFS_F_FSID_VAL \
      51    || defined HAVE_STRUCT_STATFS_F_FSID___VAL
      52  	tprint_struct_next();
      53  	PRINT_FIELD_OBJ_PTR(b, f_fsid, print_f_fsid, tcp);
      54  # endif
      55  	tprint_struct_next();
      56  	PRINT_FIELD_U(b, f_namelen);
      57  # ifdef HAVE_STRUCT_STATFS_F_FRSIZE
      58  	tprint_struct_next();
      59  	PRINT_FIELD_U(b, f_frsize);
      60  # endif
      61  # ifdef HAVE_STRUCT_STATFS_F_FLAGS
      62  	if (b.f_flags & ST_VALID) {
      63  		tprint_struct_next();
      64  		PRINT_FIELD_FLAGS(b, f_flags, statfs_flags, "ST_???");
      65  	}
      66  # endif
      67  	tprint_struct_end();
      68  #else
      69  	printaddr(addr);
      70  #endif
      71  }
      72  
      73  void
      74  print_struct_statfs64(struct tcb *const tcp, const kernel_ulong_t addr,
      75  		      const kernel_ulong_t size)
      76  {
      77  #ifdef HAVE_STRUCT_STATFS64
      78  	struct strace_statfs b;
      79  
      80  	if (!fetch_struct_statfs64(tcp, addr, size, &b))
      81  		return;
      82  
      83  	tprint_struct_begin();
      84  	PRINT_FIELD_XVAL(b, f_type, fsmagic, NULL);
      85  	tprint_struct_next();
      86  	PRINT_FIELD_U(b, f_bsize);
      87  	tprint_struct_next();
      88  	PRINT_FIELD_U(b, f_blocks);
      89  	tprint_struct_next();
      90  	PRINT_FIELD_U(b, f_bfree);
      91  	tprint_struct_next();
      92  	PRINT_FIELD_U(b, f_bavail);
      93  	tprint_struct_next();
      94  	PRINT_FIELD_U(b, f_files);
      95  	tprint_struct_next();
      96  	PRINT_FIELD_U(b, f_ffree);
      97  # if defined HAVE_STRUCT_STATFS64_F_FSID_VAL \
      98    || defined HAVE_STRUCT_STATFS64_F_FSID___VAL
      99  	tprint_struct_next();
     100  	PRINT_FIELD_OBJ_PTR(b, f_fsid, print_f_fsid, tcp);
     101  # endif
     102  	tprint_struct_next();
     103  	PRINT_FIELD_U(b, f_namelen);
     104  # ifdef HAVE_STRUCT_STATFS64_F_FRSIZE
     105  	tprint_struct_next();
     106  	PRINT_FIELD_U(b, f_frsize);
     107  # endif
     108  # ifdef HAVE_STRUCT_STATFS64_F_FLAGS
     109  	if (b.f_flags & ST_VALID) {
     110  		tprint_struct_next();
     111  		PRINT_FIELD_FLAGS(b, f_flags, statfs_flags, "ST_???");
     112  	}
     113  # endif
     114  	tprint_struct_end();
     115  #else
     116  	printaddr(addr);
     117  #endif
     118  }