|
|
88751e |
#ifndef TPAX_H
|
|
|
88751e |
#define TPAX_H
|
|
|
88751e |
|
|
|
88751e |
#include <stdint.h>
|
|
|
88751e |
#include <stddef.h>
|
|
|
88751e |
|
|
|
88751e |
#include "tpax_api.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 |
|
|
|
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,
|
|
|
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;
|
|
|
88751e |
};
|
|
|
88751e |
|
|
|
88751e |
struct tpax_driver_ctx {
|
|
|
88751e |
const char ** units;
|
|
|
88751e |
const char * program;
|
|
|
88751e |
const char * module;
|
|
|
88751e |
const struct tpax_common_ctx * cctx;
|
|
|
88751e |
struct tpax_error_info ** errv;
|
|
|
88751e |
void * any;
|
|
|
88751e |
};
|
|
|
88751e |
|
|
|
88751e |
struct tpax_unit_ctx {
|
|
|
88751e |
const char * const * path;
|
|
|
88751e |
void * any;
|
|
|
88751e |
};
|
|
|
88751e |
|
|
|
88751e |
/* driver api */
|
|
|
88751e |
tpax_api int tpax_get_driver_ctx (char ** argv, char ** envp, uint32_t flags,
|
|
|
88751e |
const struct tpax_fd_ctx *,
|
|
|
88751e |
struct tpax_driver_ctx **);
|
|
|
88751e |
|
|
|
88751e |
tpax_api void tpax_free_driver_ctx (struct tpax_driver_ctx *);
|
|
|
88751e |
|
|
|
88751e |
tpax_api int tpax_get_unit_ctx (const struct tpax_driver_ctx *, const char * path,
|
|
|
88751e |
struct tpax_unit_ctx **);
|
|
|
88751e |
|
|
|
88751e |
tpax_api void tpax_free_unit_ctx (struct tpax_unit_ctx *);
|
|
|
88751e |
|
|
|
88751e |
tpax_api int tpax_get_driver_fdctx (const struct tpax_driver_ctx *, struct tpax_fd_ctx *);
|
|
|
88751e |
tpax_api int tpax_set_driver_fdctx (struct tpax_driver_ctx *, const struct tpax_fd_ctx *);
|
|
|
88751e |
|
|
|
88751e |
/* core api */
|
|
|
88751e |
|
|
|
88751e |
/* helper api */
|
|
|
88751e |
|
|
|
88751e |
/* utility api */
|
|
|
88751e |
tpax_api int tpax_main (char **, char **,
|
|
|
88751e |
const struct tpax_fd_ctx *);
|
|
|
88751e |
/* error trace api */
|
|
|
88751e |
tpax_api int tpax_output_error_record (const struct tpax_driver_ctx *, const struct tpax_error_info *);
|
|
|
88751e |
tpax_api int tpax_output_error_vector (const struct tpax_driver_ctx *);
|
|
|
88751e |
|
|
|
88751e |
/* package info */
|
|
|
88751e |
tpax_api const struct tpax_source_version * tpax_source_version(void);
|
|
|
88751e |
|
|
|
88751e |
#ifdef __cplusplus
|
|
|
88751e |
}
|
|
|
88751e |
#endif
|
|
|
88751e |
|
|
|
88751e |
#endif
|