1*cf84ac9aSAndroid Build Coastguard Worker /*
2*cf84ac9aSAndroid Build Coastguard Worker * Copyright (c) 1999-2003 Ulrich Drepper <[email protected]>
3*cf84ac9aSAndroid Build Coastguard Worker * Copyright (c) 2004 David S. Miller <[email protected]>
4*cf84ac9aSAndroid Build Coastguard Worker * Copyright (c) 2003-2005 Roland McGrath <[email protected]>
5*cf84ac9aSAndroid Build Coastguard Worker * Copyright (c) 2007 Jan Kratochvil <[email protected]>
6*cf84ac9aSAndroid Build Coastguard Worker * Copyright (c) 2009 Denys Vlasenko <[email protected]>
7*cf84ac9aSAndroid Build Coastguard Worker * Copyright (c) 2009-2010 Andreas Schwab <[email protected]>
8*cf84ac9aSAndroid Build Coastguard Worker * Copyright (c) 2012 H.J. Lu <[email protected]>
9*cf84ac9aSAndroid Build Coastguard Worker * Copyright (c) 2005-2016 Dmitry V. Levin <[email protected]>
10*cf84ac9aSAndroid Build Coastguard Worker * Copyright (c) 2016-2017 The strace developers.
11*cf84ac9aSAndroid Build Coastguard Worker * All rights reserved.
12*cf84ac9aSAndroid Build Coastguard Worker *
13*cf84ac9aSAndroid Build Coastguard Worker * Redistribution and use in source and binary forms, with or without
14*cf84ac9aSAndroid Build Coastguard Worker * modification, are permitted provided that the following conditions
15*cf84ac9aSAndroid Build Coastguard Worker * are met:
16*cf84ac9aSAndroid Build Coastguard Worker * 1. Redistributions of source code must retain the above copyright
17*cf84ac9aSAndroid Build Coastguard Worker * notice, this list of conditions and the following disclaimer.
18*cf84ac9aSAndroid Build Coastguard Worker * 2. Redistributions in binary form must reproduce the above copyright
19*cf84ac9aSAndroid Build Coastguard Worker * notice, this list of conditions and the following disclaimer in the
20*cf84ac9aSAndroid Build Coastguard Worker * documentation and/or other materials provided with the distribution.
21*cf84ac9aSAndroid Build Coastguard Worker * 3. The name of the author may not be used to endorse or promote products
22*cf84ac9aSAndroid Build Coastguard Worker * derived from this software without specific prior written permission.
23*cf84ac9aSAndroid Build Coastguard Worker *
24*cf84ac9aSAndroid Build Coastguard Worker * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
25*cf84ac9aSAndroid Build Coastguard Worker * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26*cf84ac9aSAndroid Build Coastguard Worker * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27*cf84ac9aSAndroid Build Coastguard Worker * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28*cf84ac9aSAndroid Build Coastguard Worker * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29*cf84ac9aSAndroid Build Coastguard Worker * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30*cf84ac9aSAndroid Build Coastguard Worker * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31*cf84ac9aSAndroid Build Coastguard Worker * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32*cf84ac9aSAndroid Build Coastguard Worker * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33*cf84ac9aSAndroid Build Coastguard Worker * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34*cf84ac9aSAndroid Build Coastguard Worker */
35*cf84ac9aSAndroid Build Coastguard Worker
36*cf84ac9aSAndroid Build Coastguard Worker #include "defs.h"
37*cf84ac9aSAndroid Build Coastguard Worker #include <sys/stat.h>
38*cf84ac9aSAndroid Build Coastguard Worker #include "stat.h"
39*cf84ac9aSAndroid Build Coastguard Worker
40*cf84ac9aSAndroid Build Coastguard Worker void
print_struct_stat(struct tcb * tcp,const struct strace_stat * const st)41*cf84ac9aSAndroid Build Coastguard Worker print_struct_stat(struct tcb *tcp, const struct strace_stat *const st)
42*cf84ac9aSAndroid Build Coastguard Worker {
43*cf84ac9aSAndroid Build Coastguard Worker tprints("{");
44*cf84ac9aSAndroid Build Coastguard Worker if (!abbrev(tcp)) {
45*cf84ac9aSAndroid Build Coastguard Worker tprints("st_dev=");
46*cf84ac9aSAndroid Build Coastguard Worker print_dev_t(st->dev);
47*cf84ac9aSAndroid Build Coastguard Worker tprintf(", st_ino=%llu, st_mode=", st->ino);
48*cf84ac9aSAndroid Build Coastguard Worker print_symbolic_mode_t(st->mode);
49*cf84ac9aSAndroid Build Coastguard Worker tprintf(", st_nlink=%llu, st_uid=%llu, st_gid=%llu",
50*cf84ac9aSAndroid Build Coastguard Worker st->nlink, st->uid, st->gid);
51*cf84ac9aSAndroid Build Coastguard Worker tprintf(", st_blksize=%llu", st->blksize);
52*cf84ac9aSAndroid Build Coastguard Worker tprintf(", st_blocks=%llu", st->blocks);
53*cf84ac9aSAndroid Build Coastguard Worker } else {
54*cf84ac9aSAndroid Build Coastguard Worker tprints("st_mode=");
55*cf84ac9aSAndroid Build Coastguard Worker print_symbolic_mode_t(st->mode);
56*cf84ac9aSAndroid Build Coastguard Worker }
57*cf84ac9aSAndroid Build Coastguard Worker
58*cf84ac9aSAndroid Build Coastguard Worker switch (st->mode & S_IFMT) {
59*cf84ac9aSAndroid Build Coastguard Worker case S_IFCHR: case S_IFBLK:
60*cf84ac9aSAndroid Build Coastguard Worker tprints(", st_rdev=");
61*cf84ac9aSAndroid Build Coastguard Worker print_dev_t(st->rdev);
62*cf84ac9aSAndroid Build Coastguard Worker break;
63*cf84ac9aSAndroid Build Coastguard Worker default:
64*cf84ac9aSAndroid Build Coastguard Worker tprintf(", st_size=%llu", st->size);
65*cf84ac9aSAndroid Build Coastguard Worker break;
66*cf84ac9aSAndroid Build Coastguard Worker }
67*cf84ac9aSAndroid Build Coastguard Worker
68*cf84ac9aSAndroid Build Coastguard Worker if (!abbrev(tcp)) {
69*cf84ac9aSAndroid Build Coastguard Worker #define PRINT_ST_TIME(field) \
70*cf84ac9aSAndroid Build Coastguard Worker do { \
71*cf84ac9aSAndroid Build Coastguard Worker tprintf(", st_" #field "=%lld", (long long) st->field); \
72*cf84ac9aSAndroid Build Coastguard Worker tprints_comment(sprinttime_nsec(st->field, \
73*cf84ac9aSAndroid Build Coastguard Worker zero_extend_signed_to_ull(st->field ## _nsec)));\
74*cf84ac9aSAndroid Build Coastguard Worker if (st->has_nsec) \
75*cf84ac9aSAndroid Build Coastguard Worker tprintf(", st_" #field "_nsec=%llu", \
76*cf84ac9aSAndroid Build Coastguard Worker zero_extend_signed_to_ull( \
77*cf84ac9aSAndroid Build Coastguard Worker st->field ## _nsec)); \
78*cf84ac9aSAndroid Build Coastguard Worker } while (0)
79*cf84ac9aSAndroid Build Coastguard Worker
80*cf84ac9aSAndroid Build Coastguard Worker PRINT_ST_TIME(atime);
81*cf84ac9aSAndroid Build Coastguard Worker PRINT_ST_TIME(mtime);
82*cf84ac9aSAndroid Build Coastguard Worker PRINT_ST_TIME(ctime);
83*cf84ac9aSAndroid Build Coastguard Worker } else {
84*cf84ac9aSAndroid Build Coastguard Worker tprints(", ...");
85*cf84ac9aSAndroid Build Coastguard Worker }
86*cf84ac9aSAndroid Build Coastguard Worker tprints("}");
87*cf84ac9aSAndroid Build Coastguard Worker }
88