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     rpmts ts;
    00111     rpmfi fi;
    00112     int reverse;
    00113     int isave;
    00114     int i;
    00115 };
    00116
    00120 struct fsm_s {
    00121 /*@owned@*/
    00122     const char * path;
    00123 /*@owned@*/
    00124     const char * opath;
    00125     FD_t cfd;
    00126     FD_t rfd;
    00127 /*@dependent@*/
    00128     char * rdbuf;
    00129 /*@owned@*/
    00130     char * rdb;
    00131     size_t rdsize;
    00132     size_t rdlen;
    00133     size_t rdnb;
    00134     FD_t wfd;
    00135 /*@dependent@*/
    00136     char * wrbuf;
    00137 /*@owned@*/
    00138     char * wrb;
    00139     size_t wrsize;
    00140     size_t wrlen;
    00141     size_t wrnb;
    00142 /*@only@*/ /*@null@*/
    00143     FSMI_t iter;
    00144     int ix;
    00145 /*@only@*/
    00146     struct hardLink_s * links;
    00147 /*@only@*/
    00148     struct hardLink_s * li;
    00149 /*@kept@*/ /*@null@*/
    00150     unsigned int * archiveSize;
    00151 /*@kept@*/ /*@null@*/
    00152     const char ** failedFile;
    00153 /*@shared@*/
    00154     const char * subdir;
    00155 /*@unused@*/
    00156     char subbuf[64];    /* XXX eliminate */
    00157 /*@observer@*/
    00158     const char * osuffix;
    00159 /*@observer@*/
    00160     const char * nsuffix;
    00161 /*@shared@*/
    00162     const char * suffix;
    00163     char sufbuf[64];    /* XXX eliminate */
    00164 /*@only@*/ /*@null@*/
    00165     short * dnlx;
    00166 /*@only@*/ /*@null@*/
    00167     char * ldn;
    00168     int ldnlen;
    00169     int ldnalloc;
    00170     int postpone;
    00171     int diskchecked;
    00172     int exists;
    00173     int mkdirsdone;
    00174     int astriplen;
    00175     int rc;
    00176     int commit;
    00177     cpioMapFlags mapFlags;
    00178 /*@shared@*/
    00179     const char * dirName;
    00180 /*@shared@*/
    00181     const char * baseName;
    00182 /*@shared@*/
    00183     const char * fmd5sum;
    00184 /*@shared@*/
    00185     const char * md5sum;
    00187     unsigned fflags;
    00188     fileAction action;
    00189     fileStage goal;
    00190     fileStage stage;
    00191     struct stat sb;
    00192     struct stat osb;
    00193 };
    00194
    00195 #ifdef __cplusplus
    00196 extern "C" {
    00197 #endif
    00198
    00199 /*@-exportlocal@*/
    00205 /*@observer@*/ const char *const fileStageString(fileStage a)   /*@*/;
    00206
    00212 /*@observer@*/ const char *const fileActionString(fileAction a) /*@*/;
    00213 /*@=exportlocal@*/
    00214
    00219 /*@only@*/ FSM_t newFSM(void)
    00220         /*@*/;
    00221
    00227 /*@null@*/ FSM_t freeFSM(/*@only@*/ /*@null@*/ FSM_t fsm)
    00228         /*@globals fileSystem @*/
    00229         /*@modifies fsm, fileSystem @*/;
    00230
    00242 int fsmSetup(FSM_t fsm, fileStage goal,
    00243                 const rpmts ts,
    00244                 const rpmfi fi,
    00245                 FD_t cfd,
    00246                 /*@out@*/ unsigned int * archiveSize,
    00247                 /*@out@*/ const char ** failedFile)
    00248         /*@globals fileSystem, internalState @*/
    00249         /*@modifies fsm, ts, fi, *archiveSize, *failedFile,
    00250                 fileSystem, internalState @*/;
    00251
    00257 int fsmTeardown(FSM_t fsm)
    00258         /*@globals fileSystem, internalState @*/
    00259         /*@modifies fsm, fileSystem, internalState @*/;
    00260
    00261 /*@-exportlocal@*/
    00267 rpmts fsmGetTs(const FSM_t fsm)
    00268         /*@*/;
    00269
    00275 rpmfi fsmGetFi(/*@partial@*/ const FSM_t fsm)
    00276         /*@*/;
    00277
    00282 int fsmMapPath(FSM_t fsm)
    00283         /*@modifies fsm @*/;
    00284
    00289 int fsmMapAttrs(FSM_t fsm)
    00290         /*@modifies fsm @*/;
    00291 /*@=exportlocal@*/
    00292
    00299 int fsmStage(/*@partial@*/ FSM_t fsm, fileStage stage)
    00300         /*@globals fileSystem, internalState @*/
    00301         /*@modifies fsm, fileSystem, internalState @*/;
    00302
    00303 #ifdef __cplusplus
    00304 }
    00305 #endif
    00306
    00307 #endif  /* H_FSM */