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