rpm 5.2.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

iosm.h
Go to the documentation of this file.
1 #ifndef H_IOSM
2 #define H_IOSM
3
9 #include <rpmiotypes.h>
10 #include <rpmsw.h>
11
15 typedef /*@abstract@*/ struct iosm_s * IOSM_t;
16
17 /*@-exportlocal@*/
18 /*@unchecked@*/
19 extern int _iosm_debug;
20 /*@=exportlocal@*/
21
25 typedef enum iosmFileAction_e {
26 FA_UNKNOWN = 0,
27 FA_CREATE,
28 FA_COPYIN,
29 FA_COPYOUT,
30 FA_BACKUP,
31 FA_SAVE,
32 FA_SKIP,
33 FA_ALTNAME,
34 FA_ERASE,
35 FA_SKIPNSTATE,
36 FA_SKIPNETSHARED,
37 FA_SKIPCOLOR
38 } iosmFileAction;
39
42 typedef enum iosmMapFlags_e {
43 IOSM_MAP_PATH = (1 << 0),
44 IOSM_MAP_MODE = (1 << 1),
45 IOSM_MAP_UID = (1 << 2),
46 IOSM_MAP_GID = (1 << 3),
47 IOSM_FOLLOW_SYMLINKS= (1 << 4),
48 IOSM_MAP_ABSOLUTE = (1 << 5),
49 IOSM_MAP_ADDDOT = (1 << 6),
50 IOSM_ALL_HARDLINKS = (1 << 7),
51 IOSM_MAP_TYPE = (1 << 8),
52 IOSM_SBIT_CHECK = (1 << 9),
53 IOSM_PAYLOAD_LIST = (1 << 10),
54 IOSM_PAYLOAD_EXTRACT= (1 << 11),
55 IOSM_PAYLOAD_CREATE = (1 << 12)
56 } iosmMapFlags;
57
58 #if defined(_IOSM_INTERNAL)
59
62 #define IOSMERR_CHECK_ERRNO 0x00008000
63
66 enum iosmErrorReturns_e {
67 IOSMERR_BAD_MAGIC = (2 ),
68 IOSMERR_BAD_HEADER = (3 ),
69 IOSMERR_OPEN_FAILED = (4 | IOSMERR_CHECK_ERRNO),
70 IOSMERR_CHMOD_FAILED = (5 | IOSMERR_CHECK_ERRNO),
71 IOSMERR_CHOWN_FAILED = (6 | IOSMERR_CHECK_ERRNO),
72 IOSMERR_WRITE_FAILED = (7 | IOSMERR_CHECK_ERRNO),
73 IOSMERR_UTIME_FAILED = (8 | IOSMERR_CHECK_ERRNO),
74 IOSMERR_UNLINK_FAILED = (9 | IOSMERR_CHECK_ERRNO),
75
76 IOSMERR_RENAME_FAILED = (10 | IOSMERR_CHECK_ERRNO),
77 IOSMERR_SYMLINK_FAILED = (11 | IOSMERR_CHECK_ERRNO),
78 IOSMERR_STAT_FAILED = (12 | IOSMERR_CHECK_ERRNO),
79 IOSMERR_LSTAT_FAILED = (13 | IOSMERR_CHECK_ERRNO),
80 IOSMERR_MKDIR_FAILED = (14 | IOSMERR_CHECK_ERRNO),
81 IOSMERR_RMDIR_FAILED = (15 | IOSMERR_CHECK_ERRNO),
82 IOSMERR_MKNOD_FAILED = (16 | IOSMERR_CHECK_ERRNO),
83 IOSMERR_MKFIFO_FAILED = (17 | IOSMERR_CHECK_ERRNO),
84 IOSMERR_LINK_FAILED = (18 | IOSMERR_CHECK_ERRNO),
85 IOSMERR_READLINK_FAILED = (19 | IOSMERR_CHECK_ERRNO),
86 IOSMERR_READ_FAILED = (20 | IOSMERR_CHECK_ERRNO),
87 IOSMERR_COPY_FAILED = (21 | IOSMERR_CHECK_ERRNO),
88 IOSMERR_LSETFCON_FAILED = (22 | IOSMERR_CHECK_ERRNO),
89 IOSMERR_HDR_SIZE = (23 ),
90 IOSMERR_HDR_TRAILER = (24 ),
91 IOSMERR_UNKNOWN_FILETYPE= (25 ),
92 IOSMERR_MISSING_HARDLINK= (26 ),
93 IOSMERR_DIGEST_MISMATCH = (27 ),
94 IOSMERR_INTERNAL = (28 ),
95 IOSMERR_UNMAPPED_FILE = (29 ),
96 IOSMERR_ENOENT = (30 ),
97 IOSMERR_ENOTEMPTY = (31 )
98 };
99 #endif
100
103 #define IOSM_VERBOSE 0x8000
104 #define IOSM_INTERNAL 0x4000
105 #define IOSM_SYSCALL 0x2000
106 #define IOSM_DEAD 0x1000
107
108 #define _fv(_a) ((_a) | IOSM_VERBOSE)
109 #define _fi(_a) ((_a) | IOSM_INTERNAL)
110 #define _fs(_a) ((_a) | (IOSM_INTERNAL | IOSM_SYSCALL))
111 #define _fd(_a) ((_a) | (IOSM_INTERNAL | IOSM_DEAD))
112
113 typedef enum iosmFileStage_e {
114 IOSM_UNKNOWN = 0,
115 IOSM_INIT = _fd(1),
116 IOSM_PRE = _fd(2),
117 IOSM_PROCESS= _fv(3),
118 IOSM_POST = _fd(4),
119 IOSM_UNDO = 5,
120 IOSM_FINI = 6,
121
122 IOSM_PKGINSTALL = _fd(7),
123 IOSM_PKGERASE = _fd(8),
124 IOSM_PKGBUILD = _fd(9),
125 IOSM_PKGCOMMIT = _fd(10),
126 IOSM_PKGUNDO = _fd(11),
127
128 IOSM_CREATE = _fd(17),
129 IOSM_MAP = _fd(18),
130 IOSM_MKDIRS = _fi(19),
131 IOSM_RMDIRS = _fi(20),
132 IOSM_MKLINKS= _fi(21),
133 IOSM_NOTIFY = _fd(22),
134 IOSM_DESTROY= _fd(23),
135 IOSM_VERIFY = _fd(24),
136 IOSM_COMMIT = _fd(25),
137
138 IOSM_UNLINK = _fs(33),
139 IOSM_RENAME = _fs(34),
140 IOSM_MKDIR = _fs(35),
141 IOSM_RMDIR = _fs(36),
142 IOSM_LSETFCON= _fs(39),
143 IOSM_CHOWN = _fs(40),
144 IOSM_LCHOWN = _fs(41),
145 IOSM_CHMOD = _fs(42),
146 IOSM_UTIME = _fs(43),
147 IOSM_SYMLINK= _fs(44),
148 IOSM_LINK = _fs(45),
149 IOSM_MKFIFO = _fs(46),
150 IOSM_MKNOD = _fs(47),
151 IOSM_LSTAT = _fs(48),
152 IOSM_STAT = _fs(49),
153 IOSM_READLINK= _fs(50),
154 IOSM_CHROOT = _fs(51),
155
156 IOSM_NEXT = _fd(65),
157 IOSM_EAT = _fd(66),
158 IOSM_POS = _fd(67),
159 IOSM_PAD = _fd(68),
160 IOSM_TRAILER= _fd(69),
161 IOSM_HREAD = _fd(70),
162 IOSM_HWRITE = _fd(71),
163 IOSM_DREAD = _fs(72),
164 IOSM_DWRITE = _fs(73),
165
166 IOSM_ROPEN = _fs(129),
167 IOSM_READ = _fs(130),
168 IOSM_RCLOSE = _fs(131),
169 IOSM_WOPEN = _fs(132),
170 IOSM_WRITE = _fs(133),
171 IOSM_WCLOSE = _fs(134)
172 } iosmFileStage;
173 #undef _fv
174 #undef _fi
175 #undef _fs
176 #undef _fd
177
178 #if defined(_IOSM_INTERNAL)
179
182 typedef /*@abstract@*/ struct iosmIterator_s * IOSMI_t;
183
187 struct hardLink_s {
188 /*@owned@*/ /*@relnull@*/
189 struct hardLink_s * next;
190 /*@owned@*/
191 const char ** nsuffix;
192 /*@owned@*/
193 int * filex;
194 struct stat sb;
195 int nlink;
196 int linksLeft;
197 int linkIndex;
198 int createdPath;
199 };
200
205 struct iosmIterator_s {
206 void * ts;
207 void * fi;
208 int reverse;
209 int isave;
210 int i;
211 };
212
216 struct iosm_s {
217 /*@owned@*/ /*@relnull@*/
218 const char * path;
219 /*@owned@*/ /*@relnull@*/
220 const char * lpath;
221 /*@owned@*/ /*@relnull@*/
222 const char * opath;
223 /*@relnull@*/
224 FD_t cfd;
225 /*@relnull@*/
226 FD_t rfd;
227 /*@dependent@*/ /*@relnull@*/
228 char * rdbuf;
229 /*@owned@*/ /*@relnull@*/
230 char * rdb;
231 size_t rdsize;
232 size_t rdlen;
233 size_t rdnb;
234 FD_t wfd;
235 /*@dependent@*/ /*@relnull@*/
236 char * wrbuf;
237 /*@owned@*/ /*@relnull@*/
238 char * wrb;
239 size_t wrsize;
240 size_t wrlen;
241 size_t wrnb;
242 /*@only@*/ /*@relnull@*/
243 IOSMI_t iter;
244 int ix;
245 /*@only@*/ /*@relnull@*/
246 struct hardLink_s * links;
247 /*@only@*/ /*@relnull@*/
248 struct hardLink_s * li;
249 /*@kept@*/ /*@null@*/
250 unsigned int * archiveSize;
251 /*@kept@*/ /*@null@*/
252 const char ** failedFile;
253 /*@shared@*/ /*@relnull@*/
254 const char * subdir;
255 /*@unused@*/
256 char subbuf[64]; /* XXX eliminate */
257 /*@observer@*/ /*@relnull@*/
258 const char * osuffix;
259 /*@observer@*/ /*@relnull@*/
260 const char * nsuffix;
261 /*@shared@*/ /*@relnull@*/
262 const char * suffix;
263 char sufbuf[64]; /* XXX eliminate */
264 /*@only@*/ /*@null@*/
265 unsigned short * dnlx;
266 /*@only@*/ /*@null@*/
267 char * ldn;
268 size_t ldnlen;
269 size_t ldnalloc;
270 int postpone;
271 int diskchecked;
272 int exists;
273 int mkdirsdone;
274 size_t astriplen;
275 int rc;
276 int commit;
277 int repackaged;
278 int strict_erasures;
279 int multithreaded;
280 int adding;
281 int debug;
282 int nofdigests;
283 int nofcontexts;
284 iosmMapFlags mapFlags;
285 rpmuint32_t fdigestalgo;
286 rpmuint32_t digestlen;
287 /*@shared@*/ /*@relnull@*/
288 const char * dirName;
289 /*@shared@*/ /*@relnull@*/
290 const char * baseName;
291 /*@shared@*/ /*@relnull@*/
292 const char * fdigest;
293 /*@shared@*/ /*@relnull@*/
294 const unsigned char * digest;
295 /*@dependent@*/ /*@observer@*/ /*@null@*/
296 const char * fcontext;
298 rpmuint32_t fflags;
299 iosmFileAction action;
300 iosmFileStage goal;
301 iosmFileStage stage;
302 iosmFileStage nstage;
303 struct stat sb;
304 struct stat osb;
306 unsigned blksize;
307 int (*headerRead) (void * _iosm, struct stat *st)
308 /*@modifies _iosm, st @*/;
309 int (*headerWrite) (void * _iosm, struct stat *st)
310 /*@modifies _iosm, st @*/;
311 int (*trailerWrite) (void * _iosm)
312 /*@modifies _iosm @*/;
313
314 /*@null@*/
315 char * lmtab;
316 size_t lmtablen;
317 size_t lmtaboff;
319 struct rpmop_s op_digest;
320 };
321 #endif
322
323 #ifdef __cplusplus
324 extern "C" {
325 #endif
326
327 /*@-exportlocal@*/
333 /*@observer@*/ const char * iosmFileStageString(iosmFileStage a) /*@*/;
334
340 /*@observer@*/ const char * iosmFileActionString(iosmFileAction a) /*@*/;
341 /*@=exportlocal@*/
342
348 /*@only@*/
349 char * iosmStrerror(int rc)
350 /*@*/;
351
352 #if defined(_IOSM_INTERNAL)
353
357 /*@only@*/ IOSM_t newIOSM(void)
358 /*@*/;
359
365 /*@null@*/ IOSM_t freeIOSM(/*@only@*/ /*@null@*/ IOSM_t iosm)
366 /*@modifies iosm @*/;
367 #endif
368
381 int iosmSetup(IOSM_t iosm, iosmFileStage goal, /*@null@*/ const char * afmt,
382 const void * _ts,
383 const void * _fi,
384 FD_t cfd,
385 /*@out@*/ /*@null@*/ unsigned int * archiveSize,
386 /*@out@*/ /*@null@*/ const char ** failedFile)
387 /*@globals h_errno, fileSystem, internalState @*/
388 /*@modifies iosm, _ts, _fi, cfd, *archiveSize, *failedFile,
389 fileSystem, internalState @*/;
390
396 int iosmTeardown(IOSM_t iosm)
397 /*@globals h_errno, fileSystem, internalState @*/
398 /*@modifies iosm, fileSystem, internalState @*/;
399
400 #if defined(_IOSM_INTERNAL)
401 /*@-exportlocal@*/
407 void * iosmGetTs(const IOSM_t iosm)
408 /*@*/;
409
415 void * iosmGetFi(/*@partial@*/ const IOSM_t iosm)
416 /*@*/;
417
422 int iosmMapPath(IOSM_t iosm)
423 /*@modifies iosm @*/;
424
429 int iosmMapAttrs(IOSM_t iosm)
430 /*@modifies iosm @*/;
431 /*@=exportlocal@*/
432
436 extern int (*_iosmNext) (IOSM_t iosm, iosmFileStage nstage)
437 /*@modifies iosm @*/;
438 #endif
439
445 int iosmFileActionSkipped(iosmFileAction action)
446 /*@*/;
447
454 int iosmNext(IOSM_t iosm, iosmFileStage nstage)
455 /*@globals errno, h_errno, fileSystem, internalState @*/
456 /*@modifies iosm, errno, fileSystem, internalState @*/;
457
464 /*@-exportlocal@*/
465 int iosmStage(/*@partial@*/ IOSM_t iosm, iosmFileStage stage)
466 /*@globals errno, h_errno, fileSystem, internalState @*/
467 /*@modifies iosm, errno, fileSystem, internalState @*/;
468 /*@=exportlocal@*/
469
470 #ifdef __cplusplus
471 }
472 #endif
473
474 #endif /* H_IOSM */