rpm  5.4.10
iosm.h
Go to the documentation of this file.
1 #ifndef H_IOSM
2 #define H_IOSM
3 
9 #define _IOSM_INTERNAL /* XXX expose internals for unit tests. */
10 #include <rpmiotypes.h>
11 #include <rpmio.h> /* XXX FD_t */
12 #include <rpmsw.h>
13 
17 typedef /*@abstract@*/ struct iosm_s * IOSM_t;
18 
19 /*@-exportlocal@*/
20 /*@unchecked@*/
21 extern int _iosm_debug;
22 /*@=exportlocal@*/
23 
27 typedef enum iosmFileAction_e {
28  FA_UNKNOWN = 0,
41 
44 typedef enum iosmMapFlags_e {
45  IOSM_MAP_PATH = (1 << 0),
46  IOSM_MAP_MODE = (1 << 1),
47  IOSM_MAP_UID = (1 << 2),
48  IOSM_MAP_GID = (1 << 3),
50  IOSM_MAP_ABSOLUTE = (1 << 5),
51  IOSM_MAP_ADDDOT = (1 << 6),
52  IOSM_ALL_HARDLINKS = (1 << 7),
53  IOSM_MAP_TYPE = (1 << 8),
54  IOSM_SBIT_CHECK = (1 << 9),
55  IOSM_PAYLOAD_LIST = (1 << 10),
57  IOSM_PAYLOAD_CREATE = (1 << 12)
58 } iosmMapFlags;
59 
60 #if defined(_IOSM_INTERNAL)
61 
64 #define IOSMERR_CHECK_ERRNO 0x00008000
65 
77 
98  IOSMERR_ENOENT = (30 ),
100 };
101 #endif
102 
105 #define IOSM_VERBOSE 0x8000
106 #define IOSM_INTERNAL 0x4000
107 #define IOSM_SYSCALL 0x2000
108 #define IOSM_DEAD 0x1000
109 
110 #define _fv(_a) ((_a) | IOSM_VERBOSE)
111 #define _fi(_a) ((_a) | IOSM_INTERNAL)
112 #define _fs(_a) ((_a) | (IOSM_INTERNAL | IOSM_SYSCALL))
113 #define _fd(_a) ((_a) | (IOSM_INTERNAL | IOSM_DEAD))
114 
115 typedef enum iosmFileStage_e {
118  IOSM_PRE = _fd(2),
123 
129 
131  IOSM_MAP = _fd(18),
139 
150  IOSM_LINK = _fs(45),
154  IOSM_STAT = _fs(49),
157 
158  IOSM_NEXT = _fd(65),
159  IOSM_EAT = _fd(66),
160  IOSM_POS = _fd(67),
161  IOSM_PAD = _fd(68),
167 
168  IOSM_ROPEN = _fs(129),
169  IOSM_READ = _fs(130),
170  IOSM_RCLOSE = _fs(131),
171  IOSM_WOPEN = _fs(132),
172  IOSM_WRITE = _fs(133),
174 } iosmFileStage;
175 #undef _fv
176 #undef _fi
177 #undef _fs
178 #undef _fd
179 
180 #if defined(_IOSM_INTERNAL)
181 
184 typedef /*@abstract@*/ struct iosmIterator_s * IOSMI_t;
185 
189 struct hardLink_s {
190 /*@owned@*/ /*@relnull@*/
191  struct hardLink_s * next;
192 /*@owned@*/
193  const char ** nsuffix;
194 /*@owned@*/
195  int * filex;
196  struct stat sb;
197  int nlink;
201 };
202 
208  void * ts;
209  void * fi;
210  int reverse;
211  int isave;
212  int i;
213 };
214 
218 struct iosm_s {
219 /*@owned@*/ /*@relnull@*/
220  const char * path;
221 /*@owned@*/ /*@relnull@*/
222  const char * lpath;
223 /*@owned@*/ /*@relnull@*/
224  const char * opath;
225 /*@relnull@*/
227 /*@relnull@*/
229 /*@dependent@*/ /*@relnull@*/
230  char * rdbuf;
231 /*@owned@*/ /*@relnull@*/
232  char * rdb;
233  size_t rdsize;
234  size_t rdlen;
235  size_t rdnb;
237 /*@dependent@*/ /*@relnull@*/
238  char * wrbuf;
239 /*@owned@*/ /*@relnull@*/
240  char * wrb;
241  size_t wrsize;
242  size_t wrlen;
243  size_t wrnb;
244 /*@only@*/ /*@relnull@*/
245  IOSMI_t iter;
246  int ix;
247 /*@only@*/ /*@relnull@*/
248  struct hardLink_s * links;
249 /*@only@*/ /*@relnull@*/
250  struct hardLink_s * li;
251 /*@kept@*/ /*@null@*/
252  unsigned int * archiveSize;
253 /*@kept@*/ /*@null@*/
254  const char ** failedFile;
255 /*@shared@*/ /*@relnull@*/
256  const char * subdir;
257 /*@unused@*/
258  char subbuf[64]; /* XXX eliminate */
259 /*@observer@*/ /*@relnull@*/
260  const char * osuffix;
261 /*@observer@*/ /*@relnull@*/
262  const char * nsuffix;
263 /*@shared@*/ /*@relnull@*/
264  const char * suffix;
265  char sufbuf[64]; /* XXX eliminate */
266 /*@only@*/ /*@null@*/
267  unsigned short * dnlx;
268 /*@only@*/ /*@null@*/
269  char * ldn;
270  size_t ldnlen;
271  size_t ldnalloc;
272  int postpone;
274  int exists;
276  size_t astriplen;
277  int rc;
278  int commit;
282  int adding;
283  int debug;
289 /*@shared@*/ /*@relnull@*/
290  const char * dirName;
291 /*@shared@*/ /*@relnull@*/
292  const char * baseName;
293 /*@shared@*/ /*@relnull@*/
294  const char * fdigest;
295 /*@shared@*/ /*@relnull@*/
296  const unsigned char * digest;
297 /*@dependent@*/ /*@observer@*/ /*@null@*/
298  const char * fcontext;
305  struct stat sb;
306  struct stat osb;
308  unsigned blksize;
309  int (*headerRead) (void * _iosm, struct stat *st)
310  /*@modifies _iosm, st @*/;
311  int (*headerWrite) (void * _iosm, struct stat *st)
312  /*@modifies _iosm, st @*/;
313  int (*trailerWrite) (void * _iosm)
314  /*@modifies _iosm @*/;
315 
316 /*@null@*/
317  char * lmtab;
318  size_t lmtablen;
319  size_t lmtaboff;
322 };
323 #endif
324 
325 #ifdef __cplusplus
326 extern "C" {
327 #endif
328 
329 /*@-exportlocal@*/
335 /*@observer@*/ const char * iosmFileStageString(iosmFileStage a) /*@*/;
336 
342 /*@observer@*/ const char * iosmFileActionString(iosmFileAction a) /*@*/;
343 /*@=exportlocal@*/
344 
350 /*@only@*/
351 char * iosmStrerror(int rc)
352  /*@*/;
353 
354 #if defined(_IOSM_INTERNAL)
355 
359 /*@only@*/ IOSM_t newIOSM(void)
360  /*@*/;
361 
367 /*@null@*/ IOSM_t freeIOSM(/*@only@*/ /*@null@*/ IOSM_t iosm)
368  /*@modifies iosm @*/;
369 #endif
370 
383 int iosmSetup(IOSM_t iosm, iosmFileStage goal, /*@null@*/ const char * afmt,
384  const void * _ts,
385  const void * _fi,
386  FD_t cfd,
387  /*@out@*/ /*@null@*/ unsigned int * archiveSize,
388  /*@out@*/ /*@null@*/ const char ** failedFile)
389  /*@globals h_errno, fileSystem, internalState @*/
390  /*@modifies iosm, _ts, _fi, cfd, *archiveSize, *failedFile,
391  fileSystem, internalState @*/;
392 
398 int iosmTeardown(IOSM_t iosm)
399  /*@globals h_errno, fileSystem, internalState @*/
400  /*@modifies iosm, fileSystem, internalState @*/;
401 
402 #if defined(_IOSM_INTERNAL)
403 /*@-exportlocal@*/
409 void * iosmGetTs(const IOSM_t iosm)
410  /*@*/;
411 
417 void * iosmGetFi(/*@partial@*/ const IOSM_t iosm)
418  /*@*/;
419 
424 int iosmMapPath(IOSM_t iosm)
425  /*@modifies iosm @*/;
426 
431 int iosmMapAttrs(IOSM_t iosm)
432  /*@modifies iosm @*/;
433 /*@=exportlocal@*/
434 
438 extern int (*_iosmNext) (IOSM_t iosm, iosmFileStage nstage)
439  /*@modifies iosm @*/;
440 #endif
441 
448  /*@*/;
449 
456 int iosmNext(IOSM_t iosm, iosmFileStage nstage)
457  /*@globals errno, h_errno, fileSystem, internalState @*/
458  /*@modifies iosm, errno, fileSystem, internalState @*/;
459 
466 /*@-exportlocal@*/
467 int iosmStage(/*@partial@*/ IOSM_t iosm, iosmFileStage stage)
468  /*@globals errno, h_errno, fileSystem, internalState @*/
469  /*@modifies iosm, errno, fileSystem, internalState @*/;
470 /*@=exportlocal@*/
471 
472 #ifdef __cplusplus
473 }
474 #endif
475 
476 #endif /* H_IOSM */