LCOV - code coverage report
Current view: top level - strace_git - print_struct_stat.c (source / functions) Hit Total Coverage
Test: strace-4.16.0.69.f1ea-dirty Code Coverage Lines: 25 25 100.0 %
Date: 2017-03-18 00:38:52 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 12 12 100.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright (c) 1999-2003 Ulrich Drepper <drepper@redhat.com>
       3                 :            :  * Copyright (c) 2004 David S. Miller <davem@nuts.davemloft.net>
       4                 :            :  * Copyright (c) 2003-2005 Roland McGrath <roland@redhat.com>
       5                 :            :  * Copyright (c) 2007 Jan Kratochvil <jan.kratochvil@redhat.com>
       6                 :            :  * Copyright (c) 2009 Denys Vlasenko <dvlasenk@redhat.com>
       7                 :            :  * Copyright (c) 2009-2010 Andreas Schwab <schwab@linux-m68k.org>
       8                 :            :  * Copyright (c) 2012 H.J. Lu <hongjiu.lu@intel.com>
       9                 :            :  * Copyright (c) 2005-2016 Dmitry V. Levin <ldv@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                 :         91 : print_struct_stat(struct tcb *tcp, const struct strace_stat *const st)
      41                 :            : {
      42                 :         91 :         tprints("{");
      43         [ +  + ]:         91 :         if (!abbrev(tcp)) {
      44                 :         61 :                 tprints("st_dev=");
      45                 :         61 :                 print_dev_t(st->dev);
      46                 :         61 :                 tprintf(", st_ino=%llu, st_mode=", st->ino);
      47                 :         61 :                 print_symbolic_mode_t(st->mode);
      48                 :         61 :                 tprintf(", st_nlink=%llu, st_uid=%llu, st_gid=%llu",
      49                 :            :                         st->nlink, st->uid, st->gid);
      50                 :         61 :                 tprintf(", st_blksize=%llu", st->blksize);
      51                 :         61 :                 tprintf(", st_blocks=%llu", st->blocks);
      52                 :            :         } else {
      53                 :         30 :                 tprints("st_mode=");
      54                 :         30 :                 print_symbolic_mode_t(st->mode);
      55                 :            :         }
      56                 :            : 
      57         [ +  + ]:         91 :         switch (st->mode & S_IFMT) {
      58                 :            :         case S_IFCHR: case S_IFBLK:
      59                 :         22 :                 tprints(", st_rdev=");
      60                 :         22 :                 print_dev_t(st->rdev);
      61                 :         22 :                 break;
      62                 :            :         default:
      63                 :         69 :                 tprintf(", st_size=%llu", st->size);
      64                 :         69 :                 break;
      65                 :            :         }
      66                 :            : 
      67         [ +  + ]:         91 :         if (!abbrev(tcp)) {
      68                 :            : #define PRINT_ST_TIME(field)                            \
      69                 :            :         tprints(", st_" #field "=");                        \
      70                 :            :         tprints(sprinttime(st->field));                      \
      71                 :            :         if (st->field ## _nsec)                              \
      72                 :            :                 tprintf(".%09llu", st->field ## _nsec)
      73                 :            : 
      74         [ +  + ]:         61 :                 PRINT_ST_TIME(atime);
      75         [ +  + ]:         61 :                 PRINT_ST_TIME(mtime);
      76         [ +  + ]:         61 :                 PRINT_ST_TIME(ctime);
      77                 :            :         } else {
      78                 :         30 :                 tprints(", ...");
      79                 :            :         }
      80                 :         91 :         tprints("}");
      81                 :         91 : }

Generated by: LCOV version 1.12