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_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 * lpath;         
00129 /*@owned@*/ /*@relnull@*/
00130     const char * opath;         
00131 /*@relnull@*/
00132     FD_t cfd;                   
00133 /*@relnull@*/
00134     FD_t rfd;                   
00135 /*@dependent@*/ /*@relnull@*/
00136     char * rdbuf;               
00137 /*@owned@*/ /*@relnull@*/
00138     char * rdb;                 
00139     size_t rdsize;              
00140     size_t rdlen;               
00141     size_t rdnb;                
00142     FD_t wfd;                   
00143 /*@dependent@*/ /*@relnull@*/
00144     char * wrbuf;               
00145 /*@owned@*/ /*@relnull@*/
00146     char * wrb;                 
00147     size_t wrsize;              
00148     size_t wrlen;               
00149     size_t wrnb;                
00150 /*@only@*/ /*@null@*/
00151     FSMI_t iter;                
00152     int ix;                     
00153 /*@only@*/ /*@relnull@*/
00154     struct hardLink_s * links;  
00155 /*@only@*/ /*@relnull@*/
00156     struct hardLink_s * li;     
00157 /*@kept@*/ /*@null@*/
00158     unsigned int * archiveSize; 
00159 /*@kept@*/ /*@null@*/
00160     const char ** failedFile;   
00161 /*@shared@*/ /*@relnull@*/
00162     const char * subdir;        
00163 /*@unused@*/
00164     char subbuf[64];    /* XXX eliminate */
00165 /*@observer@*/ /*@relnull@*/
00166     const char * osuffix;       
00167 /*@observer@*/ /*@relnull@*/
00168     const char * nsuffix;       
00169 /*@shared@*/ /*@relnull@*/
00170     const char * suffix;        
00171     char sufbuf[64];    /* XXX eliminate */
00172 /*@only@*/ /*@null@*/
00173     short * dnlx;               
00174 /*@only@*/ /*@null@*/
00175     char * ldn;                 
00176     int ldnlen;                 
00177     int ldnalloc;               
00178     int postpone;               
00179     int diskchecked;            
00180     int exists;                 
00181     int mkdirsdone;             
00182     int astriplen;              
00183     int rc;                     
00184     int commit;                 
00185     int repackaged;             
00186     cpioMapFlags mapFlags;      
00187     int fdigestalgo;            
00188     int digestlen;              
00189 /*@shared@*/ /*@relnull@*/
00190     const char * dirName;       
00191 /*@shared@*/ /*@relnull@*/
00192     const char * baseName;      
00193 /*@shared@*/ /*@relnull@*/
00194     const char * fdigest;       
00195 /*@shared@*/ /*@relnull@*/
00196     const unsigned char * digest;
00197 /*@dependent@*/ /*@observer@*/ /*@null@*/
00198     const char * fcontext;      
00200     unsigned fflags;            
00201     fileAction action;          
00202     fileStage goal;             
00203     fileStage stage;            
00204     fileStage nstage;           
00205     struct stat sb;             
00206     struct stat osb;            
00208     unsigned blksize;           
00209     int (*headerRead) (FSM_t fsm, struct stat *st);
00210     int (*headerWrite) (FSM_t fsm, struct stat *st);
00211     int (*trailerWrite) (FSM_t fsm);
00212 };
00213 
00214 #ifdef __cplusplus
00215 extern "C" {
00216 #endif
00217 
00218 /*@-exportlocal@*/
00224 /*@observer@*/ const char * fileStageString(fileStage a)        /*@*/;
00225 
00231 /*@observer@*/ const char * fileActionString(fileAction a)      /*@*/;
00232 /*@=exportlocal@*/
00233 
00238 /*@only@*/ FSM_t newFSM(void)
00239         /*@*/;
00240 
00246 /*@null@*/ FSM_t freeFSM(/*@only@*/ /*@null@*/ FSM_t fsm)
00247         /*@globals fileSystem @*/
00248         /*@modifies fsm, fileSystem @*/;
00249 
00262 int fsmSetup(FSM_t fsm, fileStage goal, /*@null@*/ const char * afmt,
00263                 const rpmts ts,
00264                 const rpmfi fi,
00265                 FD_t cfd,
00266                 /*@out@*/ unsigned int * archiveSize,
00267                 /*@out@*/ const char ** failedFile)
00268         /*@globals h_errno, fileSystem, internalState @*/
00269         /*@modifies fsm, ts, fi, *archiveSize, *failedFile,
00270                 fileSystem, internalState @*/;
00271 
00277 int fsmTeardown(FSM_t fsm)
00278         /*@globals h_errno, fileSystem, internalState @*/
00279         /*@modifies fsm, fileSystem, internalState @*/;
00280 
00281 /*@-exportlocal@*/
00287 rpmts fsmGetTs(const FSM_t fsm)
00288         /*@*/;
00289 
00295 rpmfi fsmGetFi(/*@partial@*/ const FSM_t fsm)
00296         /*@*/;
00297 
00302 int fsmMapPath(FSM_t fsm)
00303         /*@modifies fsm @*/;
00304 
00309 int fsmMapAttrs(FSM_t fsm)
00310         /*@modifies fsm @*/;
00311 /*@=exportlocal@*/
00312 
00319 int fsmNext(FSM_t fsm, fileStage nstage)
00320         /*@globals errno, h_errno, fileSystem, internalState @*/
00321         /*@modifies fsm, errno, fileSystem, internalState @*/;
00322 
00329 /*@-exportlocal@*/
00330 int fsmStage(/*@partial@*/ FSM_t fsm, fileStage stage)
00331         /*@globals errno, h_errno, fileSystem, internalState @*/
00332         /*@modifies fsm, errno, fileSystem, internalState @*/;
00333 /*@=exportlocal@*/
00334 
00335 #ifdef __cplusplus
00336 }
00337 #endif
00338 
00339 #endif  /* H_FSM */

Generated on Tue Dec 27 22:41:25 2016 for rpm by  doxygen 1.4.4