00001 #ifndef H_FSM
00002 #define H_FSM
00003
00009 #include "cpio.h"
00010 #include "rpmfi.h"
00011
00012
00013
00014 extern int _fsm_debug;
00015
00016
00019 #define FSM_VERBOSE 0x8000
00020 #define FSM_INTERNAL 0x4000
00021 #define FSM_SYSCALL 0x2000
00022 #define FSM_DEAD 0x1000
00023
00024 #define _fv(_a) ((_a) | FSM_VERBOSE)
00025 #define _fi(_a) ((_a) | FSM_INTERNAL)
00026 #define _fs(_a) ((_a) | (FSM_INTERNAL | FSM_SYSCALL))
00027 #define _fd(_a) ((_a) | (FSM_INTERNAL | FSM_DEAD))
00028
00029 typedef enum fileStage_e {
00030 FSM_UNKNOWN = 0,
00031 FSM_INIT = _fd(1),
00032 FSM_PRE = _fd(2),
00033 FSM_PROCESS = _fv(3),
00034 FSM_POST = _fd(4),
00035 FSM_UNDO = 5,
00036 FSM_FINI = 6,
00037
00038 FSM_PKGINSTALL = _fd(7),
00039 FSM_PKGERASE = _fd(8),
00040 FSM_PKGBUILD = _fd(9),
00041 FSM_PKGCOMMIT = _fd(10),
00042 FSM_PKGUNDO = _fd(11),
00043
00044 FSM_CREATE = _fd(17),
00045 FSM_MAP = _fd(18),
00046 FSM_MKDIRS = _fi(19),
00047 FSM_RMDIRS = _fi(20),
00048 FSM_MKLINKS = _fi(21),
00049 FSM_NOTIFY = _fd(22),
00050 FSM_DESTROY = _fd(23),
00051 FSM_VERIFY = _fd(24),
00052 FSM_COMMIT = _fd(25),
00053
00054 FSM_UNLINK = _fs(33),
00055 FSM_RENAME = _fs(34),
00056 FSM_MKDIR = _fs(35),
00057 FSM_RMDIR = _fs(36),
00058 FSM_LSETFCON= _fs(39),
00059 FSM_CHOWN = _fs(40),
00060 FSM_LCHOWN = _fs(41),
00061 FSM_CHMOD = _fs(42),
00062 FSM_UTIME = _fs(43),
00063 FSM_SYMLINK = _fs(44),
00064 FSM_LINK = _fs(45),
00065 FSM_MKFIFO = _fs(46),
00066 FSM_MKNOD = _fs(47),
00067 FSM_LSTAT = _fs(48),
00068 FSM_STAT = _fs(49),
00069 FSM_READLINK= _fs(50),
00070 FSM_CHROOT = _fs(51),
00071
00072 FSM_NEXT = _fd(65),
00073 FSM_EAT = _fd(66),
00074 FSM_POS = _fd(67),
00075 FSM_PAD = _fd(68),
00076 FSM_TRAILER = _fd(69),
00077 FSM_HREAD = _fd(70),
00078 FSM_HWRITE = _fd(71),
00079 FSM_DREAD = _fs(72),
00080 FSM_DWRITE = _fs(73),
00081
00082 FSM_ROPEN = _fs(129),
00083 FSM_READ = _fs(130),
00084 FSM_RCLOSE = _fs(131),
00085 FSM_WOPEN = _fs(132),
00086 FSM_WRITE = _fs(133),
00087 FSM_WCLOSE = _fs(134)
00088 } fileStage;
00089 #undef _fv
00090 #undef _fi
00091 #undef _fs
00092 #undef _fd
00093
00097 struct hardLink_s {
00098
00099 struct hardLink_s * next;
00100
00101 const char ** nsuffix;
00102
00103 int * filex;
00104 struct stat sb;
00105 int nlink;
00106 int linksLeft;
00107 int linkIndex;
00108 int createdPath;
00109 };
00110
00114 struct fsmIterator_s {
00115 rpmts ts;
00116 rpmfi fi;
00117 int reverse;
00118 int isave;
00119 int i;
00120 };
00121
00125 struct fsm_s {
00126
00127 const char * path;
00128
00129 const char * lpath;
00130
00131 const char * opath;
00132
00133 FD_t cfd;
00134
00135 FD_t rfd;
00136
00137 char * rdbuf;
00138
00139 char * rdb;
00140 size_t rdsize;
00141 size_t rdlen;
00142 size_t rdnb;
00143 FD_t wfd;
00144
00145 char * wrbuf;
00146
00147 char * wrb;
00148 size_t wrsize;
00149 size_t wrlen;
00150 size_t wrnb;
00151
00152 FSMI_t iter;
00153 int ix;
00154
00155 struct hardLink_s * links;
00156
00157 struct hardLink_s * li;
00158
00159 unsigned int * archiveSize;
00160
00161 const char ** failedFile;
00162
00163 const char * subdir;
00164
00165 char subbuf[64];
00166
00167 const char * osuffix;
00168
00169 const char * nsuffix;
00170
00171 const char * suffix;
00172 char sufbuf[64];
00173
00174 short * dnlx;
00175
00176 char * ldn;
00177 int ldnlen;
00178 int ldnalloc;
00179 int postpone;
00180 int diskchecked;
00181 int exists;
00182 int mkdirsdone;
00183 int astriplen;
00184 int rc;
00185 int commit;
00186 int repackaged;
00187 cpioMapFlags mapFlags;
00188 int fdigestalgo;
00189 int digestlen;
00190
00191 const char * dirName;
00192
00193 const char * baseName;
00194
00195 const char * fdigest;
00196
00197 const unsigned char * digest;
00198
00199 const char * fcontext;
00201 unsigned fflags;
00202 fileAction action;
00203 fileStage goal;
00204 fileStage stage;
00205 fileStage nstage;
00206 struct stat sb;
00207 struct stat osb;
00209 unsigned blksize;
00210 int (*headerRead) (FSM_t fsm, struct stat *st);
00211 int (*headerWrite) (FSM_t fsm, struct stat *st);
00212 int (*trailerWrite) (FSM_t fsm);
00213 };
00214
00215 #ifdef __cplusplus
00216 extern "C" {
00217 #endif
00218
00219
00225 const char * fileStageString(fileStage a) ;
00226
00232 const char * fileActionString(fileAction a) ;
00233
00234
00239 FSM_t newFSM(void)
00240 ;
00241
00247 FSM_t freeFSM( FSM_t fsm)
00248
00249 ;
00250
00263 int fsmSetup(FSM_t fsm, fileStage goal, const char * afmt,
00264 const rpmts ts,
00265 const rpmfi fi,
00266 FD_t cfd,
00267 unsigned int * archiveSize,
00268 const char ** failedFile)
00269
00270
00271 ;
00272
00278 int fsmTeardown(FSM_t fsm)
00279
00280 ;
00281
00282
00288 rpmts fsmGetTs(const FSM_t fsm)
00289 ;
00290
00296 rpmfi fsmGetFi( const FSM_t fsm)
00297 ;
00298
00303 int fsmMapPath(FSM_t fsm)
00304 ;
00305
00310 int fsmMapAttrs(FSM_t fsm)
00311 ;
00312
00313
00320 int fsmNext(FSM_t fsm, fileStage nstage)
00321
00322 ;
00323
00330
00331 int fsmStage( FSM_t fsm, fileStage stage)
00332
00333 ;
00334
00335
00336 #ifdef __cplusplus
00337 }
00338 #endif
00339
00340 #endif