PostgreSQL Source Code
git master
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
Functions
Variables
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
Data Fields
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
f
h
i
n
o
p
r
s
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
Files
File List
Globals
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
pgtar.h
Go to the documentation of this file.
1
/*-------------------------------------------------------------------------
2
*
3
* pgtar.h
4
* Functions for manipulating tarfile datastructures (src/port/tar.c)
5
*
6
*
7
* Portions Copyright (c) 1996-2024, 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
tarPaddingBytesRequired
(
size_t
len
)
80
{
81
return
TYPEALIGN
(
TAR_BLOCK_SIZE
,
len
) -
len
;
82
}
83
84
#endif
TYPEALIGN
#define TYPEALIGN(ALIGNVAL, LEN)
Definition:
c.h:809
val
long val
Definition:
informix.c:689
mode
static PgChecksumMode mode
Definition:
pg_checksums.c:55
len
const void size_t len
Definition:
pg_crc32c_sse42.c:24
filename
static char * filename
Definition:
pg_dumpall.c:119
read_tar_number
uint64 read_tar_number(const char *s, int len)
Definition:
tar.c:58
tarPaddingBytesRequired
static size_t tarPaddingBytesRequired(size_t len)
Definition:
pgtar.h:79
tarChecksum
int tarChecksum(char *header)
Definition:
tar.c:90
tarFileType
tarFileType
Definition:
pgtar.h:59
TAR_FILETYPE_SYMLINK
@ TAR_FILETYPE_SYMLINK
Definition:
pgtar.h:61
TAR_FILETYPE_DIRECTORY
@ TAR_FILETYPE_DIRECTORY
Definition:
pgtar.h:62
TAR_FILETYPE_PLAIN
@ TAR_FILETYPE_PLAIN
Definition:
pgtar.h:60
tarHeaderOffset
tarHeaderOffset
Definition:
pgtar.h:38
TAR_OFFSET_DEVMINOR
@ TAR_OFFSET_DEVMINOR
Definition:
pgtar.h:53
TAR_OFFSET_MODE
@ TAR_OFFSET_MODE
Definition:
pgtar.h:40
TAR_OFFSET_PREFIX
@ TAR_OFFSET_PREFIX
Definition:
pgtar.h:54
TAR_OFFSET_VERSION
@ TAR_OFFSET_VERSION
Definition:
pgtar.h:49
TAR_OFFSET_DEVMAJOR
@ TAR_OFFSET_DEVMAJOR
Definition:
pgtar.h:52
TAR_OFFSET_UID
@ TAR_OFFSET_UID
Definition:
pgtar.h:41
TAR_OFFSET_TYPEFLAG
@ TAR_OFFSET_TYPEFLAG
Definition:
pgtar.h:46
TAR_OFFSET_NAME
@ TAR_OFFSET_NAME
Definition:
pgtar.h:39
TAR_OFFSET_SIZE
@ TAR_OFFSET_SIZE
Definition:
pgtar.h:43
TAR_OFFSET_GNAME
@ TAR_OFFSET_GNAME
Definition:
pgtar.h:51
TAR_OFFSET_CHECKSUM
@ TAR_OFFSET_CHECKSUM
Definition:
pgtar.h:45
TAR_OFFSET_GID
@ TAR_OFFSET_GID
Definition:
pgtar.h:42
TAR_OFFSET_LINKNAME
@ TAR_OFFSET_LINKNAME
Definition:
pgtar.h:47
TAR_OFFSET_MTIME
@ TAR_OFFSET_MTIME
Definition:
pgtar.h:44
TAR_OFFSET_UNAME
@ TAR_OFFSET_UNAME
Definition:
pgtar.h:50
TAR_OFFSET_MAGIC
@ TAR_OFFSET_MAGIC
Definition:
pgtar.h:48
tarCreateHeader
enum tarError tarCreateHeader(char *h, const char *filename, const char *linktarget, pgoff_t size, mode_t mode, uid_t uid, gid_t gid, time_t mtime)
Definition:
tar.c:114
tarError
tarError
Definition:
pgtar.h:20
TAR_SYMLINK_TOO_LONG
@ TAR_SYMLINK_TOO_LONG
Definition:
pgtar.h:23
TAR_OK
@ TAR_OK
Definition:
pgtar.h:21
TAR_NAME_TOO_LONG
@ TAR_NAME_TOO_LONG
Definition:
pgtar.h:22
TAR_BLOCK_SIZE
#define TAR_BLOCK_SIZE
Definition:
pgtar.h:17
print_tar_number
void print_tar_number(char *s, int len, uint64 val)
Definition:
tar.c:22
size
static pg_noinline void Size size
Definition:
slab.c:607
gid_t
int gid_t
Definition:
win32_port.h:245
pgoff_t
#define pgoff_t
Definition:
win32_port.h:207
uid_t
int uid_t
Definition:
win32_port.h:244
src
include
pgtar.h
Generated on Wed Nov 27 2024 06:13:27 for PostgreSQL Source Code by
1.9.1