rpm
5.2.1
|
00001 #ifndef H_IOSM 00002 #define H_IOSM 00003 00009 #include <rpmiotypes.h> 00010 #include <rpmsw.h> 00011 00015 typedef /*@abstract@*/ struct iosm_s * IOSM_t; 00016 00017 /*@-exportlocal@*/ 00018 /*@unchecked@*/ 00019 extern int _iosm_debug; 00020 /*@=exportlocal@*/ 00021 00025 typedef enum iosmFileAction_e { 00026 FA_UNKNOWN = 0, 00027 FA_CREATE, 00028 FA_COPYIN, 00029 FA_COPYOUT, 00030 FA_BACKUP, 00031 FA_SAVE, 00032 FA_SKIP, 00033 FA_ALTNAME, 00034 FA_ERASE, 00035 FA_SKIPNSTATE, 00036 FA_SKIPNETSHARED, 00037 FA_SKIPCOLOR 00038 } iosmFileAction; 00039 00042 typedef enum iosmMapFlags_e { 00043 IOSM_MAP_PATH = (1 << 0), 00044 IOSM_MAP_MODE = (1 << 1), 00045 IOSM_MAP_UID = (1 << 2), 00046 IOSM_MAP_GID = (1 << 3), 00047 IOSM_FOLLOW_SYMLINKS= (1 << 4), 00048 IOSM_MAP_ABSOLUTE = (1 << 5), 00049 IOSM_MAP_ADDDOT = (1 << 6), 00050 IOSM_ALL_HARDLINKS = (1 << 7), 00051 IOSM_MAP_TYPE = (1 << 8), 00052 IOSM_SBIT_CHECK = (1 << 9), 00053 IOSM_PAYLOAD_LIST = (1 << 10), 00054 IOSM_PAYLOAD_EXTRACT= (1 << 11), 00055 IOSM_PAYLOAD_CREATE = (1 << 12) 00056 } iosmMapFlags; 00057 00058 #if defined(_IOSM_INTERNAL) 00059 00062 #define IOSMERR_CHECK_ERRNO 0x00008000 00063 00066 enum iosmErrorReturns_e { 00067 IOSMERR_BAD_MAGIC = (2 ), 00068 IOSMERR_BAD_HEADER = (3 ), 00069 IOSMERR_OPEN_FAILED = (4 | IOSMERR_CHECK_ERRNO), 00070 IOSMERR_CHMOD_FAILED = (5 | IOSMERR_CHECK_ERRNO), 00071 IOSMERR_CHOWN_FAILED = (6 | IOSMERR_CHECK_ERRNO), 00072 IOSMERR_WRITE_FAILED = (7 | IOSMERR_CHECK_ERRNO), 00073 IOSMERR_UTIME_FAILED = (8 | IOSMERR_CHECK_ERRNO), 00074 IOSMERR_UNLINK_FAILED = (9 | IOSMERR_CHECK_ERRNO), 00075 00076 IOSMERR_RENAME_FAILED = (10 | IOSMERR_CHECK_ERRNO), 00077 IOSMERR_SYMLINK_FAILED = (11 | IOSMERR_CHECK_ERRNO), 00078 IOSMERR_STAT_FAILED = (12 | IOSMERR_CHECK_ERRNO), 00079 IOSMERR_LSTAT_FAILED = (13 | IOSMERR_CHECK_ERRNO), 00080 IOSMERR_MKDIR_FAILED = (14 | IOSMERR_CHECK_ERRNO), 00081 IOSMERR_RMDIR_FAILED = (15 | IOSMERR_CHECK_ERRNO), 00082 IOSMERR_MKNOD_FAILED = (16 | IOSMERR_CHECK_ERRNO), 00083 IOSMERR_MKFIFO_FAILED = (17 | IOSMERR_CHECK_ERRNO), 00084 IOSMERR_LINK_FAILED = (18 | IOSMERR_CHECK_ERRNO), 00085 IOSMERR_READLINK_FAILED = (19 | IOSMERR_CHECK_ERRNO), 00086 IOSMERR_READ_FAILED = (20 | IOSMERR_CHECK_ERRNO), 00087 IOSMERR_COPY_FAILED = (21 | IOSMERR_CHECK_ERRNO), 00088 IOSMERR_LSETFCON_FAILED = (22 | IOSMERR_CHECK_ERRNO), 00089 IOSMERR_HDR_SIZE = (23 ), 00090 IOSMERR_HDR_TRAILER = (24 ), 00091 IOSMERR_UNKNOWN_FILETYPE= (25 ), 00092 IOSMERR_MISSING_HARDLINK= (26 ), 00093 IOSMERR_DIGEST_MISMATCH = (27 ), 00094 IOSMERR_INTERNAL = (28 ), 00095 IOSMERR_UNMAPPED_FILE = (29 ), 00096 IOSMERR_ENOENT = (30 ), 00097 IOSMERR_ENOTEMPTY = (31 ) 00098 }; 00099 #endif 00100 00103 #define IOSM_VERBOSE 0x8000 00104 #define IOSM_INTERNAL 0x4000 00105 #define IOSM_SYSCALL 0x2000 00106 #define IOSM_DEAD 0x1000 00107 00108 #define _fv(_a) ((_a) | IOSM_VERBOSE) 00109 #define _fi(_a) ((_a) | IOSM_INTERNAL) 00110 #define _fs(_a) ((_a) | (IOSM_INTERNAL | IOSM_SYSCALL)) 00111 #define _fd(_a) ((_a) | (IOSM_INTERNAL | IOSM_DEAD)) 00112 00113 typedef enum iosmFileStage_e { 00114 IOSM_UNKNOWN = 0, 00115 IOSM_INIT = _fd(1), 00116 IOSM_PRE = _fd(2), 00117 IOSM_PROCESS= _fv(3), 00118 IOSM_POST = _fd(4), 00119 IOSM_UNDO = 5, 00120 IOSM_FINI = 6, 00121 00122 IOSM_PKGINSTALL = _fd(7), 00123 IOSM_PKGERASE = _fd(8), 00124 IOSM_PKGBUILD = _fd(9), 00125 IOSM_PKGCOMMIT = _fd(10), 00126 IOSM_PKGUNDO = _fd(11), 00127 00128 IOSM_CREATE = _fd(17), 00129 IOSM_MAP = _fd(18), 00130 IOSM_MKDIRS = _fi(19), 00131 IOSM_RMDIRS = _fi(20), 00132 IOSM_MKLINKS= _fi(21), 00133 IOSM_NOTIFY = _fd(22), 00134 IOSM_DESTROY= _fd(23), 00135 IOSM_VERIFY = _fd(24), 00136 IOSM_COMMIT = _fd(25), 00137 00138 IOSM_UNLINK = _fs(33), 00139 IOSM_RENAME = _fs(34), 00140 IOSM_MKDIR = _fs(35), 00141 IOSM_RMDIR = _fs(36), 00142 IOSM_LSETFCON= _fs(39), 00143 IOSM_CHOWN = _fs(40), 00144 IOSM_LCHOWN = _fs(41), 00145 IOSM_CHMOD = _fs(42), 00146 IOSM_UTIME = _fs(43), 00147 IOSM_SYMLINK= _fs(44), 00148 IOSM_LINK = _fs(45), 00149 IOSM_MKFIFO = _fs(46), 00150 IOSM_MKNOD = _fs(47), 00151 IOSM_LSTAT = _fs(48), 00152 IOSM_STAT = _fs(49), 00153 IOSM_READLINK= _fs(50), 00154 IOSM_CHROOT = _fs(51), 00155 00156 IOSM_NEXT = _fd(65), 00157 IOSM_EAT = _fd(66), 00158 IOSM_POS = _fd(67), 00159 IOSM_PAD = _fd(68), 00160 IOSM_TRAILER= _fd(69), 00161 IOSM_HREAD = _fd(70), 00162 IOSM_HWRITE = _fd(71), 00163 IOSM_DREAD = _fs(72), 00164 IOSM_DWRITE = _fs(73), 00165 00166 IOSM_ROPEN = _fs(129), 00167 IOSM_READ = _fs(130), 00168 IOSM_RCLOSE = _fs(131), 00169 IOSM_WOPEN = _fs(132), 00170 IOSM_WRITE = _fs(133), 00171 IOSM_WCLOSE = _fs(134) 00172 } iosmFileStage; 00173 #undef _fv 00174 #undef _fi 00175 #undef _fs 00176 #undef _fd 00177 00178 #if defined(_IOSM_INTERNAL) 00179 00182 typedef /*@abstract@*/ struct iosmIterator_s * IOSMI_t; 00183 00187 struct hardLink_s { 00188 /*@owned@*/ /*@relnull@*/ 00189 struct hardLink_s * next; 00190 /*@owned@*/ 00191 const char ** nsuffix; 00192 /*@owned@*/ 00193 int * filex; 00194 struct stat sb; 00195 int nlink; 00196 int linksLeft; 00197 int linkIndex; 00198 int createdPath; 00199 }; 00200 00205 struct iosmIterator_s { 00206 void * ts; 00207 void * fi; 00208 int reverse; 00209 int isave; 00210 int i; 00211 }; 00212 00216 struct iosm_s { 00217 /*@owned@*/ /*@relnull@*/ 00218 const char * path; 00219 /*@owned@*/ /*@relnull@*/ 00220 const char * lpath; 00221 /*@owned@*/ /*@relnull@*/ 00222 const char * opath; 00223 /*@relnull@*/ 00224 FD_t cfd; 00225 /*@relnull@*/ 00226 FD_t rfd; 00227 /*@dependent@*/ /*@relnull@*/ 00228 char * rdbuf; 00229 /*@owned@*/ /*@relnull@*/ 00230 char * rdb; 00231 size_t rdsize; 00232 size_t rdlen; 00233 size_t rdnb; 00234 FD_t wfd; 00235 /*@dependent@*/ /*@relnull@*/ 00236 char * wrbuf; 00237 /*@owned@*/ /*@relnull@*/ 00238 char * wrb; 00239 size_t wrsize; 00240 size_t wrlen; 00241 size_t wrnb; 00242 /*@only@*/ /*@relnull@*/ 00243 IOSMI_t iter; 00244 int ix; 00245 /*@only@*/ /*@relnull@*/ 00246 struct hardLink_s * links; 00247 /*@only@*/ /*@relnull@*/ 00248 struct hardLink_s * li; 00249 /*@kept@*/ /*@null@*/ 00250 unsigned int * archiveSize; 00251 /*@kept@*/ /*@null@*/ 00252 const char ** failedFile; 00253 /*@shared@*/ /*@relnull@*/ 00254 const char * subdir; 00255 /*@unused@*/ 00256 char subbuf[64]; /* XXX eliminate */ 00257 /*@observer@*/ /*@relnull@*/ 00258 const char * osuffix; 00259 /*@observer@*/ /*@relnull@*/ 00260 const char * nsuffix; 00261 /*@shared@*/ /*@relnull@*/ 00262 const char * suffix; 00263 char sufbuf[64]; /* XXX eliminate */ 00264 /*@only@*/ /*@null@*/ 00265 unsigned short * dnlx; 00266 /*@only@*/ /*@null@*/ 00267 char * ldn; 00268 size_t ldnlen; 00269 size_t ldnalloc; 00270 int postpone; 00271 int diskchecked; 00272 int exists; 00273 int mkdirsdone; 00274 size_t astriplen; 00275 int rc; 00276 int commit; 00277 int repackaged; 00278 int strict_erasures; 00279 int multithreaded; 00280 int adding; 00281 int debug; 00282 int nofdigests; 00283 int nofcontexts; 00284 iosmMapFlags mapFlags; 00285 rpmuint32_t fdigestalgo; 00286 rpmuint32_t digestlen; 00287 /*@shared@*/ /*@relnull@*/ 00288 const char * dirName; 00289 /*@shared@*/ /*@relnull@*/ 00290 const char * baseName; 00291 /*@shared@*/ /*@relnull@*/ 00292 const char * fdigest; 00293 /*@shared@*/ /*@relnull@*/ 00294 const unsigned char * digest; 00295 /*@dependent@*/ /*@observer@*/ /*@null@*/ 00296 const char * fcontext; 00298 rpmuint32_t fflags; 00299 iosmFileAction action; 00300 iosmFileStage goal; 00301 iosmFileStage stage; 00302 iosmFileStage nstage; 00303 struct stat sb; 00304 struct stat osb; 00306 unsigned blksize; 00307 int (*headerRead) (void * _iosm, struct stat *st) 00308 /*@modifies _iosm, st @*/; 00309 int (*headerWrite) (void * _iosm, struct stat *st) 00310 /*@modifies _iosm, st @*/; 00311 int (*trailerWrite) (void * _iosm) 00312 /*@modifies _iosm @*/; 00313 00314 /*@null@*/ 00315 char * lmtab; 00316 size_t lmtablen; 00317 size_t lmtaboff; 00319 struct rpmop_s op_digest; 00320 }; 00321 #endif 00322 00323 #ifdef __cplusplus 00324 extern "C" { 00325 #endif 00326 00327 /*@-exportlocal@*/ 00333 /*@observer@*/ const char * iosmFileStageString(iosmFileStage a) /*@*/; 00334 00340 /*@observer@*/ const char * iosmFileActionString(iosmFileAction a) /*@*/; 00341 /*@=exportlocal@*/ 00342 00348 /*@only@*/ 00349 char * iosmStrerror(int rc) 00350 /*@*/; 00351 00352 #if defined(_IOSM_INTERNAL) 00353 00357 /*@only@*/ IOSM_t newIOSM(void) 00358 /*@*/; 00359 00365 /*@null@*/ IOSM_t freeIOSM(/*@only@*/ /*@null@*/ IOSM_t iosm) 00366 /*@modifies iosm @*/; 00367 #endif 00368 00381 int iosmSetup(IOSM_t iosm, iosmFileStage goal, /*@null@*/ const char * afmt, 00382 const void * _ts, 00383 const void * _fi, 00384 FD_t cfd, 00385 /*@out@*/ /*@null@*/ unsigned int * archiveSize, 00386 /*@out@*/ /*@null@*/ const char ** failedFile) 00387 /*@globals h_errno, fileSystem, internalState @*/ 00388 /*@modifies iosm, _ts, _fi, cfd, *archiveSize, *failedFile, 00389 fileSystem, internalState @*/; 00390 00396 int iosmTeardown(IOSM_t iosm) 00397 /*@globals h_errno, fileSystem, internalState @*/ 00398 /*@modifies iosm, fileSystem, internalState @*/; 00399 00400 #if defined(_IOSM_INTERNAL) 00401 /*@-exportlocal@*/ 00407 void * iosmGetTs(const IOSM_t iosm) 00408 /*@*/; 00409 00415 void * iosmGetFi(/*@partial@*/ const IOSM_t iosm) 00416 /*@*/; 00417 00422 int iosmMapPath(IOSM_t iosm) 00423 /*@modifies iosm @*/; 00424 00429 int iosmMapAttrs(IOSM_t iosm) 00430 /*@modifies iosm @*/; 00431 /*@=exportlocal@*/ 00432 00436 extern int (*_iosmNext) (IOSM_t iosm, iosmFileStage nstage) 00437 /*@modifies iosm @*/; 00438 #endif 00439 00445 int iosmFileActionSkipped(iosmFileAction action) 00446 /*@*/; 00447 00454 int iosmNext(IOSM_t iosm, iosmFileStage nstage) 00455 /*@globals errno, h_errno, fileSystem, internalState @*/ 00456 /*@modifies iosm, errno, fileSystem, internalState @*/; 00457 00464 /*@-exportlocal@*/ 00465 int iosmStage(/*@partial@*/ IOSM_t iosm, iosmFileStage stage) 00466 /*@globals errno, h_errno, fileSystem, internalState @*/ 00467 /*@modifies iosm, errno, fileSystem, internalState @*/; 00468 /*@=exportlocal@*/ 00469 00470 #ifdef __cplusplus 00471 } 00472 #endif 00473 00474 #endif /* H_IOSM */