rpm  4.5
fsm.h
Go to the documentation of this file.
1 #ifndef H_FSM
2 #define H_FSM
3 
9 #include "cpio.h"
10 
11 /*@-exportlocal@*/
12 /*@unchecked@*/
13 extern int _fsm_debug;
14 /*@=exportlocal@*/
15 
18 #define FSM_VERBOSE 0x8000
19 #define FSM_INTERNAL 0x4000
20 #define FSM_SYSCALL 0x2000
21 #define FSM_DEAD 0x1000
22 
23 #define _fv(_a) ((_a) | FSM_VERBOSE)
24 #define _fi(_a) ((_a) | FSM_INTERNAL)
25 #define _fs(_a) ((_a) | (FSM_INTERNAL | FSM_SYSCALL))
26 #define _fd(_a) ((_a) | (FSM_INTERNAL | FSM_DEAD))
27 
28 typedef enum fileStage_e {
30  FSM_INIT = _fd(1),
31  FSM_PRE = _fd(2),
33  FSM_POST = _fd(4),
34  FSM_UNDO = 5,
35  FSM_FINI = 6,
36 
42 
43  FSM_CREATE = _fd(17),
44  FSM_MAP = _fd(18),
45  FSM_MKDIRS = _fi(19),
46  FSM_RMDIRS = _fi(20),
48  FSM_NOTIFY = _fd(22),
50  FSM_VERIFY = _fd(24),
51  FSM_COMMIT = _fd(25),
52 
53  FSM_UNLINK = _fs(33),
54  FSM_RENAME = _fs(34),
55  FSM_MKDIR = _fs(35),
56  FSM_RMDIR = _fs(36),
58  FSM_CHOWN = _fs(40),
59  FSM_LCHOWN = _fs(41),
60  FSM_CHMOD = _fs(42),
61  FSM_UTIME = _fs(43),
63  FSM_LINK = _fs(45),
64  FSM_MKFIFO = _fs(46),
65  FSM_MKNOD = _fs(47),
66  FSM_LSTAT = _fs(48),
67  FSM_STAT = _fs(49),
69  FSM_CHROOT = _fs(51),
70 
71  FSM_NEXT = _fd(65),
72  FSM_EAT = _fd(66),
73  FSM_POS = _fd(67),
74  FSM_PAD = _fd(68),
76  FSM_HREAD = _fd(70),
77  FSM_HWRITE = _fd(71),
78  FSM_DREAD = _fs(72),
79  FSM_DWRITE = _fs(73),
80 
81  FSM_ROPEN = _fs(129),
82  FSM_READ = _fs(130),
83  FSM_RCLOSE = _fs(131),
84  FSM_WOPEN = _fs(132),
85  FSM_WRITE = _fs(133),
86  FSM_WCLOSE = _fs(134)
87 } fileStage;
88 #undef _fv
89 #undef _fi
90 #undef _fs
91 #undef _fd
92 
96 struct hardLink_s {
97 /*@owned@*/ /*@relnull@*/
98  struct hardLink_s * next;
99 /*@owned@*/
100  const char ** nsuffix;
101 /*@owned@*/
102  int * filex;
103  struct stat sb;
104  int nlink;
108 };
109 
116  int reverse;
117  int isave;
118  int i;
119 };
120 
124 struct fsm_s {
125 /*@owned@*/ /*@relnull@*/
126  const char * path;
127 /*@owned@*/ /*@relnull@*/
128  const char * lpath;
129 /*@owned@*/ /*@relnull@*/
130  const char * opath;
131 /*@relnull@*/
133 /*@relnull@*/
135 /*@dependent@*/ /*@relnull@*/
136  char * rdbuf;
137 /*@owned@*/ /*@relnull@*/
138  char * rdb;
139  size_t rdsize;
140  size_t rdlen;
141  size_t rdnb;
143 /*@dependent@*/ /*@relnull@*/
144  char * wrbuf;
145 /*@owned@*/ /*@relnull@*/
146  char * wrb;
147  size_t wrsize;
148  size_t wrlen;
149  size_t wrnb;
150 /*@only@*/ /*@null@*/
152  int ix;
153 /*@only@*/ /*@relnull@*/
154  struct hardLink_s * links;
155 /*@only@*/ /*@relnull@*/
156  struct hardLink_s * li;
157 /*@kept@*/ /*@null@*/
158  unsigned int * archiveSize;
159 /*@kept@*/ /*@null@*/
160  const char ** failedFile;
161 /*@shared@*/ /*@relnull@*/
162  const char * subdir;
163 /*@unused@*/
164  char subbuf[64]; /* XXX eliminate */
165 /*@observer@*/ /*@relnull@*/
166  const char * osuffix;
167 /*@observer@*/ /*@relnull@*/
168  const char * nsuffix;
169 /*@shared@*/ /*@relnull@*/
170  const char * suffix;
171  char sufbuf[64]; /* XXX eliminate */
172 /*@only@*/ /*@null@*/
173  short * dnlx;
174 /*@only@*/ /*@null@*/
175  char * ldn;
176  int ldnlen;
177  int ldnalloc;
178  int postpone;
180  int exists;
182  int astriplen;
183  int rc;
184  int commit;
188  int digestlen;
189 /*@shared@*/ /*@relnull@*/
190  const char * dirName;
191 /*@shared@*/ /*@relnull@*/
192  const char * baseName;
193 /*@shared@*/ /*@relnull@*/
194  const char * fdigest;
195 /*@shared@*/ /*@relnull@*/
196  const unsigned char * digest;
197 /*@dependent@*/ /*@observer@*/ /*@null@*/
198  const char * fcontext;
200  unsigned fflags;
205  struct stat sb;
206  struct stat osb;
208  unsigned blksize;
209  int (*headerRead) (FSM_t fsm, struct stat *st);
210  int (*headerWrite) (FSM_t fsm, struct stat *st);
211  int (*trailerWrite) (FSM_t fsm);
212 };
213 
214 #ifdef __cplusplus
215 extern "C" {
216 #endif
217 
218 /*@-exportlocal@*/
224 /*@observer@*/ const char * fileStageString(fileStage a) /*@*/;
225 
231 /*@observer@*/ const char * fileActionString(fileAction a) /*@*/;
232 /*@=exportlocal@*/
233 
238 /*@only@*/ FSM_t newFSM(void)
239  /*@*/;
240 
246 /*@null@*/ FSM_t freeFSM(/*@only@*/ /*@null@*/ FSM_t fsm)
247  /*@globals fileSystem @*/
248  /*@modifies fsm, fileSystem @*/;
249 
262 int fsmSetup(FSM_t fsm, fileStage goal, /*@null@*/ const char * afmt,
263  const rpmts ts,
264  const rpmfi fi,
265  FD_t cfd,
266  /*@out@*/ unsigned int * archiveSize,
267  /*@out@*/ const char ** failedFile)
268  /*@globals h_errno, fileSystem, internalState @*/
269  /*@modifies fsm, ts, fi, *archiveSize, *failedFile,
270  fileSystem, internalState @*/;
271 
277 int fsmTeardown(FSM_t fsm)
278  /*@globals h_errno, fileSystem, internalState @*/
279  /*@modifies fsm, fileSystem, internalState @*/;
280 
281 /*@-exportlocal@*/
287 rpmts fsmGetTs(const FSM_t fsm)
288  /*@*/;
289 
295 rpmfi fsmGetFi(/*@partial@*/ const FSM_t fsm)
296  /*@*/;
297 
302 int fsmMapPath(FSM_t fsm)
303  /*@modifies fsm @*/;
304 
309 int fsmMapAttrs(FSM_t fsm)
310  /*@modifies fsm @*/;
311 /*@=exportlocal@*/
312 
319 int fsmNext(FSM_t fsm, fileStage nstage)
320  /*@globals errno, h_errno, fileSystem, internalState @*/
321  /*@modifies fsm, errno, fileSystem, internalState @*/;
322 
329 /*@-exportlocal@*/
330 int fsmStage(/*@partial@*/ FSM_t fsm, fileStage stage)
331  /*@globals errno, h_errno, fileSystem, internalState @*/
332  /*@modifies fsm, errno, fileSystem, internalState @*/;
333 /*@=exportlocal@*/
334 
335 #ifdef __cplusplus
336 }
337 #endif
338 
339 #endif /* H_FSM */