rpm  5.4.15
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 */
int iosmStage(IOSM_t iosm, iosmFileStage stage)
File state machine driver.
Definition: iosm.c:1638
Definition: iosm.h:34
struct hardLink_s * li
Definition: iosm.h:250
char * ldn
Definition: iosm.h:269
int(* _iosmNext)(IOSM_t iosm, iosmFileStage nstage)
Vector to iosmNext.
Definition: iosm.c:83
struct stat sb
Definition: iosm.h:305
IOSM_t freeIOSM(IOSM_t iosm)
Destroy I/O state machine instance.
Definition: iosm.c:580
const char * nsuffix
Definition: iosm.h:262
const char ** failedFile
Definition: iosm.h:254
int postpone
Definition: iosm.h:272
enum iosmFileAction_e iosmFileAction
File disposition(s) during package install/erase processing.
iosmMapFlags_e
Definition: iosm.h:44
int commit
Definition: iosm.h:278
const char * osuffix
Definition: iosm.h:260
const char * lpath
Definition: iosm.h:222
Definition: iosm.h:159
Definition: iosm.h:131
iosmFileAction action
Definition: iosm.h:301
char * wrb
Definition: iosm.h:240
const char * path
Definition: iosm.h:220
int iosmSetup(IOSM_t iosm, iosmFileStage goal, const char *afmt, const void *_ts, const void *_fi, FD_t cfd, unsigned int *archiveSize, const char **failedFile)
Load external data into I/O state machine.
Definition: iosm.c:669
void * iosmGetFi(const IOSM_t iosm)
Retrieve transaction element file info from I/O state machine iterator.
Definition: iosm.c:97
const char * dirName
Definition: iosm.h:290
rpmuint32_t digestlen
Definition: iosm.h:288
size_t wrsize
Definition: iosm.h:241
int repackaged
Definition: iosm.h:279
size_t lmtaboff
Definition: iosm.h:319
unsigned int * archiveSize
Definition: iosm.h:252
void * ts
Definition: iosm.h:208
int adding
Definition: iosm.h:282
IOSMI_t iter
Definition: iosm.h:245
#define _fi(_a)
Definition: iosm.h:111
int ix
Definition: iosm.h:246
enum iosmFileStage_e iosmFileStage
const unsigned char * digest
Definition: iosm.h:296
struct rpmop_s op_digest
Definition: iosm.h:321
Definition: iosm.h:30
const char * subdir
Definition: iosm.h:256
Definition: iosm.h:118
int(* headerWrite)(void *_iosm, struct stat *st)
Definition: iosm.h:311
size_t wrnb
Definition: iosm.h:243
const char * iosmFileStageString(iosmFileStage a)
Return formatted string representation of file stages.
Definition: iosm.c:2703
FD_t cfd
Definition: iosm.h:226
IOSM_t newIOSM(void)
Create I/O state machine instance.
Definition: iosm.c:574
unsigned int rpmuint32_t
Definition: rpmiotypes.h:28
FD_t wfd
Definition: iosm.h:236
char * lmtab
Definition: iosm.h:317
size_t rdnb
Definition: iosm.h:235
int iosmNext(IOSM_t iosm, iosmFileStage nstage)
File state machine driver.
Definition: iosm.c:461
char * iosmStrerror(int rc)
Return formatted error message on payload handling failure.
Definition: iosm.c:2769
size_t ldnlen
Definition: iosm.h:270
int multithreaded
Definition: iosm.h:281
char sufbuf[64]
Definition: iosm.h:265
const char * fdigest
Definition: iosm.h:294
int iosmFileActionSkipped(iosmFileAction action)
Is the file going to be skipped?
Definition: iosm.c:2678
void * fi
Definition: iosm.h:209
struct iosm_s * IOSM_t
File state machine data.
Definition: iosm.h:17
iosmFileStage stage
Definition: iosm.h:303
iosmMapFlags mapFlags
Definition: iosm.h:286
#define _fv(_a)
Definition: iosm.h:110
int iosmTeardown(IOSM_t iosm)
Clean I/O state machine.
Definition: iosm.c:802
const char * iosmFileActionString(iosmFileAction a)
Return formatted string representation of file disposition.
Definition: iosm.c:2683
Definition: iosm.h:160
const char * fcontext
Definition: iosm.h:298
int(* trailerWrite)(void *_iosm)
Definition: iosm.h:313
iosmFileStage_e
Definition: iosm.h:115
The FD_t File Handle data structure.
int rc
Definition: iosm.h:277
Definition: iosm.h:32
size_t rdlen
Definition: iosm.h:234
char * rdb
Definition: iosm.h:232
int reverse
Definition: iosm.h:210
Iterator across package file info, forward on install, backward on erase.
Definition: iosm.h:207
int iosmMapAttrs(IOSM_t iosm)
Map file stat(2) info.
Definition: iosm.c:949
int nofcontexts
Definition: iosm.h:285
Cumulative statistics for an operation.
Definition: rpmsw.h:39
iosmFileStage nstage
Definition: iosm.h:304
char * wrbuf
Definition: iosm.h:238
size_t wrlen
Definition: iosm.h:242
#define _fd(_a)
Definition: iosm.h:113
rpmuint32_t fdigestalgo
Definition: iosm.h:287
rpmuint32_t fflags
Definition: iosm.h:300
enum iosmMapFlags_e iosmMapFlags
void * iosmGetTs(const IOSM_t iosm)
Retrieve transaction set from I/O state machine iterator.
Definition: iosm.h:29
int isave
Definition: iosm.h:211
Definition: iosm.h:161
size_t lmtablen
Definition: iosm.h:318
FD_t rfd
Definition: iosm.h:228
int nofdigests
Definition: iosm.h:284
struct hardLink_s * links
Definition: iosm.h:248
size_t astriplen
Definition: iosm.h:276
Definition: iosm.h:36
int strict_erasures
Definition: iosm.h:280
iosmFileStage goal
Definition: iosm.h:302
size_t rdsize
Definition: iosm.h:233
char * rdbuf
Definition: iosm.h:230
const char * suffix
Definition: iosm.h:264
struct stat osb
Definition: iosm.h:306
unsigned blksize
Definition: iosm.h:308
int mkdirsdone
Definition: iosm.h:275
int debug
Definition: iosm.h:283
iosmErrorReturns_e
Definition: iosm.h:68
int iosmMapPath(IOSM_t iosm)
Map next file path and action.
Definition: iosm.c:858
iosmFileAction_e
File disposition(s) during package install/erase processing.
Definition: iosm.h:27
int diskchecked
Definition: iosm.h:273
const char * baseName
Definition: iosm.h:292
int exists
Definition: iosm.h:274
int(* headerRead)(void *_iosm, struct stat *st)
Definition: iosm.h:309
unsigned short * dnlx
Definition: iosm.h:267
char subbuf[64]
Definition: iosm.h:258
#define _fs(_a)
Definition: iosm.h:112
File name and stat information.
Definition: iosm.h:218
size_t ldnalloc
Definition: iosm.h:271
#define IOSMERR_CHECK_ERRNO
Definition: iosm.h:64
struct iosmIterator_s * IOSMI_t
Iterator across package file info, forward on install, backward on erase.
Definition: iosm.h:184
int _iosm_debug
Definition: iosm.c:75
Definition: iosm.h:33
const char * opath
Definition: iosm.h:224