Branch data Line data Source code
1 : : /*
2 : : * Copyright (c) 2014-2016 Dmitry V. Levin <ldv@altlinux.org>
3 : : * All rights reserved.
4 : : *
5 : : * Redistribution and use in source and binary forms, with or without
6 : : * modification, are permitted provided that the following conditions
7 : : * are met:
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.
15 : : *
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.
26 : : */
27 : :
28 : : #include "defs.h"
29 : : #include "statfs.h"
30 : : #include "xlat/fsmagic.h"
31 : : #include "xlat/statfs_flags.h"
32 : :
33 : : static void
34 : 28 : print_statfs_type(const char *const prefix, const unsigned long long magic)
35 : : {
36 : 28 : tprints(prefix);
37 : 28 : printxval_search(fsmagic, magic, NULL);
38 : 28 : }
39 : :
40 : : #if defined HAVE_STRUCT_STATFS_F_FLAGS || defined HAVE_STRUCT_STATFS64_F_FLAGS
41 : : static void
42 : 28 : print_statfs_flags(const char *const prefix, const unsigned long long flags)
43 : : {
44 [ + - ]: 28 : if (flags & ST_VALID) {
45 : 28 : tprints(prefix);
46 : 28 : printflags64(statfs_flags, flags, "ST_???");
47 : : }
48 : 28 : }
49 : : #endif /* HAVE_STRUCT_STATFS_F_FLAGS || HAVE_STRUCT_STATFS64_F_FLAGS */
50 : :
51 : : static void
52 : 280 : print_statfs_number(const char *const prefix, const unsigned long long number)
53 : : {
54 : 280 : tprints(prefix);
55 : 280 : tprintf("%llu", number);
56 : 280 : }
57 : :
58 : : void
59 : 36 : print_struct_statfs(struct tcb *const tcp, const kernel_ulong_t addr)
60 : : {
61 : : #ifdef HAVE_STRUCT_STATFS
62 : : struct strace_statfs b;
63 : :
64 [ + + ]: 36 : if (!fetch_struct_statfs(tcp, addr, &b))
65 : 12 : return;
66 : :
67 : 24 : print_statfs_type("{f_type=", b.f_type);
68 : 24 : print_statfs_number(", f_bsize=", b.f_bsize);
69 : 24 : print_statfs_number(", f_blocks=", b.f_blocks);
70 : 24 : print_statfs_number(", f_bfree=", b.f_bfree);
71 : 24 : print_statfs_number(", f_bavail=", b.f_bavail);
72 : 24 : print_statfs_number(", f_files=", b.f_files);
73 : 24 : print_statfs_number(", f_ffree=", b.f_ffree);
74 : : # if defined HAVE_STRUCT_STATFS_F_FSID_VAL \
75 : : || defined HAVE_STRUCT_STATFS_F_FSID___VAL
76 : 24 : print_statfs_number(", f_fsid={val=[", b.f_fsid[0]);
77 : 24 : print_statfs_number(", ", b.f_fsid[1]);
78 : 24 : tprints("]}");
79 : : # endif
80 : 24 : print_statfs_number(", f_namelen=", b.f_namelen);
81 : : # ifdef HAVE_STRUCT_STATFS_F_FRSIZE
82 : 24 : print_statfs_number(", f_frsize=", b.f_frsize);
83 : : # endif
84 : : # ifdef HAVE_STRUCT_STATFS_F_FLAGS
85 : 24 : print_statfs_flags(", f_flags=", b.f_flags);
86 : : # endif
87 : 24 : tprints("}");
88 : : #else
89 : : printaddr(addr);
90 : : #endif
91 : : }
92 : :
93 : : void
94 : 8 : print_struct_statfs64(struct tcb *const tcp, const kernel_ulong_t addr,
95 : : const kernel_ulong_t size)
96 : : {
97 : : #ifdef HAVE_STRUCT_STATFS64
98 : : struct strace_statfs b;
99 : :
100 [ + + ]: 8 : if (!fetch_struct_statfs64(tcp, addr, size, &b))
101 : 4 : return;
102 : :
103 : 4 : print_statfs_type("{f_type=", b.f_type);
104 : 4 : print_statfs_number(", f_bsize=", b.f_bsize);
105 : 4 : print_statfs_number(", f_blocks=", b.f_blocks);
106 : 4 : print_statfs_number(", f_bfree=", b.f_bfree);
107 : 4 : print_statfs_number(", f_bavail=", b.f_bavail);
108 : 4 : print_statfs_number(", f_files=", b.f_files);
109 : 4 : print_statfs_number(", f_ffree=", b.f_ffree);
110 : : # if defined HAVE_STRUCT_STATFS64_F_FSID_VAL \
111 : : || defined HAVE_STRUCT_STATFS64_F_FSID___VAL
112 : 4 : print_statfs_number(", f_fsid={val=[", b.f_fsid[0]);
113 : 4 : print_statfs_number(", ", b.f_fsid[1]);
114 : 4 : tprints("]}");
115 : : # endif
116 : 4 : print_statfs_number(", f_namelen=", b.f_namelen);
117 : : # ifdef HAVE_STRUCT_STATFS64_F_FRSIZE
118 : 4 : print_statfs_number(", f_frsize=", b.f_frsize);
119 : : # endif
120 : : # ifdef HAVE_STRUCT_STATFS64_F_FLAGS
121 : 4 : print_statfs_flags(", f_flags=", b.f_flags);
122 : : # endif
123 : 4 : tprints("}");
124 : : #else
125 : : printaddr(addr);
126 : : #endif
127 : : }
|