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 * opath;
00129
00130 FD_t cfd;
00131
00132 FD_t rfd;
00133
00134 char * rdbuf;
00135
00136 char * rdb;
00137 size_t rdsize;
00138 size_t rdlen;
00139 size_t rdnb;
00140 FD_t wfd;
00141
00142 char * wrbuf;
00143
00144 char * wrb;
00145 size_t wrsize;
00146 size_t wrlen;
00147 size_t wrnb;
00148
00149 FSMI_t iter;
00150 int ix;
00151
00152 struct hardLink_s * links;
00153
00154 struct hardLink_s * li;
00155
00156 unsigned int * archiveSize;
00157
00158 const char ** failedFile;
00159
00160 const char * subdir;
00161
00162 char subbuf[64];
00163
00164 const char * osuffix;
00165
00166 const char * nsuffix;
00167
00168 const char * suffix;
00169 char sufbuf[64];
00170
00171 short * dnlx;
00172
00173 char * ldn;
00174 int ldnlen;
00175 int ldnalloc;
00176 int postpone;
00177 int diskchecked;
00178 int exists;
00179 int mkdirsdone;
00180 int astriplen;
00181 int rc;
00182 int commit;
00183 cpioMapFlags mapFlags;
00184
00185 const char * dirName;
00186
00187 const char * baseName;
00188
00189 const char * fmd5sum;
00190
00191 const char * md5sum;
00192
00193 const char * fcontext;
00195 unsigned fflags;
00196 fileAction action;
00197 fileStage goal;
00198 fileStage stage;
00199 fileStage nstage;
00200 struct stat sb;
00201 struct stat osb;
00202 };
00203
00204 #ifdef __cplusplus
00205 extern "C" {
00206 #endif
00207
00208
00214 const char *const fileStageString(fileStage a) ;
00215
00221 const char *const fileActionString(fileAction a) ;
00222
00223
00228 FSM_t newFSM(void)
00229 ;
00230
00236 FSM_t freeFSM( FSM_t fsm)
00237
00238 ;
00239
00251 int fsmSetup(FSM_t fsm, fileStage goal,
00252 const rpmts ts,
00253 const rpmfi fi,
00254 FD_t cfd,
00255 unsigned int * archiveSize,
00256 const char ** failedFile)
00257
00258
00259 ;
00260
00266 int fsmTeardown(FSM_t fsm)
00267
00268 ;
00269
00270
00276 rpmts fsmGetTs(const FSM_t fsm)
00277 ;
00278
00284 rpmfi fsmGetFi( const FSM_t fsm)
00285 ;
00286
00291 int fsmMapPath(FSM_t fsm)
00292 ;
00293
00298 int fsmMapAttrs(FSM_t fsm)
00299 ;
00300
00301
00308 int fsmNext(FSM_t fsm, fileStage nstage)
00309
00310 ;
00311
00318
00319 int fsmStage( FSM_t fsm, fileStage stage)
00320
00321 ;
00322
00323
00324 #ifdef __cplusplus
00325 }
00326 #endif
00327
00328 #endif