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
|
#ifndef TPAX_H
#define TPAX_H
#include <stdint.h>
#include <stddef.h>
#include <sys/stat.h>
#include "tpax_api.h"
#include "tpax_specs.h"
#ifdef __cplusplus
extern "C" {
#endif
/* pre-alpha */
#ifndef TPAX_APP
#ifndef TPAX_PRE_ALPHA
#error libtpax: pre-alpha: ABI is not final!
#error to use the library, compile with -DTPAX_PRE_ALPHA.
#endif
#endif
/* status codes */
#define TPAX_OK 0x00
#define TPAX_USAGE 0x01
#define TPAX_ERROR 0x02
#define TPAX_FATAL 0x03
/* driver flags */
#define TPAX_DRIVER_VERBOSITY_NONE 0x0000
#define TPAX_DRIVER_VERBOSITY_ERRORS 0x0001
#define TPAX_DRIVER_VERBOSITY_STATUS 0x0002
#define TPAX_DRIVER_VERBOSITY_USAGE 0x0004
#define TPAX_DRIVER_CLONE_VECTOR 0x0008
#define TPAX_DRIVER_VERSION 0x0010
#define TPAX_DRIVER_VERBOSE 0x0020
#define TPAX_DRIVER_DRY_RUN 0x0080
#define TPAX_DRIVER_EXEC_MODE_LIST 0x0100
#define TPAX_DRIVER_EXEC_MODE_READ 0x0200
#define TPAX_DRIVER_EXEC_MODE_WRITE 0x0400
#define TPAX_DRIVER_EXEC_MODE_COPY 0x0800
#define TPAX_DRIVER_ANNOTATE_ALWAYS 0x1000
#define TPAX_DRIVER_ANNOTATE_NEVER 0x2000
#define TPAX_DRIVER_ANNOTATE_FULL 0x4000
#define TPAX_DRIVER_WRITE_FORMAT_PAX 0x10000
#define TPAX_DRIVER_WRITE_FORMAT_CPIO 0x20000
#define TPAX_DRIVER_WRITE_FORMAT_USTAR 0x40000
#define TPAX_DRIVER_WRITE_FORMAT_RUSTAR 0x80000
#define TPAX_DRIVER_DIR_MEMBER_RECURSE 0x100000
#define TPAX_DRIVER_STRICT_PATH_INPUT 0x200000
#define TPAX_DRIVER_PURE_PATH_OUTPUT 0x400000
#define TPAX_DRIVER_PRESERVE_ATIME 0x1000000
#define TPAX_DRIVER_PRESERVE_MTIME 0x2000000
#define TPAX_DRIVER_PAX_SYMLINK_ARGS 0x4000000
#define TPAX_DRIVER_PAX_SYMLINK_ITEMS 0x8000000
#define TPAX_DRIVER_STRICT_DEVICE_ID 0X10000000
/* error flags */
#define TPAX_ERROR_TOP_LEVEL 0x0001
#define TPAX_ERROR_NESTED 0x0002
#define TPAX_ERROR_CHILD 0x0004
#define TPAX_ERROR_CUSTOM 0x0008
enum tpax_custom_error {
TPAX_ERR_FLOW_ERROR,
TPAX_ERR_FLEE_ERROR,
TPAX_ERR_NULL_CONTEXT,
TPAX_ERR_BAD_DATA,
TPAX_ERR_FORBIDDEN_PATH,
TPAX_ERR_FILE_CHANGED,
TPAX_ERR_REGION_SIZE,
TPAX_ERR_CAP,
};
enum tpax_warning_level {
TPAX_WARNING_LEVEL_UNKNOWN,
TPAX_WARNING_LEVEL_ALL,
TPAX_WARNING_LEVEL_ERROR,
TPAX_WARNING_LEVEL_NONE,
};
struct tpax_source_version {
int major;
int minor;
int revision;
const char * commit;
};
struct tpax_fd_ctx {
int fdin;
int fdout;
int fderr;
int fdlog;
int fdcwd;
int fddst;
};
struct tpax_error_info {
const struct tpax_driver_ctx * edctx;
const struct tpax_unit_ctx * euctx;
const char * eunit;
int esyscode;
int elibcode;
const char * efunction;
int eline;
unsigned eflags;
void * eany;
};
struct tpax_common_ctx {
uint64_t drvflags;
uint64_t actflags;
uint64_t fmtflags;
uint32_t blksize;
};
struct tpax_driver_ctx {
const char ** units;
const char * program;
const char * module;
const char * const * file;
const struct tpax_common_ctx * cctx;
struct tpax_error_info ** errv;
const off_t * cpos;
void * any;
};
struct tpax_unit_ctx {
const char * const * path;
const char * const * link;
const struct tpax_ustar_header *uhdr;
const struct tpax_cpio_header * chdr;
const struct stat * st;
const off_t * hpos;
const off_t * dpos;
void * any;
};
/* driver api */
tpax_api int tpax_lib_get_driver_ctx (char ** argv, char ** envp, uint32_t flags,
const struct tpax_fd_ctx *,
struct tpax_driver_ctx **);
tpax_api void tpax_lib_free_driver_ctx (struct tpax_driver_ctx *);
tpax_api int tpax_lib_get_unit_ctx (const struct tpax_driver_ctx *, int, const char * path,
struct tpax_unit_ctx **);
tpax_api void tpax_lib_free_unit_ctx (struct tpax_unit_ctx *);
tpax_api int tpax_lib_get_driver_fdctx (const struct tpax_driver_ctx *, struct tpax_fd_ctx *);
tpax_api int tpax_lib_set_driver_fdctx (struct tpax_driver_ctx *, const struct tpax_fd_ctx *);
/* core api */
tpax_api int tpax_archive_enqueue (const struct tpax_driver_ctx *, const struct tpax_unit_ctx *);
tpax_api int tpax_archive_write (const struct tpax_driver_ctx *);
tpax_api int tpax_archive_reset (const struct tpax_driver_ctx *);
tpax_api int tpax_archive_seal (const struct tpax_driver_ctx *);
/* utility helper interfaces */
tpax_api int tpax_util_path_copy (char *, const char *, size_t, uint32_t, size_t *);
tpax_api int tpax_util_stat_compare (const struct stat *, const struct stat *);
/* utility api */
tpax_api int tpax_main (char **, char **,
const struct tpax_fd_ctx *);
tpax_api int tpax_output_error_vector (const struct tpax_driver_ctx *);
tpax_api int tpax_output_error_record (const struct tpax_driver_ctx *, const struct tpax_error_info *);
/* meta interfaces */
tpax_api int tpax_meta_init_ustar_header (const struct tpax_driver_ctx *, const char *, const struct stat *,
const char *, struct tpax_ustar_header *);
/* low-level interfaces */
tpax_api int tpax_io_create_memory_snapshot(const struct tpax_driver_ctx *, int, const char *,
const struct stat *, void *);
tpax_api int tpax_io_create_tmpfs_snapshot (const struct tpax_driver_ctx *, int, const char *,
const struct stat *);
/* package info */
tpax_api const struct tpax_source_version * tpax_api_source_version(void);
#ifdef __cplusplus
}
#endif
#endif
|