1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
|
#ifndef H_ROLLBACK
#define H_ROLLBACK
/** \file lib/rollback.h
*/
#include "depends.h"
#include "install.h"
/**
*/
typedef /*@abstract@*/ struct cpioHeader * FSM_t;
#include "cpio.h"
/**
*/
#define FSM_INTERNAL 0x8000
#define FSM_QUIET 0x4000
#define _fi(_a) ((_a) | FSM_INTERNAL)
#define _fq(_a) ((_a) | FSM_INTERNAL)
typedef enum fileStage_e {
FSM_UNKNOWN = 0,
FSM_INIT = _fq(1),
FSM_PRE = _fq(2),
FSM_PROCESS = _fq(3),
FSM_POST = _fq(4),
FSM_UNDO = 5,
FSM_COMMIT = 6,
FSM_CREATE = _fi(17),
FSM_MAP = _fi(18),
FSM_MKDIRS = _fi(19),
FSM_RMDIRS = _fi(20),
FSM_MKLINKS = _fi(21),
FSM_NOTIFY = _fi(22),
FSM_DESTROY = _fi(23),
FSM_VERIFY = _fi(24),
FSM_UNLINK = _fi(33),
FSM_RENAME = _fi(34),
FSM_MKDIR = _fi(35),
FSM_RMDIR = _fi(36),
FSM_CHOWN = _fi(37),
FSM_LCHOWN = _fi(38),
FSM_CHMOD = _fi(39),
FSM_UTIME = _fi(40),
FSM_SYMLINK = _fi(41),
FSM_LINK = _fi(42),
FSM_MKFIFO = _fi(43),
FSM_MKNOD = _fi(44),
FSM_NEXT = _fi(65),
FSM_EAT = _fi(66),
FSM_POS = _fi(67),
FSM_PAD = _fi(68),
} fileStage;
#undef _fi
/**
* File disposition(s) during package install/erase transaction.
*/
typedef enum fileAction_e {
FA_UNKNOWN = 0, /*!< initial action (default action for source rpm) */
FA_CREATE, /*!< ... to be replaced. */
FA_BACKUP, /*!< ... renamed with ".rpmorig" extension. */
FA_SAVE, /*!< ... renamed with ".rpmsave" extension. */
FA_SKIP, /*!< ... already replaced, don't remove. */
FA_ALTNAME, /*!< ... create with ".rpmnew" extension. */
FA_REMOVE, /*!< ... to be removed. */
FA_SKIPNSTATE, /*!< ... untouched, state "not installed". */
FA_SKIPNETSHARED, /*!< ... untouched, state "netshared". */
FA_SKIPMULTILIB, /*!< ... untouched. @todo state "multilib" ???. */
} fileAction;
#define XFA_SKIPPING(_a) \
((_a) == FA_SKIP || (_a) == FA_SKIPNSTATE || (_a) == FA_SKIPNETSHARED || (_a) == FA_SKIPMULTILIB)
/**
*/
typedef enum rollbackDir_e {
ROLLBACK_SAVE = 1, /*!< Save files. */
ROLLBACK_RESTORE = 2, /*!< Restore files. */
} rollbackDir;
/**
* File types.
* These are the types of files used internally by rpm. The file
* type is determined by applying stat(2) macros like S_ISDIR to
* the file mode tag from a header. The values are arbitrary,
* but are identical to the linux stat(2) file types.
*/
enum fileTypes {
PIPE = 1, /*!< pipe/fifo */
CDEV = 2, /*!< character device */
XDIR = 4, /*!< directory */
BDEV = 6, /*!< block device */
REG = 8, /*!< regular file */
LINK = 10, /*!< hard link */
SOCK = 12, /*!< socket */
};
/**
*/
typedef int (*HGE_t) (Header h, int_32 tag, /*@out@*/ int_32 * type,
/*@out@*/ void ** p, /*@out@*/int_32 * c)
/*@modifies *type, *p, *c @*/;
/**
*/
struct transactionFileInfo_s {
/* for all packages */
enum rpmTransactionType type;
/*@owned@*/ fileAction * actions; /*!< file disposition */
/*@owned@*/ struct fingerPrint_s * fps; /*!< file fingerprints */
HGE_t hge;
Header h; /*!< Package header */
/*@owned@*/ const char * name;
/*@owned@*/ const char * version;
/*@owned@*/ const char * release;
int_32 epoch;
const uint_32 * fflags; /*!< File flags (from header) */
const uint_32 * fsizes; /*!< File sizes (from header) */
/*@owned@*/ const char ** bnl; /*!< Base names (from header) */
/*@owned@*/ const char ** dnl; /*!< Directory names (from header) */
int_32 * dil; /*!< Directory indices (from header) */
/*@owned@*/ const char ** obnl; /*!< Original Base names (from header) */
/*@owned@*/ const char ** odnl; /*!< Original Directory names (from header) */
int_32 * odil; /*!< Original Directory indices (from header) */
/*@owned@*/ const char ** fmd5s;/*!< file MD5 sums (from header) */
/*@owned@*/ const char ** flinks; /*!< file links (from header) */
/* XXX setuid/setgid bits are turned off if fuser/fgroup doesn't map. */
uint_16 * fmodes; /*!< file modes (from header) */
/*@owned@*/ char * fstates; /*!< file states (from header) */
/*@owned@*/ const char ** fuser; /*!< file owner(s) */
/*@owned@*/ const char ** fgroup; /*!< file group(s) */
/*@owned@*/ const char ** flangs; /*!< file lang(s) */
int fc; /*!< No. of files. */
int dc; /*!< No. of directories. */
int bnlmax; /*!< Length (in bytes) of longest base name. */
int dnlmax; /*!< Length (in bytes) of longest dir name. */
int striplen;
int scriptArg;
unsigned int archiveSize;
/*@owned@*/ const char ** apath;
int mapflags;
/*@owned@*/ int * fmapflags;
uid_t uid;
/*@owned@*/ uid_t * fuids;
gid_t gid;
/*@owned@*/ gid_t * fgids;
int magic;
#define TFIMAGIC 0x09697923
/*@owned@*/ FSM_t fsm;
/* these are for TR_ADDED packages */
/*@dependent@*/ struct availablePackage * ap;
/*@owned@*/ struct sharedFileInfo * replaced;
/*@owned@*/ uint_32 * replacedSizes;
/* for TR_REMOVED packages */
unsigned int record;
};
#ifdef __cplusplus
extern "C" {
#endif
/**
*/
/*@only@*/ /*@null@*/ FSM_t newFSM(void);
/**
*/
/*@null@*/ FSM_t freeFSM(/*@only@*/ /*@null@*/ FSM_t fsm);
/**
* Load data from header into transaction file element info.
* @param h header
* @param fi transaction element file info
*/
void loadFi(Header h, TFI_t fi)
/*@modifies h, fi @*/;
/**
* Destroy transaction element file info.
* @param fi transaction element file info
*/
void freeFi(TFI_t fi)
/*@modifies fi @*/;
/**
* Return formatted string representation of package disposition.
* @param a package dispostion
* @return formatted string
*/
/*@observer@*/ const char *const fiTypeString(TFI_t fi);
/**
* Return formatted string representation of file stages.
* @param a file stage
* @return formatted string
*/
/*@observer@*/ const char *const fileStageString(fileStage a);
/**
* Return formatted string representation of file disposition.
* @param a file dispostion
* @return formatted string
*/
/*@observer@*/ const char *const fileActionString(fileAction a);
/**
* Perform package install/remove actions for s single file.
* @param ts transaction set
* @param fi transaction element file info
* @param i file index
* @param a file stage
* @return 0 on success, 1 on failure
*/
int pkgAction(const rpmTransactionSet ts, TFI_t fi, int i, fileStage a);
/**
* Perform package install/remove actions.
* @param ts transaction set
* @param fi transaction element file info
* @param a file stage
* @return 0 on success, otherwise no. of failures
*/
int pkgActions(const rpmTransactionSet ts, TFI_t fi, fileStage a);
/**
* @return 0 on success
*/
int fsmSetup(FSM_t fsm, const rpmTransactionSet ts, const TFI_t fi, FD_t cfd,
const char ** failedFile);
/**
* @return 0 on success
*/
int fsmTeardown(FSM_t fsm);
/**
* Archive extraction state machine.
* @param fsm file state machine data
* @param stage next stage
* @return 0 on success
*/
int fsmStage(FSM_t fsm, fileStage stage);
#ifdef __cplusplus
}
#endif
#endif /* H_ROLLBACK */
|