1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
#ifndef H_ARCHIVE
#define H_ARCHIVE
/** \ingroup payload
* \file lib/rpmarchive.h
* File archive (aka payload) API.
*/
#define RPMERR_CHECK_ERRNO -32768
/** \ingroup payload
* Error codes for archive and file handling
*/
enum rpmfilesErrorCodes {
RPMERR_ITER_END = -1,
RPMERR_BAD_MAGIC = -2,
RPMERR_BAD_HEADER = -3,
RPMERR_HDR_SIZE = -4,
RPMERR_UNKNOWN_FILETYPE= -5,
RPMERR_MISSING_FILE = -6,
RPMERR_DIGEST_MISMATCH = -7,
RPMERR_INTERNAL = -8,
RPMERR_UNMAPPED_FILE = -9,
RPMERR_ENOENT = -10,
RPMERR_ENOTEMPTY = -11,
RPMERR_FILE_SIZE = -12,
RPMERR_ITER_SKIP = -13,
RPMERR_EXIST_AS_DIR = -14,
RPMERR_OPEN_FAILED = -32768,
RPMERR_CHMOD_FAILED = -32769,
RPMERR_CHOWN_FAILED = -32770,
RPMERR_WRITE_FAILED = -32771,
RPMERR_UTIME_FAILED = -32772,
RPMERR_UNLINK_FAILED = -32773,
RPMERR_RENAME_FAILED = -32774,
RPMERR_SYMLINK_FAILED = -32775,
RPMERR_STAT_FAILED = -32776,
RPMERR_LSTAT_FAILED = -32777,
RPMERR_MKDIR_FAILED = -32778,
RPMERR_RMDIR_FAILED = -32779,
RPMERR_MKNOD_FAILED = -32780,
RPMERR_MKFIFO_FAILED = -32781,
RPMERR_LINK_FAILED = -32782,
RPMERR_READLINK_FAILED = -32783,
RPMERR_READ_FAILED = -32784,
RPMERR_COPY_FAILED = -32785,
RPMERR_LSETFCON_FAILED = -32786,
RPMERR_SETCAP_FAILED = -32787,
};
#ifdef __cplusplus
extern "C" {
#endif
/** \ingroup payload
* Return formatted error message on payload handling failure.
* @param rc error code
* @return formatted error string (malloced)
*/
char * rpmfileStrerror(int rc);
/** \ingroup payload
* Get new file iterator for writing the archive content.
* The returned rpmfi will only visit the files needing some content.
* You need to provide the content using rpmfiArchiveWrite() or
* rpmfiArchiveWriteFile(). Make sure to close the rpmfi with
* rpmfiArchiveClose() to get the trailer written.
* rpmfiSetFX() is not supported for this type of iterator.
* @param fd file
* @param files file info
* @return new rpmfi
*/
rpmfi rpmfiNewArchiveWriter(FD_t fd, rpmfiles files);
/** \ingroup payload
* Get new file iterator for looping over the archive content.
* Returned rpmfi visites files in the order they are read from the payload.
* Content of the regular files can be retrieved with rpmfiArchiveRead() or
* rpmfiArchiveReadToFile() when they are visited with rpmfiNext().
* rpmfiSetFX() is not supported for this type of iterator.
* @param fd file
* @param files file info
* @param itype how to handle hard links. See rpmFileIter.
* @return new rpmfi
*/
rpmfi rpmfiNewArchiveReader(FD_t fd, rpmfiles files, int itype);
/** \ingroup payload
* Close payload archive
* @param fi file info
* @return > 0 on error
*/
int rpmfiArchiveClose(rpmfi fi);
/** \ingroup payload
* Return current position in payload archive
* @param fi file info
* @return position
*/
rpm_loff_t rpmfiArchiveTell(rpmfi fi);
/** \ingroup payload
* Write content into current file in archive
* @param fi file info
* @param buf pointer to content
* @param size number of bytes to write
* @return bytes actually written
*/
size_t rpmfiArchiveWrite(rpmfi fi, const void * buf, size_t size);
/** \ingroup payload
* Write content from given file into current file in archive
* @param fi file info
* @param fd file descriptor of file to read
* @return > 0 on error
*/
int rpmfiArchiveWriteFile(rpmfi fi, FD_t fd);
/** \ingroup payload
* Read content from current file in archive
* @param fi file info
* @param buf pointer to buffer
* @param size number of bytes to read
* @return bytes actually read
*/
size_t rpmfiArchiveRead(rpmfi fi, void * buf, size_t size);
/** \ingroup payload
* Has current file content stored in the archive
* @param fi file info
* @ return 1 for regular files but 0 for hardlinks without content
*/
int rpmfiArchiveHasContent(rpmfi fi);
/** \ingroup payload
* Write content from current file in archive to a file
* @param fi file info
* @param fd file descriptor of file to write to
* @param nodigest omit checksum check if 1
* @return > 0 on error
*/
int rpmfiArchiveReadToFile(rpmfi fi, FD_t fd, int nodigest);
#ifdef __cplusplus
}
#endif
#endif /* H_ARCHIVE */
|