LCOV - code coverage report
Current view: top level - src/include - pgtar.h (source / functions) Coverage Total Hit
Test: Code coverage Lines: 0.0 % 2 0
Test Date: 2026-01-26 10:56:24 Functions: 0.0 % 1 0
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /*-------------------------------------------------------------------------
       2              :  *
       3              :  * pgtar.h
       4              :  *        Functions for manipulating tarfile datastructures (src/port/tar.c)
       5              :  *
       6              :  *
       7              :  * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
       8              :  * Portions Copyright (c) 1994, Regents of the University of California
       9              :  *
      10              :  * src/include/pgtar.h
      11              :  *
      12              :  *-------------------------------------------------------------------------
      13              :  */
      14              : #ifndef PG_TAR_H
      15              : #define PG_TAR_H
      16              : 
      17              : #define         TAR_BLOCK_SIZE  512
      18              : 
      19              : enum tarError
      20              : {
      21              :         TAR_OK = 0,
      22              :         TAR_NAME_TOO_LONG,
      23              :         TAR_SYMLINK_TOO_LONG,
      24              : };
      25              : 
      26              : /*
      27              :  * Offsets of fields within a 512-byte tar header.
      28              :  *
      29              :  * "tar number" values should be generated using print_tar_number() and can be
      30              :  * read using read_tar_number(). Fields that contain strings are generally
      31              :  * both filled and read using strlcpy().
      32              :  *
      33              :  * The value for the checksum field can be computed using tarChecksum().
      34              :  *
      35              :  * Some fields are not used by PostgreSQL; see tarCreateHeader().
      36              :  */
      37              : enum tarHeaderOffset
      38              : {
      39              :         TAR_OFFSET_NAME = 0,            /* 100 byte string */
      40              :         TAR_OFFSET_MODE = 100,          /* 8 byte tar number, excludes S_IFMT */
      41              :         TAR_OFFSET_UID = 108,           /* 8 byte tar number */
      42              :         TAR_OFFSET_GID = 116,           /* 8 byte tar number */
      43              :         TAR_OFFSET_SIZE = 124,          /* 8 byte tar number */
      44              :         TAR_OFFSET_MTIME = 136,         /* 12 byte tar number */
      45              :         TAR_OFFSET_CHECKSUM = 148,      /* 8 byte tar number */
      46              :         TAR_OFFSET_TYPEFLAG = 156,      /* 1 byte file type, see TAR_FILETYPE_* */
      47              :         TAR_OFFSET_LINKNAME = 157,      /* 100 byte string */
      48              :         TAR_OFFSET_MAGIC = 257,         /* "ustar" with terminating zero byte */
      49              :         TAR_OFFSET_VERSION = 263,       /* "00" */
      50              :         TAR_OFFSET_UNAME = 265,         /* 32 byte string */
      51              :         TAR_OFFSET_GNAME = 297,         /* 32 byte string */
      52              :         TAR_OFFSET_DEVMAJOR = 329,      /* 8 byte tar number */
      53              :         TAR_OFFSET_DEVMINOR = 337,      /* 8 byte tar number */
      54              :         TAR_OFFSET_PREFIX = 345,        /* 155 byte string */
      55              :         /* last 12 bytes of the 512-byte block are unassigned */
      56              : };
      57              : 
      58              : enum tarFileType
      59              : {
      60              :         TAR_FILETYPE_PLAIN = '0',
      61              :         TAR_FILETYPE_SYMLINK = '2',
      62              :         TAR_FILETYPE_DIRECTORY = '5',
      63              : };
      64              : 
      65              : extern enum tarError tarCreateHeader(char *h, const char *filename,
      66              :                                                                          const char *linktarget, pgoff_t size,
      67              :                                                                          mode_t mode, uid_t uid, gid_t gid,
      68              :                                                                          time_t mtime);
      69              : extern uint64 read_tar_number(const char *s, int len);
      70              : extern void print_tar_number(char *s, int len, uint64 val);
      71              : extern int      tarChecksum(char *header);
      72              : 
      73              : /*
      74              :  * Compute the number of padding bytes required for an entry in a tar
      75              :  * archive. We must pad out to a multiple of TAR_BLOCK_SIZE. Since that's
      76              :  * a power of 2, we can use TYPEALIGN().
      77              :  */
      78              : static inline size_t
      79            0 : tarPaddingBytesRequired(size_t len)
      80              : {
      81            0 :         return TYPEALIGN(TAR_BLOCK_SIZE, len) - len;
      82              : }
      83              : 
      84              : #endif
        

Generated by: LCOV version 2.3.2-1