Blame include/tpax/tpax.h

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