2 * Copyright (c) 2014-2016 Dmitry V. Levin <ldv@altlinux.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #include "xlat/fsmagic.h"
31 #include "xlat/statfs_flags.h"
34 print_statfs_type(const char *const prefix, const unsigned long long magic)
37 const char *s = xlat_search(fsmagic, ARRAY_SIZE(fsmagic), magic);
41 tprintf("%#llx", magic);
45 print_statfs_flags(const char *const prefix, const unsigned long long flags)
47 if (flags & ST_VALID) {
49 printflags(statfs_flags, flags, "ST_???");
54 print_statfs_number(const char *const prefix, const unsigned long long number)
57 tprintf("%llu", number);
61 print_struct_statfs(struct tcb *tcp, const long addr)
63 #ifdef HAVE_STRUCT_STATFS
64 struct strace_statfs b;
66 if (!fetch_struct_statfs(tcp, addr, &b))
69 print_statfs_type("{f_type=", b.f_type);
70 print_statfs_number(", f_bsize=", b.f_bsize);
71 print_statfs_number(", f_blocks=", b.f_blocks);
72 print_statfs_number(", f_bfree=", b.f_bfree);
73 print_statfs_number(", f_bavail=", b.f_bavail);
74 print_statfs_number(", f_files=", b.f_files);
75 print_statfs_number(", f_ffree=", b.f_ffree);
76 # if defined HAVE_STRUCT_STATFS_F_FSID_VAL \
77 || defined HAVE_STRUCT_STATFS_F_FSID___VAL
78 print_statfs_number(", f_fsid={", b.f_fsid[0]);
79 print_statfs_number(", ", b.f_fsid[1]);
82 print_statfs_number(", f_namelen=", b.f_namelen);
83 # ifdef HAVE_STRUCT_STATFS_F_FRSIZE
84 print_statfs_number(", f_frsize=", b.f_frsize);
86 # ifdef HAVE_STRUCT_STATFS_F_FLAGS
87 print_statfs_flags(", f_flags=", b.f_flags);
96 print_struct_statfs64(struct tcb *tcp, const long addr, const unsigned long size)
98 #ifdef HAVE_STRUCT_STATFS64
99 struct strace_statfs b;
101 if (!fetch_struct_statfs64(tcp, addr, size, &b))
104 print_statfs_type("{f_type=", b.f_type);
105 print_statfs_number(", f_bsize=", b.f_bsize);
106 print_statfs_number(", f_blocks=", b.f_blocks);
107 print_statfs_number(", f_bfree=", b.f_bfree);
108 print_statfs_number(", f_bavail=", b.f_bavail);
109 print_statfs_number(", f_files=", b.f_files);
110 print_statfs_number(", f_ffree=", b.f_ffree);
111 # if defined HAVE_STRUCT_STATFS64_F_FSID_VAL \
112 || defined HAVE_STRUCT_STATFS64_F_FSID___VAL
113 print_statfs_number(", f_fsid={", b.f_fsid[0]);
114 print_statfs_number(", ", b.f_fsid[1]);
117 print_statfs_number(", f_namelen=", b.f_namelen);
118 # ifdef HAVE_STRUCT_STATFS64_F_FRSIZE
119 print_statfs_number(", f_frsize=", b.f_frsize);
121 # ifdef HAVE_STRUCT_STATFS64_F_FLAGS
122 print_statfs_flags(", f_flags=", b.f_flags);