00001 #ifndef H_FSM
00002 #define H_FSM
00003
00009 #include <rpmlib.h>
00010 #include "cpio.h"
00011
00014 #define FSM_VERBOSE 0x8000
00015 #define FSM_INTERNAL 0x4000
00016 #define FSM_SYSCALL 0x2000
00017 #define FSM_DEAD 0x1000
00018 #define _fv(_a) ((_a) | FSM_VERBOSE)
00019 #define _fi(_a) ((_a) | FSM_INTERNAL)
00020 #define _fs(_a) ((_a) | (FSM_INTERNAL | FSM_SYSCALL))
00021 #define _fd(_a) ((_a) | (FSM_INTERNAL | FSM_DEAD))
00022 typedef enum fileStage_e {
00023 FSM_UNKNOWN = 0,
00024 FSM_INIT = _fd(1),
00025 FSM_PRE = _fd(2),
00026 FSM_PROCESS = _fv(3),
00027 FSM_POST = _fd(4),
00028 FSM_UNDO = 5,
00029 FSM_FINI = 6,
00030
00031 FSM_PKGINSTALL = _fd(7),
00032 FSM_PKGERASE = _fd(8),
00033 FSM_PKGBUILD = _fd(9),
00034 FSM_PKGCOMMIT = _fd(10),
00035 FSM_PKGUNDO = _fd(11),
00036
00037 FSM_CREATE = _fd(17),
00038 FSM_MAP = _fd(18),
00039 FSM_MKDIRS = _fi(19),
00040 FSM_RMDIRS = _fi(20),
00041 FSM_MKLINKS = _fi(21),
00042 FSM_NOTIFY = _fd(22),
00043 FSM_DESTROY = _fd(23),
00044 FSM_VERIFY = _fd(24),
00045 FSM_COMMIT = _fd(25),
00046
00047 FSM_UNLINK = _fs(33),
00048 FSM_RENAME = _fs(34),
00049 FSM_MKDIR = _fs(35),
00050 FSM_RMDIR = _fs(36),
00051 FSM_CHOWN = _fs(37),
00052 FSM_LCHOWN = _fs(38),
00053 FSM_CHMOD = _fs(39),
00054 FSM_UTIME = _fs(40),
00055 FSM_SYMLINK = _fs(41),
00056 FSM_LINK = _fs(42),
00057 FSM_MKFIFO = _fs(43),
00058 FSM_MKNOD = _fs(44),
00059 FSM_LSTAT = _fs(45),
00060 FSM_STAT = _fs(46),
00061 FSM_READLINK= _fs(47),
00062 FSM_CHROOT = _fs(48),
00063
00064 FSM_NEXT = _fd(65),
00065 FSM_EAT = _fd(66),
00066 FSM_POS = _fd(67),
00067 FSM_PAD = _fd(68),
00068 FSM_TRAILER = _fd(69),
00069 FSM_HREAD = _fd(70),
00070 FSM_HWRITE = _fd(71),
00071 FSM_DREAD = _fs(72),
00072 FSM_DWRITE = _fs(73),
00073
00074 FSM_ROPEN = _fs(129),
00075 FSM_READ = _fs(130),
00076 FSM_RCLOSE = _fs(131),
00077 FSM_WOPEN = _fs(132),
00078 FSM_WRITE = _fs(133),
00079 FSM_WCLOSE = _fs(134),
00080 } fileStage;
00081 #undef _fv
00082 #undef _fi
00083 #undef _fs
00084 #undef _fd
00085
00089 struct hardLink {
00090 struct hardLink * next;
00091 const char ** nsuffix;
00092 int * filex;
00093 struct stat sb;
00094 int nlink;
00095 int linksLeft;
00096 int linkIndex;
00097 int createdPath;
00098 };
00099
00103 struct fsmIterator_s {
00104 rpmTransactionSet ts;
00105 TFI_t fi;
00106 int reverse;
00107 int isave;
00108 int i;
00109 };
00110
00114 struct fsm_s {
00115 const char * path;
00116 const char * opath;
00117 FD_t cfd;
00118 FD_t rfd;
00119 char * rdbuf;
00120 char * rdb;
00121 size_t rdsize;
00122 size_t rdlen;
00123 size_t rdnb;
00124 FD_t wfd;
00125 char * wrbuf;
00126 char * wrb;
00127 size_t wrsize;
00128 size_t wrlen;
00129 size_t wrnb;
00130 FSMI_t iter;
00131 int ix;
00132 struct hardLink * links;
00133 struct hardLink * li;
00134 unsigned int * archiveSize;
00135 const char ** failedFile;
00136 const char * subdir;
00137 char subbuf[64];
00138 const char * osuffix;
00139 const char * nsuffix;
00140 const char * suffix;
00141 char sufbuf[64];
00142 short * dnlx;
00143 char * ldn;
00144 int ldnlen;
00145 int ldnalloc;
00146 int postpone;
00147 int diskchecked;
00148 int exists;
00149 int mkdirsdone;
00150 int astriplen;
00151 int rc;
00152 int commit;
00153 cpioMapFlags mapFlags;
00154 const char * dirName;
00155 const char * baseName;
00156 const char * fmd5sum;
00157 unsigned fflags;
00158 fileAction action;
00159 fileStage goal;
00160 fileStage stage;
00161 struct stat sb;
00162 struct stat osb;
00163 };
00164
00165 #ifdef __cplusplus
00166 extern "C" {
00167 #endif
00168
00169
00175 const char *const fileStageString(fileStage a) ;
00176
00182 const char *const fileActionString(fileAction a) ;
00183
00184
00189 FSM_t newFSM(void)
00190 ;
00191
00197 FSM_t freeFSM( FSM_t fsm)
00198 ;
00199
00210 int fsmSetup(FSM_t fsm, fileStage goal,
00211 const rpmTransactionSet ts,
00212 const TFI_t fi,
00213 FD_t cfd,
00214 unsigned int * archiveSize,
00215 const char ** failedFile)
00216 ;
00217
00223 int fsmTeardown(FSM_t fsm)
00224 ;
00225
00226
00232 rpmTransactionSet fsmGetTs(const FSM_t fsm)
00233 ;
00234
00240 TFI_t fsmGetFi(const FSM_t fsm)
00241 ;
00242
00247 int fsmMapPath(FSM_t fsm)
00248 ;
00249
00254 int fsmMapAttrs(FSM_t fsm)
00255 ;
00256
00257
00264 int fsmStage( FSM_t fsm, fileStage stage)
00265 ;
00266
00267 #ifdef __cplusplus
00268 }
00269 #endif
00270
00271 #endif