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