rpm  4.18.0
rpmfiles.h
Go to the documentation of this file.
1 #ifndef _RPMFILES_H
2 #define _RPMFILES_H
3 
8 #include <sys/types.h>
9 #include <sys/stat.h>
10 #include <unistd.h>
11 
12 #include <rpm/rpmtypes.h>
13 
21 typedef enum rpmFileTypes_e {
22  PIPE = 1,
23  CDEV = 2,
24  XDIR = 4,
25  BDEV = 6,
26  REG = 8,
27  LINK = 10,
28  SOCK = 12
30 
34 typedef enum rpmfileState_e {
35  RPMFILE_STATE_MISSING = -1, /* used for unavailable data */
42 
43 #define RPMFILE_IS_INSTALLED(_x) ((_x) == RPMFILE_STATE_NORMAL || (_x) == RPMFILE_STATE_NETSHARED)
44 
50  RPMFILE_CONFIG = (1 << 0),
51  RPMFILE_DOC = (1 << 1),
52  RPMFILE_ICON = (1 << 2),
53  RPMFILE_MISSINGOK = (1 << 3),
54  RPMFILE_NOREPLACE = (1 << 4),
55  RPMFILE_SPECFILE = (1 << 5),
56  RPMFILE_GHOST = (1 << 6),
57  RPMFILE_LICENSE = (1 << 7),
58  RPMFILE_README = (1 << 8),
59  /* bits 9-10 unused */
60  RPMFILE_PUBKEY = (1 << 11),
61  RPMFILE_ARTIFACT = (1 << 12),
62 };
63 
65 
66 #define RPMFILE_ALL ~(RPMFILE_NONE)
67 
74  RPMVERIFY_MD5 = (1 << 0),
76  RPMVERIFY_FILESIZE = (1 << 1),
77  RPMVERIFY_LINKTO = (1 << 2),
78  RPMVERIFY_USER = (1 << 3),
79  RPMVERIFY_GROUP = (1 << 4),
80  RPMVERIFY_MTIME = (1 << 5),
81  RPMVERIFY_MODE = (1 << 6),
82  RPMVERIFY_RDEV = (1 << 7),
83  RPMVERIFY_CAPS = (1 << 8),
84  /* bits 9-14 unused, reserved for rpmVerifyAttrs */
85  RPMVERIFY_CONTEXTS = (1 << 15),
86  /* bits 16-22 used in rpmVerifyFlags */
87  /* bits 23-27 used in rpmQueryFlags */
89  RPMVERIFY_READFAIL = (1 << 29),
90  RPMVERIFY_LSTATFAIL = (1 << 30),
91  RPMVERIFY_LGETFILECONFAIL = (1 << 31)
92 };
93 
95 
96 #define RPMVERIFY_ALL ~(RPMVERIFY_NONE)
97 #define RPMVERIFY_FAILURES \
98  (RPMVERIFY_LSTATFAIL|RPMVERIFY_READFAIL|RPMVERIFY_READLINKFAIL|RPMVERIFY_LGETFILECONFAIL)
99 
103 typedef enum rpmFileAction_e {
105  FA_CREATE = 1,
106  FA_COPYIN = 2,
108  FA_BACKUP = 4,
109  FA_SAVE = 5,
110  FA_SKIP = 6,
112  FA_ERASE = 8,
116  FA_TOUCH = 12,
117  /* bits 16-31 reserved */
119 
120 #define XFA_SKIPPING(_a) \
121  ((_a) == FA_SKIP || (_a) == FA_SKIPNSTATE || (_a) == FA_SKIPNETSHARED || (_a) == FA_SKIPCOLOR)
122 
123 #define XFA_CREATING(_a) \
124  ((_a) == FA_CREATE || (_a) == FA_BACKUP || (_a) == FA_SAVE || (_a) == FA_ALTNAME)
125 
130  char * oldPath;
131  char * newPath;
132 };
133 
136  RPMFI_KEEPHEADER = (1 << 0),
137  RPMFI_NOFILECLASS = (1 << 1),
138  RPMFI_NOFILEDEPS = (1 << 2),
139  RPMFI_NOFILELANGS = (1 << 3),
140  RPMFI_NOFILEUSER = (1 << 4),
141  RPMFI_NOFILEGROUP = (1 << 5),
142  RPMFI_NOFILEMODES = (1 << 6),
143  RPMFI_NOFILESIZES = (1 << 7),
144  RPMFI_NOFILECAPS = (1 << 8),
146  RPMFI_NOFILEDIGESTS = (1 << 10),
147  RPMFI_NOFILEMTIMES = (1 << 11),
148  RPMFI_NOFILERDEVS = (1 << 12),
149  RPMFI_NOFILEINODES = (1 << 13),
150  RPMFI_NOFILESTATES = (1 << 14),
151  RPMFI_NOFILECOLORS = (1 << 15),
153  RPMFI_NOFILEFLAGS = (1 << 17),
156 };
157 
159 
160 #define RPMFI_FLAGS_ERASE \
161  (RPMFI_NOFILECLASS | RPMFI_NOFILELANGS | \
162  RPMFI_NOFILEMTIMES | RPMFI_NOFILERDEVS | \
163  RPMFI_NOFILEVERIFYFLAGS)
164 
165 #define RPMFI_FLAGS_INSTALL \
166  (RPMFI_NOFILECLASS | RPMFI_NOFILEVERIFYFLAGS)
167 
168 #define RPMFI_FLAGS_VERIFY \
169  (RPMFI_NOFILECLASS | RPMFI_NOFILEDEPS | RPMFI_NOFILELANGS | \
170  RPMFI_NOFILECOLORS)
171 
172 #define RPMFI_FLAGS_QUERY \
173  (RPMFI_NOFILECLASS | RPMFI_NOFILEDEPS | RPMFI_NOFILELANGS | \
174  RPMFI_NOFILECOLORS | RPMFI_NOFILEVERIFYFLAGS)
175 
176 #define RPMFI_FLAGS_FILETRIGGER \
177  (RPMFI_NOFILECLASS | RPMFI_NOFILEDEPS | RPMFI_NOFILELANGS | \
178  RPMFI_NOFILEUSER | RPMFI_NOFILEGROUP | RPMFI_NOFILEMODES | \
179  RPMFI_NOFILESIZES | RPMFI_NOFILECAPS | RPMFI_NOFILELINKTOS | \
180  RPMFI_NOFILEDIGESTS | RPMFI_NOFILEMTIMES | RPMFI_NOFILERDEVS | \
181  RPMFI_NOFILEINODES | RPMFI_NOFILECOLORS | \
182  RPMFI_NOFILEVERIFYFLAGS | RPMFI_NOFILEFLAGS)
183 
184 #define RPMFI_FLAGS_ONLY_FILENAMES \
185  (RPMFI_FLAGS_FILETRIGGER | RPMFI_NOFILESTATES)
186 
187 typedef enum rpmFileIter_e {
196 
197 #define RPMFILEITERMAX 6
198 
199 #ifdef __cplusplus
200 extern "C" {
201 #endif
202 
212 
219 
226 
233 
240 
249 int rpmfilesFindFN(rpmfiles files, const char * fn);
250 
259 int rpmfilesFindOFN(rpmfiles files, const char * fn);
260 
261 rpmfi rpmfilesIter(rpmfiles files, int itype);
262 
269 
276 
285 int rpmfilesCompare(rpmfiles afi, int aix, rpmfiles bfi, int bix);
286 
293 const char * rpmfilesBN(rpmfiles fi, int ix);
294 
306 const char * rpmfilesDN(rpmfiles fi, int jx);
307 
314 int rpmfilesDI(rpmfiles fi, int ix);
315 
322 char * rpmfilesFN(rpmfiles fi, int ix);
323 
330 int rpmfilesODI(rpmfiles fi, int ix);
331 
338 const char * rpmfilesOBN(rpmfiles fi, int ix);
339 
351 const char * rpmfilesODN(rpmfiles fi, int jx);
352 
359 char * rpmfilesOFN(rpmfiles fi, int ix);
360 
368 
376 
383 const char * rpmfilesFLink(rpmfiles fi, int ix);
384 
392 
400 
407 const char * rpmfilesFClass(rpmfiles fi, int ix);
408 
416 uint32_t rpmfilesFDepends(rpmfiles fi, int ix, const uint32_t ** fddictp);
417 
424 uint32_t rpmfilesFNlink(rpmfiles fi, int ix);
425 
434 uint32_t rpmfilesFLinks(rpmfiles fi, int ix, const int ** files);
435 
442 const char * rpmfilesFLangs(rpmfiles fi, int ix);
443 
451 
459 
468 const unsigned char * rpmfilesFDigest(rpmfiles fi, int ix, int *algo, size_t *len);
469 
477 const unsigned char * rpmfilesFSignature(rpmfiles fi, int ix, size_t *len);
478 
487 const unsigned char * rpmfilesVSignature(rpmfiles fi, int ix, size_t *len,
488  uint16_t *algo);
489 
497 
505 
513 
520 const char * rpmfilesFUser(rpmfiles fi, int ix);
521 
528 const char * rpmfilesFGroup(rpmfiles fi, int ix);
529 
538 const char * rpmfilesFCaps(rpmfiles fi, int ix);
539 
548 int rpmfilesStat(rpmfiles fi, int ix, int flags, struct stat *sb);
549 
558 
559 #ifdef __cplusplus
560 }
561 #endif
562 
563 #endif /* _RPMFILES_H */
int rpmfilesStat(rpmfiles fi, int ix, int flags, struct stat *sb)
Map file stat(2) info.
rpm_count_t rpmfilesDC(rpmfiles fi)
Return directory count from file info set.
rpmVerifyAttrs rpmfilesVFlags(rpmfiles fi, int ix)
Return file verify flags from file info set.
char * rpmfilesFN(rpmfiles fi, int ix)
Return file name from file info set.
const char * rpmfilesFUser(rpmfiles fi, int ix)
Return file owner from file info set.
enum rpmFileTypes_e rpmFileTypes
File types.
const char * rpmfilesFGroup(rpmfiles fi, int ix)
Return file group from file info set.
rpm_mode_t rpmfilesFMode(rpmfiles fi, int ix)
Return file mode from file info set.
rpm_ino_t rpmfilesFInode(rpmfiles fi, int ix)
Return file inode from file info set.
int rpmfilesFindFN(rpmfiles files, const char *fn)
Return file index of the given file name or -1 if file is not in the rpmfi.
rpmfiles rpmfilesLink(rpmfiles fi)
Reference a file info set instance.
rpmfiles rpmfilesNew(rpmstrPool pool, Header h, rpmTagVal tagN, rpmfiFlags flags)
Create and load a file info set.
const char * rpmfilesFLink(rpmfiles fi, int ix)
Return file linkto (i.e.
const char * rpmfilesODN(rpmfiles fi, int jx)
Return original directory name from file info set.
const char * rpmfilesFClass(rpmfiles fi, int ix)
Return file class from file info set.
const char * rpmfilesFCaps(rpmfiles fi, int ix)
Return textual representation of file capabilities from file info set.
rpmfileState rpmfilesFState(rpmfiles fi, int ix)
Return file state from file info set.
const unsigned char * rpmfilesFSignature(rpmfiles fi, int ix, size_t *len)
Return file (binary) digest of file info set.
uint32_t rpmfilesFLinks(rpmfiles fi, int ix, const int **files)
Return (calculated) file nlink count from file info set.
rpm_color_t rpmfilesFColor(rpmfiles fi, int ix)
Return file color bits from file info set.
rpmfileAttrs rpmfilesFFlags(rpmfiles fi, int ix)
Return file flags from file info set.
enum rpmFileAction_e rpmFileAction
File disposition(s) during package install/erase transaction.
rpm_rdev_t rpmfilesFRdev(rpmfiles fi, int ix)
Return file rdev from file info set.
const unsigned char * rpmfilesFDigest(rpmfiles fi, int ix, int *algo, size_t *len)
Return file (binary) digest of file info set.
int rpmfilesDI(rpmfiles fi, int ix)
Return directory index from file info set.
rpmFileAction_e
File disposition(s) during package install/erase transaction.
Definition: rpmfiles.h:103
int rpmfilesCompare(rpmfiles afi, int aix, rpmfiles bfi, int bix)
Return file info comparison.
int rpmfilesDigestAlgo(rpmfiles fi)
Return digest algorithm of a file info set.
rpmVerifyAttrs rpmfilesVerify(rpmfiles fi, int ix, rpmVerifyAttrs omitMask)
Verify file attributes (including digest).
rpm_loff_t rpmfilesFSize(rpmfiles fi, int ix)
Return file size from file info set.
int rpmfilesFindOFN(rpmfiles files, const char *fn)
Return file index of the given original file name or -1 if file is not in the rpmfi.
rpmfiles rpmfilesFree(rpmfiles fi)
Destroy a file info set.
int rpmfilesODI(rpmfiles fi, int ix)
Return original directory index from file info set.
const char * rpmfilesFLangs(rpmfiles fi, int ix)
Return file language(s) from file info set.
const unsigned char * rpmfilesVSignature(rpmfiles fi, int ix, size_t *len, uint16_t *algo)
Return file verity signature (binary)
char * rpmfilesOFN(rpmfiles fi, int ix)
Return original file name from file info set.
rpmFileTypes_e
File types.
Definition: rpmfiles.h:21
rpm_count_t rpmfilesFC(rpmfiles fi)
Return file count from file info set.
uint32_t rpmfilesFNlink(rpmfiles fi, int ix)
Return (calculated) file nlink count from file info set.
const char * rpmfilesBN(rpmfiles fi, int ix)
Return base name from file info set.
uint32_t rpmfilesFDepends(rpmfiles fi, int ix, const uint32_t **fddictp)
Return file depends dictionary from file info set.
const char * rpmfilesOBN(rpmfiles fi, int ix)
Return original base name from file info set.
rpm_time_t rpmfilesFMtime(rpmfiles fi, int ix)
Return file modify time from file info set.
const char * rpmfilesDN(rpmfiles fi, int jx)
Return directory name from file info set.
rpm_color_t rpmfilesColor(rpmfiles files)
Return union of all file color bits from file info set.
@ FA_BACKUP
Definition: rpmfiles.h:108
@ FA_CREATE
Definition: rpmfiles.h:105
@ FA_UNKNOWN
Definition: rpmfiles.h:104
@ FA_COPYIN
Definition: rpmfiles.h:106
@ FA_SKIPNSTATE
Definition: rpmfiles.h:113
@ FA_SAVE
Definition: rpmfiles.h:109
@ FA_COPYOUT
Definition: rpmfiles.h:107
@ FA_SKIP
Definition: rpmfiles.h:110
@ FA_SKIPCOLOR
Definition: rpmfiles.h:115
@ FA_ALTNAME
Definition: rpmfiles.h:111
@ FA_TOUCH
Definition: rpmfiles.h:116
@ FA_ERASE
Definition: rpmfiles.h:112
@ FA_SKIPNETSHARED
Definition: rpmfiles.h:114
@ XDIR
Definition: rpmfiles.h:24
@ CDEV
Definition: rpmfiles.h:23
@ SOCK
Definition: rpmfiles.h:28
@ PIPE
Definition: rpmfiles.h:22
@ REG
Definition: rpmfiles.h:26
@ BDEV
Definition: rpmfiles.h:25
@ LINK
Definition: rpmfiles.h:27
uint32_t rpm_ino_t
Definition: rpmtypes.h:56
uint32_t rpm_count_t
Definition: rpmtypes.h:29
struct rpmfi_s * rpmfi
Definition: rpmtypes.h:66
rpm_tag_t rpmTagVal
Definition: rpmtypes.h:30
struct rpmfiles_s * rpmfiles
Definition: rpmtypes.h:67
uint32_t rpmFlags
Definition: rpmtypes.h:42
uint32_t rpm_color_t
Definition: rpmtypes.h:38
uint16_t rpm_mode_t
Definition: rpmtypes.h:53
uint64_t rpm_loff_t
Definition: rpmtypes.h:51
struct headerToken_s * Header
RPM header and data retrieval types.
Definition: rpmtypes.h:24
uint32_t rpm_time_t
Definition: rpmtypes.h:52
uint16_t rpm_rdev_t
Definition: rpmtypes.h:54
rpmVerifyAttrs_e
Exported file verify attributes (ie RPMTAG_FILEVERIFYFLAGS) + bits used for reporting failures.
Definition: rpmfiles.h:72
@ RPMVERIFY_CAPS
Definition: rpmfiles.h:83
@ RPMVERIFY_MTIME
Definition: rpmfiles.h:80
@ RPMVERIFY_MD5
Definition: rpmfiles.h:74
@ RPMVERIFY_LGETFILECONFAIL
Definition: rpmfiles.h:91
@ RPMVERIFY_CONTEXTS
Definition: rpmfiles.h:85
@ RPMVERIFY_RDEV
Definition: rpmfiles.h:82
@ RPMVERIFY_MODE
Definition: rpmfiles.h:81
@ RPMVERIFY_GROUP
Definition: rpmfiles.h:79
@ RPMVERIFY_USER
Definition: rpmfiles.h:78
@ RPMVERIFY_FILESIZE
Definition: rpmfiles.h:76
@ RPMVERIFY_NONE
Definition: rpmfiles.h:73
@ RPMVERIFY_READFAIL
Definition: rpmfiles.h:89
@ RPMVERIFY_READLINKFAIL
Definition: rpmfiles.h:88
@ RPMVERIFY_LSTATFAIL
Definition: rpmfiles.h:90
@ RPMVERIFY_FILEDIGEST
Definition: rpmfiles.h:75
@ RPMVERIFY_LINKTO
Definition: rpmfiles.h:77
rpmFileIter_e
Definition: rpmfiles.h:187
@ RPMFI_ITER_READ_ARCHIVE_CONTENT_FIRST
Definition: rpmfiles.h:192
@ RPMFI_ITER_WRITE_ARCHIVE
Definition: rpmfiles.h:190
@ RPMFI_ITER_READ_ARCHIVE_OMIT_HARDLINKS
Definition: rpmfiles.h:193
@ RPMFI_ITER_FWD
Definition: rpmfiles.h:188
@ RPMFI_ITER_INTERVAL
Definition: rpmfiles.h:194
@ RPMFI_ITER_READ_ARCHIVE
Definition: rpmfiles.h:191
@ RPMFI_ITER_BACK
Definition: rpmfiles.h:189
rpmfiFlags_e
Definition: rpmfiles.h:134
@ RPMFI_NOVERITYSIGNATURES
Definition: rpmfiles.h:155
@ RPMFI_NOFILELANGS
Definition: rpmfiles.h:139
@ RPMFI_NOFILEMTIMES
Definition: rpmfiles.h:147
@ RPMFI_NOFILEVERIFYFLAGS
Definition: rpmfiles.h:152
@ RPMFI_NOFILEDIGESTS
Definition: rpmfiles.h:146
@ RPMFI_NOFILERDEVS
Definition: rpmfiles.h:148
@ RPMFI_NOFILEFLAGS
Definition: rpmfiles.h:153
@ RPMFI_NOFILEINODES
Definition: rpmfiles.h:149
@ RPMFI_NOFILESTATES
Definition: rpmfiles.h:150
@ RPMFI_NOFILELINKTOS
Definition: rpmfiles.h:145
@ RPMFI_NOFILECAPS
Definition: rpmfiles.h:144
@ RPMFI_NOFILEMODES
Definition: rpmfiles.h:142
@ RPMFI_NOHEADER
Definition: rpmfiles.h:135
@ RPMFI_NOFILESIGNATURES
Definition: rpmfiles.h:154
@ RPMFI_KEEPHEADER
Definition: rpmfiles.h:136
@ RPMFI_NOFILESIZES
Definition: rpmfiles.h:143
@ RPMFI_NOFILECOLORS
Definition: rpmfiles.h:151
@ RPMFI_NOFILEUSER
Definition: rpmfiles.h:140
@ RPMFI_NOFILEGROUP
Definition: rpmfiles.h:141
@ RPMFI_NOFILEDEPS
Definition: rpmfiles.h:138
@ RPMFI_NOFILECLASS
Definition: rpmfiles.h:137
enum rpmFileIter_e rpmFileIter
rpmfileAttrs_e
Exported File Attributes (ie RPMTAG_FILEFLAGS)
Definition: rpmfiles.h:48
@ RPMFILE_ARTIFACT
Definition: rpmfiles.h:61
@ RPMFILE_MISSINGOK
Definition: rpmfiles.h:53
@ RPMFILE_ICON
Definition: rpmfiles.h:52
@ RPMFILE_DOC
Definition: rpmfiles.h:51
@ RPMFILE_GHOST
Definition: rpmfiles.h:56
@ RPMFILE_SPECFILE
Definition: rpmfiles.h:55
@ RPMFILE_CONFIG
Definition: rpmfiles.h:50
@ RPMFILE_LICENSE
Definition: rpmfiles.h:57
@ RPMFILE_NONE
Definition: rpmfiles.h:49
@ RPMFILE_NOREPLACE
Definition: rpmfiles.h:54
@ RPMFILE_PUBKEY
Definition: rpmfiles.h:60
@ RPMFILE_README
Definition: rpmfiles.h:58
enum rpmfileState_e rpmfileState
File States (when installed).
rpmfileState_e
File States (when installed).
Definition: rpmfiles.h:34
@ RPMFILE_STATE_NORMAL
Definition: rpmfiles.h:36
@ RPMFILE_STATE_REPLACED
Definition: rpmfiles.h:37
@ RPMFILE_STATE_NOTINSTALLED
Definition: rpmfiles.h:38
@ RPMFILE_STATE_NETSHARED
Definition: rpmfiles.h:39
@ RPMFILE_STATE_MISSING
Definition: rpmfiles.h:35
@ RPMFILE_STATE_WRONGCOLOR
Definition: rpmfiles.h:40
rpmFlags rpmfileAttrs
Definition: rpmfiles.h:64
rpmFlags rpmVerifyAttrs
Definition: rpmfiles.h:94
rpmFlags rpmfiFlags
Definition: rpmfiles.h:158
rpmfi rpmfilesIter(rpmfiles files, int itype)
Typedefs for RPM abstract data types.
struct rpmstrPool_s * rpmstrPool
Definition: rpmtypes.h:84
We pass these around as an array with a sentinel.
Definition: rpmfiles.h:129
char * oldPath
Definition: rpmfiles.h:130
char * newPath
Definition: rpmfiles.h:131