• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

lib/fsm.h

Go to the documentation of this file.
00001 #ifndef H_FSM
00002 #define H_FSM
00003 
00009 #include "cpio.h"
00010 #include "rpmfi.h"      /* XXX fileAction typedef */
00011 
00012 /*@-exportlocal@*/
00013 /*@unchecked@*/
00014 extern int _fsm_debug;
00015 /*@=exportlocal@*/
00016 
00019 #define FSM_VERBOSE     0x8000
00020 #define FSM_INTERNAL    0x4000
00021 #define FSM_SYSCALL     0x2000
00022 #define FSM_DEAD        0x1000
00023 
00024 #define _fv(_a)         ((_a) | FSM_VERBOSE)
00025 #define _fi(_a)         ((_a) | FSM_INTERNAL)
00026 #define _fs(_a)         ((_a) | (FSM_INTERNAL | FSM_SYSCALL))
00027 #define _fd(_a)         ((_a) | (FSM_INTERNAL | FSM_DEAD))
00028 
00029 typedef enum fileStage_e {
00030     FSM_UNKNOWN =   0,
00031     FSM_INIT    =  _fd(1),
00032     FSM_PRE     =  _fd(2),
00033     FSM_PROCESS =  _fv(3),
00034     FSM_POST    =  _fd(4),
00035     FSM_UNDO    =  5,
00036     FSM_FINI    =  6,
00037 
00038     FSM_PKGINSTALL      = _fd(7),
00039     FSM_PKGERASE        = _fd(8),
00040     FSM_PKGBUILD        = _fd(9),
00041     FSM_PKGCOMMIT       = _fd(10),
00042     FSM_PKGUNDO         = _fd(11),
00043 
00044     FSM_CREATE  =  _fd(17),
00045     FSM_MAP     =  _fd(18),
00046     FSM_MKDIRS  =  _fi(19),
00047     FSM_RMDIRS  =  _fi(20),
00048     FSM_MKLINKS =  _fi(21),
00049     FSM_NOTIFY  =  _fd(22),
00050     FSM_DESTROY =  _fd(23),
00051     FSM_VERIFY  =  _fd(24),
00052     FSM_COMMIT  =  _fd(25),
00053 
00054     FSM_UNLINK  =  _fs(33),
00055     FSM_RENAME  =  _fs(34),
00056     FSM_MKDIR   =  _fs(35),
00057     FSM_RMDIR   =  _fs(36),
00058     FSM_LSETFCON=  _fs(39),
00059     FSM_CHOWN   =  _fs(40),
00060     FSM_LCHOWN  =  _fs(41),
00061     FSM_CHMOD   =  _fs(42),
00062     FSM_UTIME   =  _fs(43),
00063     FSM_SYMLINK =  _fs(44),
00064     FSM_LINK    =  _fs(45),
00065     FSM_MKFIFO  =  _fs(46),
00066     FSM_MKNOD   =  _fs(47),
00067     FSM_LSTAT   =  _fs(48),
00068     FSM_STAT    =  _fs(49),
00069     FSM_READLINK=  _fs(50),
00070     FSM_CHROOT  =  _fs(51),
00071 
00072     FSM_NEXT    =  _fd(65),
00073     FSM_EAT     =  _fd(66),
00074     FSM_POS     =  _fd(67),
00075     FSM_PAD     =  _fd(68),
00076     FSM_TRAILER =  _fd(69),
00077     FSM_HREAD   =  _fd(70),
00078     FSM_HWRITE  =  _fd(71),
00079     FSM_DREAD   =  _fs(72),
00080     FSM_DWRITE  =  _fs(73),
00081 
00082     FSM_ROPEN   =  _fs(129),
00083     FSM_READ    =  _fs(130),
00084     FSM_RCLOSE  =  _fs(131),
00085     FSM_WOPEN   =  _fs(132),
00086     FSM_WRITE   =  _fs(133),
00087     FSM_WCLOSE  =  _fs(134)
00088 } fileStage;
00089 #undef  _fv
00090 #undef  _fi
00091 #undef  _fs
00092 #undef  _fd
00093 
00097 struct hardLink_s {
00098 /*@owned@*/ /*@relnull@*/
00099     struct hardLink_s * next;
00100 /*@owned@*/
00101     const char ** nsuffix;
00102 /*@owned@*/
00103     int * filex;
00104     struct stat sb;
00105     int nlink;
00106     int linksLeft;
00107     int linkIndex;
00108     int createdPath;
00109 };
00110 
00114 struct fsmIterator_s {
00115     rpmts ts;                   
00116     rpmfi fi;                   
00117     int reverse;                
00118     int isave;                  
00119     int i;                      
00120 };
00121 
00125 struct fsm_s {
00126 /*@owned@*/ /*@relnull@*/
00127     const char * path;          
00128 /*@owned@*/ /*@relnull@*/
00129     const char * lpath;         
00130 /*@owned@*/ /*@relnull@*/
00131     const char * opath;         
00132 /*@relnull@*/
00133     FD_t cfd;                   
00134 /*@relnull@*/
00135     FD_t rfd;                   
00136 /*@dependent@*/ /*@relnull@*/
00137     char * rdbuf;               
00138 /*@owned@*/ /*@relnull@*/
00139     char * rdb;                 
00140     size_t rdsize;              
00141     size_t rdlen;               
00142     size_t rdnb;                
00143     FD_t wfd;                   
00144 /*@dependent@*/ /*@relnull@*/
00145     char * wrbuf;               
00146 /*@owned@*/ /*@relnull@*/
00147     char * wrb;                 
00148     size_t wrsize;              
00149     size_t wrlen;               
00150     size_t wrnb;                
00151 /*@only@*/ /*@null@*/
00152     FSMI_t iter;                
00153     int ix;                     
00154 /*@only@*/ /*@relnull@*/
00155     struct hardLink_s * links;  
00156 /*@only@*/ /*@relnull@*/
00157     struct hardLink_s * li;     
00158 /*@kept@*/ /*@null@*/
00159     unsigned int * archiveSize; 
00160 /*@kept@*/ /*@null@*/
00161     const char ** failedFile;   
00162 /*@shared@*/ /*@relnull@*/
00163     const char * subdir;        
00164 /*@unused@*/
00165     char subbuf[64];    /* XXX eliminate */
00166 /*@observer@*/ /*@relnull@*/
00167     const char * osuffix;       
00168 /*@observer@*/ /*@relnull@*/
00169     const char * nsuffix;       
00170 /*@shared@*/ /*@relnull@*/
00171     const char * suffix;        
00172     char sufbuf[64];    /* XXX eliminate */
00173 /*@only@*/ /*@null@*/
00174     short * dnlx;               
00175 /*@only@*/ /*@null@*/
00176     char * ldn;                 
00177     int ldnlen;                 
00178     int ldnalloc;               
00179     int postpone;               
00180     int diskchecked;            
00181     int exists;                 
00182     int mkdirsdone;             
00183     int astriplen;              
00184     int rc;                     
00185     int commit;                 
00186     int repackaged;             
00187     cpioMapFlags mapFlags;      
00188     int fdigestalgo;            
00189     int digestlen;              
00190 /*@shared@*/ /*@relnull@*/
00191     const char * dirName;       
00192 /*@shared@*/ /*@relnull@*/
00193     const char * baseName;      
00194 /*@shared@*/ /*@relnull@*/
00195     const char * fdigest;       
00196 /*@shared@*/ /*@relnull@*/
00197     const unsigned char * digest;
00198 /*@dependent@*/ /*@observer@*/ /*@null@*/
00199     const char * fcontext;      
00201     unsigned fflags;            
00202     fileAction action;          
00203     fileStage goal;             
00204     fileStage stage;            
00205     fileStage nstage;           
00206     struct stat sb;             
00207     struct stat osb;            
00209     unsigned blksize;           
00210     int (*headerRead) (FSM_t fsm, struct stat *st);
00211     int (*headerWrite) (FSM_t fsm, struct stat *st);
00212     int (*trailerWrite) (FSM_t fsm);
00213 };
00214 
00215 #ifdef __cplusplus
00216 extern "C" {
00217 #endif
00218 
00219 /*@-exportlocal@*/
00225 /*@observer@*/ const char * fileStageString(fileStage a)        /*@*/;
00226 
00232 /*@observer@*/ const char * fileActionString(fileAction a)      /*@*/;
00233 /*@=exportlocal@*/
00234 
00239 /*@only@*/ FSM_t newFSM(void)
00240         /*@*/;
00241 
00247 /*@null@*/ FSM_t freeFSM(/*@only@*/ /*@null@*/ FSM_t fsm)
00248         /*@globals fileSystem @*/
00249         /*@modifies fsm, fileSystem @*/;
00250 
00263 int fsmSetup(FSM_t fsm, fileStage goal, /*@null@*/ const char * afmt,
00264                 const rpmts ts,
00265                 const rpmfi fi,
00266                 FD_t cfd,
00267                 /*@out@*/ unsigned int * archiveSize,
00268                 /*@out@*/ const char ** failedFile)
00269         /*@globals h_errno, fileSystem, internalState @*/
00270         /*@modifies fsm, ts, fi, *archiveSize, *failedFile,
00271                 fileSystem, internalState @*/;
00272 
00278 int fsmTeardown(FSM_t fsm)
00279         /*@globals h_errno, fileSystem, internalState @*/
00280         /*@modifies fsm, fileSystem, internalState @*/;
00281 
00282 /*@-exportlocal@*/
00288 rpmts fsmGetTs(const FSM_t fsm)
00289         /*@*/;
00290 
00296 rpmfi fsmGetFi(/*@partial@*/ const FSM_t fsm)
00297         /*@*/;
00298 
00303 int fsmMapPath(FSM_t fsm)
00304         /*@modifies fsm @*/;
00305 
00310 int fsmMapAttrs(FSM_t fsm)
00311         /*@modifies fsm @*/;
00312 /*@=exportlocal@*/
00313 
00320 int fsmNext(FSM_t fsm, fileStage nstage)
00321         /*@globals errno, h_errno, fileSystem, internalState @*/
00322         /*@modifies fsm, errno, fileSystem, internalState @*/;
00323 
00330 /*@-exportlocal@*/
00331 int fsmStage(/*@partial@*/ FSM_t fsm, fileStage stage)
00332         /*@globals errno, h_errno, fileSystem, internalState @*/
00333         /*@modifies fsm, errno, fileSystem, internalState @*/;
00334 /*@=exportlocal@*/
00335 
00336 #ifdef __cplusplus
00337 }
00338 #endif
00339 
00340 #endif  /* H_FSM */

Generated on Mon Nov 29 2010 05:18:43 for rpm by  doxygen 1.7.2