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@*/ /*@relnull@*/
00097     struct hardLink_s * next;
00098 /*@owned@*/
00099     const char ** nsuffix;
00100 /*@owned@*/
00101     int * filex;
00102     struct stat sb;
00103     int nlink;
00104     int linksLeft;
00105     int linkIndex;
00106     int createdPath;
00107 };
00108 
00112 struct fsmIterator_s {
00113     rpmts ts;                   
00114     rpmfi fi;                   
00115     int reverse;                
00116     int isave;                  
00117     int i;                      
00118 };
00119 
00123 struct fsm_s {
00124 /*@owned@*/ /*@relnull@*/
00125     const char * path;          
00126 /*@owned@*/ /*@relnull@*/
00127     const char * opath;         
00128 /*@relnull@*/
00129     FD_t cfd;                   
00130 /*@relnull@*/
00131     FD_t rfd;                   
00132 /*@dependent@*/ /*@relnull@*/
00133     char * rdbuf;               
00134 /*@owned@*/ /*@relnull@*/
00135     char * rdb;                 
00136     size_t rdsize;              
00137     size_t rdlen;               
00138     size_t rdnb;                
00139     FD_t wfd;                   
00140 /*@dependent@*/ /*@relnull@*/
00141     char * wrbuf;               
00142 /*@owned@*/ /*@relnull@*/
00143     char * wrb;                 
00144     size_t wrsize;              
00145     size_t wrlen;               
00146     size_t wrnb;                
00147 /*@only@*/ /*@null@*/
00148     FSMI_t iter;                
00149     int ix;                     
00150 /*@only@*/ /*@relnull@*/
00151     struct hardLink_s * links;  
00152 /*@only@*/ /*@relnull@*/
00153     struct hardLink_s * li;     
00154 /*@kept@*/ /*@null@*/
00155     unsigned int * archiveSize; 
00156 /*@kept@*/ /*@null@*/
00157     const char ** failedFile;   
00158 /*@shared@*/ /*@relnull@*/
00159     const char * subdir;        
00160 /*@unused@*/
00161     char subbuf[64];    /* XXX eliminate */
00162 /*@observer@*/ /*@relnull@*/
00163     const char * osuffix;       
00164 /*@observer@*/ /*@relnull@*/
00165     const char * nsuffix;       
00166 /*@shared@*/ /*@relnull@*/
00167     const char * suffix;        
00168     char sufbuf[64];    /* XXX eliminate */
00169 /*@only@*/ /*@null@*/
00170     short * dnlx;               
00171 /*@only@*/ /*@null@*/
00172     char * ldn;                 
00173     int ldnlen;                 
00174     int ldnalloc;               
00175     int postpone;               
00176     int diskchecked;            
00177     int exists;                 
00178     int mkdirsdone;             
00179     int astriplen;              
00180     int rc;                     
00181     int commit;                 
00182     cpioMapFlags mapFlags;      
00183 /*@shared@*/ /*@relnull@*/
00184     const char * dirName;       
00185 /*@shared@*/ /*@relnull@*/
00186     const char * baseName;      
00187 /*@shared@*/ /*@relnull@*/
00188     const char * fmd5sum;       
00189 /*@shared@*/ /*@relnull@*/
00190     const char * md5sum;        
00192     unsigned fflags;            
00193     fileAction action;          
00194     fileStage goal;             
00195     fileStage stage;            
00196     fileStage nstage;           
00197     struct stat sb;             
00198     struct stat osb;            
00199 };
00200 
00201 #ifdef __cplusplus
00202 extern "C" {
00203 #endif
00204 
00205 /*@-exportlocal@*/
00211 /*@observer@*/ const char *const fileStageString(fileStage a)   /*@*/;
00212 
00218 /*@observer@*/ const char *const fileActionString(fileAction a) /*@*/;
00219 /*@=exportlocal@*/
00220 
00225 /*@only@*/ FSM_t newFSM(void)
00226         /*@*/;
00227 
00233 /*@null@*/ FSM_t freeFSM(/*@only@*/ /*@null@*/ FSM_t fsm)
00234         /*@globals fileSystem @*/
00235         /*@modifies fsm, fileSystem @*/;
00236 
00248 int fsmSetup(FSM_t fsm, fileStage goal,
00249                 const rpmts ts,
00250                 const rpmfi fi,
00251                 FD_t cfd,
00252                 /*@out@*/ unsigned int * archiveSize,
00253                 /*@out@*/ const char ** failedFile)
00254         /*@globals h_errno, fileSystem, internalState @*/
00255         /*@modifies fsm, ts, fi, *archiveSize, *failedFile,
00256                 fileSystem, internalState @*/;
00257 
00263 int fsmTeardown(FSM_t fsm)
00264         /*@globals h_errno, fileSystem, internalState @*/
00265         /*@modifies fsm, fileSystem, internalState @*/;
00266 
00267 /*@-exportlocal@*/
00273 rpmts fsmGetTs(const FSM_t fsm)
00274         /*@*/;
00275 
00281 rpmfi fsmGetFi(/*@partial@*/ const FSM_t fsm)
00282         /*@*/;
00283 
00288 int fsmMapPath(FSM_t fsm)
00289         /*@modifies fsm @*/;
00290 
00295 int fsmMapAttrs(FSM_t fsm)
00296         /*@modifies fsm @*/;
00297 /*@=exportlocal@*/
00298 
00305 /*@-exportlocal@*/
00306 int fsmStage(/*@partial@*/ FSM_t fsm, fileStage stage)
00307         /*@globals errno, h_errno, fileSystem, internalState @*/
00308         /*@modifies fsm, errno, fileSystem, internalState @*/;
00309 /*@=exportlocal@*/
00310 
00311 #ifdef __cplusplus
00312 }
00313 #endif
00314 
00315 #endif  /* H_FSM */

Generated on Mon Jan 10 10:10:03 2005 for rpm by doxygen 1.3.5