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_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 /*@owned@*/ /*@relnull@*/
00098     struct hardLink_s * next;
00099 /*@owned@*/
00100     const char ** nsuffix;
00101 /*@owned@*/
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 /*@owned@*/ /*@relnull@*/
00126     const char * path;          
00127 /*@owned@*/ /*@relnull@*/
00128     const char * opath;         
00129 /*@relnull@*/
00130     FD_t cfd;                   
00131 /*@relnull@*/
00132     FD_t rfd;                   
00133 /*@dependent@*/ /*@relnull@*/
00134     char * rdbuf;               
00135 /*@owned@*/ /*@relnull@*/
00136     char * rdb;                 
00137     size_t rdsize;              
00138     size_t rdlen;               
00139     size_t rdnb;                
00140     FD_t wfd;                   
00141 /*@dependent@*/ /*@relnull@*/
00142     char * wrbuf;               
00143 /*@owned@*/ /*@relnull@*/
00144     char * wrb;                 
00145     size_t wrsize;              
00146     size_t wrlen;               
00147     size_t wrnb;                
00148 /*@only@*/ /*@null@*/
00149     FSMI_t iter;                
00150     int ix;                     
00151 /*@only@*/ /*@relnull@*/
00152     struct hardLink_s * links;  
00153 /*@only@*/ /*@relnull@*/
00154     struct hardLink_s * li;     
00155 /*@kept@*/ /*@null@*/
00156     unsigned int * archiveSize; 
00157 /*@kept@*/ /*@null@*/
00158     const char ** failedFile;   
00159 /*@shared@*/ /*@relnull@*/
00160     const char * subdir;        
00161 /*@unused@*/
00162     char subbuf[64];    /* XXX eliminate */
00163 /*@observer@*/ /*@relnull@*/
00164     const char * osuffix;       
00165 /*@observer@*/ /*@relnull@*/
00166     const char * nsuffix;       
00167 /*@shared@*/ /*@relnull@*/
00168     const char * suffix;        
00169     char sufbuf[64];    /* XXX eliminate */
00170 /*@only@*/ /*@null@*/
00171     short * dnlx;               
00172 /*@only@*/ /*@null@*/
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 /*@shared@*/ /*@relnull@*/
00185     const char * dirName;       
00186 /*@shared@*/ /*@relnull@*/
00187     const char * baseName;      
00188 /*@shared@*/ /*@relnull@*/
00189     const char * fmd5sum;       
00190 /*@shared@*/ /*@relnull@*/
00191     const char * md5sum;        
00192 /*@dependent@*/ /*@observer@*/ /*@null@*/
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 /*@-exportlocal@*/
00214 /*@observer@*/ const char *const fileStageString(fileStage a)   /*@*/;
00215 
00221 /*@observer@*/ const char *const fileActionString(fileAction a) /*@*/;
00222 /*@=exportlocal@*/
00223 
00228 /*@only@*/ FSM_t newFSM(void)
00229         /*@*/;
00230 
00236 /*@null@*/ FSM_t freeFSM(/*@only@*/ /*@null@*/ FSM_t fsm)
00237         /*@globals fileSystem @*/
00238         /*@modifies fsm, fileSystem @*/;
00239 
00251 int fsmSetup(FSM_t fsm, fileStage goal,
00252                 const rpmts ts,
00253                 const rpmfi fi,
00254                 FD_t cfd,
00255                 /*@out@*/ unsigned int * archiveSize,
00256                 /*@out@*/ const char ** failedFile)
00257         /*@globals h_errno, fileSystem, internalState @*/
00258         /*@modifies fsm, ts, fi, *archiveSize, *failedFile,
00259                 fileSystem, internalState @*/;
00260 
00266 int fsmTeardown(FSM_t fsm)
00267         /*@globals h_errno, fileSystem, internalState @*/
00268         /*@modifies fsm, fileSystem, internalState @*/;
00269 
00270 /*@-exportlocal@*/
00276 rpmts fsmGetTs(const FSM_t fsm)
00277         /*@*/;
00278 
00284 rpmfi fsmGetFi(/*@partial@*/ const FSM_t fsm)
00285         /*@*/;
00286 
00291 int fsmMapPath(FSM_t fsm)
00292         /*@modifies fsm @*/;
00293 
00298 int fsmMapAttrs(FSM_t fsm)
00299         /*@modifies fsm @*/;
00300 /*@=exportlocal@*/
00301 
00308 int fsmNext(FSM_t fsm, fileStage nstage)
00309         /*@globals errno, h_errno, fileSystem, internalState @*/
00310         /*@modifies fsm, errno, fileSystem, internalState @*/;
00311 
00318 /*@-exportlocal@*/
00319 int fsmStage(/*@partial@*/ FSM_t fsm, fileStage stage)
00320         /*@globals errno, h_errno, fileSystem, internalState @*/
00321         /*@modifies fsm, errno, fileSystem, internalState @*/;
00322 /*@=exportlocal@*/
00323 
00324 #ifdef __cplusplus
00325 }
00326 #endif
00327 
00328 #endif  /* H_FSM */

Generated on Fri Oct 12 08:44:53 2007 for rpm by  doxygen 1.5.2