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

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright (c) 2017 The strace developers.
       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 <sys/stat.h>
      31                 :            : #include <linux/fcntl.h>
      32                 :            : 
      33                 :            : #include "xlat/statx_masks.h"
      34                 :            : #include "xlat/statx_attrs.h"
      35                 :            : #include "xlat/at_statx_sync_types.h"
      36                 :            : 
      37                 :            : #ifndef AT_STATX_SYNC_TYPE
      38                 :            : #  define AT_STATX_SYNC_TYPE (AT_STATX_FORCE_SYNC | AT_STATX_DONT_SYNC)
      39                 :            : #endif /* !AT_STATX_SYNC_TYPE */
      40                 :            : 
      41                 :            : typedef struct {
      42                 :            :         int64_t sec;
      43                 :            :         int32_t nsec;
      44                 :            :         int32_t reserved;
      45                 :            : } struct_statx_timestamp;
      46                 :            : 
      47                 :            : typedef struct {
      48                 :            :         uint32_t stx_mask; /* What results were written [uncond] */
      49                 :            :         uint32_t stx_blksize; /* Preferred general I/O size [uncond] */
      50                 :            :         uint64_t stx_attributes; /* Flags conveying information about the file
      51                 :            :                                     [uncond] */
      52                 :            : 
      53                 :            :         uint32_t stx_nlink; /* Number of hard links */
      54                 :            :         uint32_t stx_uid; /* User ID of owner */
      55                 :            :         uint32_t stx_gid; /* Group ID of owner */
      56                 :            :         uint16_t stx_mode; /* File mode */
      57                 :            :         uint16_t reserved0[1];
      58                 :            : 
      59                 :            :         uint64_t stx_ino; /* Inode number */
      60                 :            :         uint64_t stx_size; /* File size */
      61                 :            :         uint64_t stx_blocks; /* Number of 512-byte blocks allocated */
      62                 :            :         uint64_t reserved1[1];
      63                 :            : 
      64                 :            :         struct_statx_timestamp stx_atime; /* Last access time */
      65                 :            :         struct_statx_timestamp stx_btime; /* File creation time */
      66                 :            :         struct_statx_timestamp stx_ctime; /* Last attribute change time */
      67                 :            :         struct_statx_timestamp stx_mtime; /* Last data modification time */
      68                 :            : 
      69                 :            :         uint32_t stx_rdev_major; /* Device ID of special file [if bdev/cdev] */
      70                 :            :         uint32_t stx_rdev_minor;
      71                 :            :         uint32_t stx_dev_major; /* ID of device containing file [uncond] */
      72                 :            :         uint32_t stx_dev_minor;
      73                 :            : 
      74                 :            :         uint64_t reserved2[16]; /* Spare space for future expansion */
      75                 :            : } struct_statx;
      76                 :            : 
      77                 :         30 : SYS_FUNC(statx)
      78                 :            : {
      79         [ +  + ]:         30 :         if (entering(tcp)) {
      80                 :         15 :                 print_dirfd(tcp, tcp->u_arg[0]);
      81                 :         15 :                 printpath(tcp, tcp->u_arg[1]);
      82                 :         15 :                 tprints(", ");
      83         [ -  + ]:         15 :                 if (printflags(at_flags, tcp->u_arg[2] & ~AT_STATX_SYNC_TYPE,
      84                 :            :                                NULL))
      85                 :            :                 {
      86                 :          0 :                         tprints("|");
      87                 :            :                 }
      88                 :         15 :                 printxvals(tcp->u_arg[2] & AT_STATX_SYNC_TYPE, "AT_STATX_???",
      89                 :            :                            at_statx_sync_types, NULL);
      90                 :         15 :                 tprints(", ");
      91                 :         15 :                 printflags(statx_masks, tcp->u_arg[3], "STATX_???");
      92                 :         15 :                 tprints(", ");
      93                 :            :         } else {
      94                 :            : #define PRINT_FIELD_U(field) \
      95                 :            :         tprintf(", %s=%llu", #field, (unsigned long long) stx.field)
      96                 :            : 
      97                 :            : #define PRINT_FIELD_TIME(field)                                         \
      98                 :            :         do {                                                            \
      99                 :            :                 tprints(", " #field "=");                           \
     100                 :            :                 tprints(sprinttime(stx.field.sec));                     \
     101                 :            :                 if (stx.field.nsec)                                     \
     102                 :            :                         tprintf(".%09" PRId32, stx.field.nsec);               \
     103                 :            :         } while (0)
     104                 :            : 
     105                 :            :                 struct_statx stx;
     106         [ +  + ]:         15 :                 if (umove_or_printaddr(tcp, tcp->u_arg[4], &stx)) {
     107                 :          5 :                         return 0;
     108                 :            :                 }
     109                 :            : 
     110                 :         10 :                 tprints("{stx_mask=");
     111                 :         10 :                 printflags(statx_masks, stx.stx_mask, "STATX_???");
     112                 :            : 
     113         [ +  - ]:         10 :                 if (!abbrev(tcp)) {
     114                 :         10 :                         PRINT_FIELD_U(stx_blksize);
     115                 :            :                 }
     116                 :            : 
     117                 :         10 :                 tprints(", stx_attributes=");
     118                 :         10 :                 printflags(statx_attrs, stx.stx_attributes, "STATX_ATTR_???");
     119                 :            : 
     120         [ +  - ]:         10 :                 if (!abbrev(tcp)) {
     121                 :         10 :                         PRINT_FIELD_U(stx_nlink);
     122                 :         10 :                         PRINT_FIELD_U(stx_uid);
     123                 :         10 :                         PRINT_FIELD_U(stx_gid);
     124                 :            :                 }
     125                 :            : 
     126                 :         10 :                 tprints(", stx_mode=");
     127                 :         10 :                 print_symbolic_mode_t(stx.stx_mode);
     128                 :            : 
     129         [ +  - ]:         10 :                 if (!abbrev(tcp)) {
     130                 :         10 :                         PRINT_FIELD_U(stx_ino);
     131                 :            :                 }
     132                 :            : 
     133                 :         10 :                 PRINT_FIELD_U(stx_size);
     134                 :            : 
     135         [ +  - ]:         10 :                 if (!abbrev(tcp)) {
     136                 :         10 :                         PRINT_FIELD_U(stx_blocks);
     137         [ +  - ]:         10 :                         PRINT_FIELD_TIME(stx_atime);
     138         [ -  + ]:         10 :                         PRINT_FIELD_TIME(stx_btime);
     139         [ +  - ]:         10 :                         PRINT_FIELD_TIME(stx_ctime);
     140         [ +  - ]:         10 :                         PRINT_FIELD_TIME(stx_mtime);
     141                 :         10 :                         PRINT_FIELD_U(stx_rdev_major);
     142                 :         10 :                         PRINT_FIELD_U(stx_rdev_minor);
     143                 :         10 :                         PRINT_FIELD_U(stx_dev_major);
     144                 :         10 :                         PRINT_FIELD_U(stx_dev_minor);
     145                 :            :                 } else {
     146                 :          0 :                         tprints(", ...");
     147                 :            :                 }
     148                 :         10 :                 tprints("}");
     149                 :            :         }
     150                 :         25 :         return 0;
     151                 :            : }

Generated by: LCOV version 1.12