Main Page Modules Data Structures File List Data Fields Globals Related Pages

# lib/fsm.h

Go to the documentation of this file.

    00001 #ifndef H_FSM
    00002 #define H_FSM
    00003
    00009 #include "cpio.h"
    00010
    00011 /*@-exportlocal@*/
    00012 /*@unchecked@*/
    00013 extern int _fsm_debug;
    00014 /*@=exportlocal@*/
    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_CHOWN   =  _fs(37),
    00058     FSM_LCHOWN  =  _fs(38),
    00059     FSM_CHMOD   =  _fs(39),
    00060     FSM_UTIME   =  _fs(40),
    00061     FSM_SYMLINK =  _fs(41),
    00062     FSM_LINK    =  _fs(42),
    00063     FSM_MKFIFO  =  _fs(43),
    00064     FSM_MKNOD   =  _fs(44),
    00065     FSM_LSTAT   =  _fs(45),
    00066     FSM_STAT    =  _fs(46),
    00067     FSM_READLINK=  _fs(47),
    00068     FSM_CHROOT  =  _fs(48),
    00069
    00070     FSM_NEXT    =  _fd(65),
    00071     FSM_EAT     =  _fd(66),
    00072     FSM_POS     =  _fd(67),
    00073     FSM_PAD     =  _fd(68),
    00074     FSM_TRAILER =  _fd(69),
    00075     FSM_HREAD   =  _fd(70),
    00076     FSM_HWRITE  =  _fd(71),
    00077     FSM_DREAD   =  _fs(72),
    00078     FSM_DWRITE  =  _fs(73),
    00079
    00080     FSM_ROPEN   =  _fs(129),
    00081     FSM_READ    =  _fs(130),
    00082     FSM_RCLOSE  =  _fs(131),
    00083     FSM_WOPEN   =  _fs(132),
    00084     FSM_WRITE   =  _fs(133),
    00085     FSM_WCLOSE  =  _fs(134)
    00086 } fileStage;
    00087 #undef  _fv
    00088 #undef  _fi
    00089 #undef  _fs
    00090 #undef  _fd
    00091
    00095 struct hardLink_s {
    00096 /*@owned@*/ struct hardLink_s * next;
    00097 /*@owned@*/ const char ** nsuffix;
    00098 /*@owned@*/ int * filex;
    00099     struct stat sb;
    00100     int nlink;
    00101     int linksLeft;
    00102     int linkIndex;
    00103     int createdPath;
    00104 };
    00105
    00109 struct fsmIterator_s {
    00110 /*@kept@*/ rpmTransactionSet ts;
    00111 /*@kept@*/ TFI_t fi;
    00112     int reverse;
    00113     int isave;
    00114     int i;
    00115 };
    00116
    00120 struct fsm_s {
    00121 /*@owned@*/ const char * path;
    00122 /*@owned@*/ const char * opath;
    00123     FD_t cfd;
    00124     FD_t rfd;
    00125 /*@dependent@*/ char * rdbuf;
    00126 /*@owned@*/ char * rdb;
    00127     size_t rdsize;
    00128     size_t rdlen;
    00129     size_t rdnb;
    00130     FD_t wfd;
    00131 /*@dependent@*/ char * wrbuf;
    00132 /*@owned@*/ char * wrb;
    00133     size_t wrsize;
    00134     size_t wrlen;
    00135     size_t wrnb;
    00136 /*@only@*/ FSMI_t iter;
    00137     int ix;
    00138 /*@only@*/ struct hardLink_s * links;
    00139 /*@only@*/ struct hardLink_s * li;
    00140 /*@kept@*/ /*@null@*/ unsigned int * archiveSize;
    00141 /*@kept@*/ /*@null@*/ const char ** failedFile;
    00142 /*@shared@*/ const char * subdir;
    00143 /*@unused@*/ char subbuf[64];   /* XXX eliminate */
    00144 /*@observer@*/ const char * osuffix;
    00145 /*@observer@*/ const char * nsuffix;
    00146 /*@shared@*/ const char * suffix;
    00147     char sufbuf[64];    /* XXX eliminate */
    00148 /*@only@*/ /*@null@*/ short * dnlx;
    00149 /*@only@*/ /*@null@*/ char * ldn;
    00150     int ldnlen;
    00151     int ldnalloc;
    00152     int postpone;
    00153     int diskchecked;
    00154     int exists;
    00155     int mkdirsdone;
    00156     int astriplen;
    00157     int rc;
    00158     int commit;
    00159     cpioMapFlags mapFlags;
    00160 /*@shared@*/ const char * dirName;
    00161 /*@shared@*/ const char * baseName;
    00162 /*@shared@*/ const char * fmd5sum;
    00163     unsigned fflags;
    00164     fileAction action;
    00165     fileStage goal;
    00166     fileStage stage;
    00167     struct stat sb;
    00168     struct stat osb;
    00169 };
    00170
    00171 #ifdef __cplusplus
    00172 extern "C" {
    00173 #endif
    00174
    00175 /*@-exportlocal@*/
    00181 /*@observer@*/ const char *const fileStageString(fileStage a)   /*@*/;
    00182
    00188 /*@observer@*/ const char *const fileActionString(fileAction a) /*@*/;
    00189 /*@=exportlocal@*/
    00190
    00195 /*@only@*/ FSM_t newFSM(void)
    00196         /*@*/;
    00197
    00203 /*@null@*/ FSM_t freeFSM(/*@only@*/ /*@null@*/ FSM_t fsm)
    00204         /*@modifies fsm @*/;
    00205
    00216 int fsmSetup(FSM_t fsm, fileStage goal,
    00217                 /*@kept@*/ const rpmTransactionSet ts,
    00218                 /*@kept@*/ const TFI_t fi,
    00219                 FD_t cfd,
    00220                 /*@out@*/ unsigned int * archiveSize,
    00221                 /*@out@*/ const char ** failedFile)
    00222         /*@modifies fsm, *archiveSize, *failedFile, fileSystem  @*/;
    00223
    00229 int fsmTeardown(FSM_t fsm)
    00230         /*@modifies fsm @*/;
    00231
    00232 /*@-exportlocal@*/
    00238 /*@kept@*/ rpmTransactionSet fsmGetTs(const FSM_t fsm)
    00239         /*@*/;
    00240
    00246 /*@kept@*/ TFI_t fsmGetFi(/*@partial@*/const FSM_t fsm)
    00247         /*@*/;
    00248
    00253 int fsmMapPath(FSM_t fsm)
    00254         /*@modifies fsm @*/;
    00255
    00260 int fsmMapAttrs(FSM_t fsm)
    00261         /*@modifies fsm @*/;
    00262 /*@=exportlocal@*/
    00263
    00270 int fsmStage(/*@partial@*/ FSM_t fsm, fileStage stage)
    00271         /*@modifies fsm, fileSystem @*/;
    00272
    00273 #ifdef __cplusplus
    00274 }
    00275 #endif
    00276
    00277 #endif  /* H_FSM */