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

           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                 :            : 
      30                 :            : #include DEF_MPERS_TYPE(struct_statfs)
      31                 :            : #include DEF_MPERS_TYPE(struct_statfs64)
      32                 :            : 
      33                 :            : #include <linux/types.h>
      34                 :            : #include <asm/statfs.h>
      35                 :            : typedef struct statfs struct_statfs;
      36                 :            : typedef struct statfs64 struct_statfs64;
      37                 :            : 
      38                 :            : #include MPERS_DEFS
      39                 :            : 
      40                 :            : #include "statfs.h"
      41                 :            : 
      42                 :         30 : MPERS_PRINTER_DECL(bool, fetch_struct_statfs,
      43                 :            :                    struct tcb *const tcp, const kernel_ulong_t addr,
      44                 :            :                    struct strace_statfs *const p)
      45                 :            : {
      46                 :            :         struct_statfs b;
      47                 :            : 
      48         [ +  + ]:         30 :         if (umove_or_printaddr(tcp, addr, &b))
      49                 :         10 :                 return false;
      50                 :            : 
      51                 :         20 :         p->f_type = zero_extend_signed_to_ull(b.f_type);
      52                 :         20 :         p->f_bsize = zero_extend_signed_to_ull(b.f_bsize);
      53                 :         20 :         p->f_blocks = zero_extend_signed_to_ull(b.f_blocks);
      54                 :         20 :         p->f_bfree = zero_extend_signed_to_ull(b.f_bfree);
      55                 :         20 :         p->f_bavail = zero_extend_signed_to_ull(b.f_bavail);
      56                 :         20 :         p->f_files = zero_extend_signed_to_ull(b.f_files);
      57                 :         20 :         p->f_ffree = zero_extend_signed_to_ull(b.f_ffree);
      58                 :            : #if defined HAVE_STRUCT_STATFS_F_FSID_VAL
      59                 :         20 :         p->f_fsid[0] = zero_extend_signed_to_ull(b.f_fsid.val[0]);
      60                 :         20 :         p->f_fsid[1] = zero_extend_signed_to_ull(b.f_fsid.val[1]);
      61                 :            : #elif defined HAVE_STRUCT_STATFS_F_FSID___VAL
      62                 :            :         p->f_fsid[0] = zero_extend_signed_to_ull(b.f_fsid.__val[0]);
      63                 :            :         p->f_fsid[1] = zero_extend_signed_to_ull(b.f_fsid.__val[1]);
      64                 :            : #endif
      65                 :         20 :         p->f_namelen = zero_extend_signed_to_ull(b.f_namelen);
      66                 :            : #ifdef HAVE_STRUCT_STATFS_F_FRSIZE
      67                 :         20 :         p->f_frsize = zero_extend_signed_to_ull(b.f_frsize);
      68                 :            : #endif
      69                 :            : #ifdef HAVE_STRUCT_STATFS_F_FLAGS
      70                 :         20 :         p->f_flags = zero_extend_signed_to_ull(b.f_flags);
      71                 :            : #endif
      72                 :            : 
      73                 :         30 :         return true;
      74                 :            : }
      75                 :            : 
      76                 :            : #if defined ARM || (defined AARCH64 && defined IN_MPERS)
      77                 :            : /* See arch/arm/kernel/sys_oabi-compat.c for details. */
      78                 :            : # define COMPAT_STATFS64_PADDED_SIZE (sizeof(struct_statfs64) + 4)
      79                 :            : #endif
      80                 :            : 
      81                 :          8 : MPERS_PRINTER_DECL(bool, fetch_struct_statfs64,
      82                 :            :                    struct tcb *const tcp, const kernel_ulong_t addr,
      83                 :            :                    const kernel_ulong_t size, struct strace_statfs *const p)
      84                 :            : {
      85                 :            :         struct_statfs64 b;
      86                 :            : 
      87         [ +  + ]:          8 :         if (sizeof(b) != size
      88                 :            : #ifdef COMPAT_STATFS64_PADDED_SIZE
      89                 :            :             && sizeof(b) != COMPAT_STATFS64_PADDED_SIZE
      90                 :            : #endif
      91                 :            :            ) {
      92                 :          2 :                 printaddr(addr);
      93                 :          2 :                 return false;
      94                 :            :         }
      95                 :            : 
      96         [ +  + ]:          6 :         if (umove_or_printaddr(tcp, addr, &b))
      97                 :          2 :                 return false;
      98                 :            : 
      99                 :          4 :         p->f_type = zero_extend_signed_to_ull(b.f_type);
     100                 :          4 :         p->f_bsize = zero_extend_signed_to_ull(b.f_bsize);
     101                 :          4 :         p->f_blocks = zero_extend_signed_to_ull(b.f_blocks);
     102                 :          4 :         p->f_bfree = zero_extend_signed_to_ull(b.f_bfree);
     103                 :          4 :         p->f_bavail = zero_extend_signed_to_ull(b.f_bavail);
     104                 :          4 :         p->f_files = zero_extend_signed_to_ull(b.f_files);
     105                 :          4 :         p->f_ffree = zero_extend_signed_to_ull(b.f_ffree);
     106                 :            : #if defined HAVE_STRUCT_STATFS64_F_FSID_VAL
     107                 :          4 :         p->f_fsid[0] = zero_extend_signed_to_ull(b.f_fsid.val[0]);
     108                 :          4 :         p->f_fsid[1] = zero_extend_signed_to_ull(b.f_fsid.val[1]);
     109                 :            : #elif defined HAVE_STRUCT_STATFS64_F_FSID___VAL
     110                 :            :         p->f_fsid[0] = zero_extend_signed_to_ull(b.f_fsid.__val[0]);
     111                 :            :         p->f_fsid[1] = zero_extend_signed_to_ull(b.f_fsid.__val[1]);
     112                 :            : #endif
     113                 :          4 :         p->f_namelen = zero_extend_signed_to_ull(b.f_namelen);
     114                 :            : #ifdef HAVE_STRUCT_STATFS64_F_FRSIZE
     115                 :          4 :         p->f_frsize = zero_extend_signed_to_ull(b.f_frsize);
     116                 :            : #endif
     117                 :            : #ifdef HAVE_STRUCT_STATFS64_F_FLAGS
     118                 :          4 :         p->f_flags = zero_extend_signed_to_ull(b.f_flags);
     119                 :            : #endif
     120                 :            : 
     121                 :          8 :         return true;
     122                 :            : }

Generated by: LCOV version 1.12