|
|
26e14f |
#ifndef NTUX_H
|
|
|
26e14f |
#define NTUX_H
|
|
|
26e14f |
|
|
|
26e14f |
#include <stdint.h>
|
|
|
26e14f |
|
|
|
26e14f |
#include "ntux_api.h"
|
|
|
26e14f |
|
|
|
26e14f |
#ifdef __cplusplus
|
|
|
26e14f |
extern "C" {
|
|
|
26e14f |
#endif
|
|
|
26e14f |
|
|
|
26e14f |
/* pre-alpha */
|
|
|
26e14f |
#ifndef NTUX_APP
|
|
|
26e14f |
#ifndef NTUX_PRE_ALPHA
|
|
|
26e14f |
#error libntux: pre-alpha: ABI is not final!
|
|
|
26e14f |
#error to use the library, please pass -DNTUX_PRE_ALPHA to the compiler.
|
|
|
26e14f |
#endif
|
|
|
26e14f |
#endif
|
|
|
26e14f |
|
|
|
26e14f |
/* status codes */
|
|
|
26e14f |
#define NTUX_OK 0x00
|
|
|
26e14f |
#define NTUX_USAGE 0x01
|
|
|
26e14f |
#define NTUX_ERROR 0x02
|
|
|
26e14f |
|
|
|
26e14f |
/* driver flags */
|
|
|
26e14f |
#define NTUX_DRIVER_VERBOSITY_NONE 0x0000
|
|
|
26e14f |
#define NTUX_DRIVER_VERBOSITY_ERRORS 0x0001
|
|
|
26e14f |
#define NTUX_DRIVER_VERBOSITY_STATUS 0x0002
|
|
|
26e14f |
#define NTUX_DRIVER_VERBOSITY_USAGE 0x0004
|
|
|
26e14f |
#define NTUX_DRIVER_CLONE_VECTOR 0x0008
|
|
|
26e14f |
|
|
|
26e14f |
#define NTUX_DRIVER_VERSION 0x0010
|
|
|
26e14f |
#define NTUX_DRIVER_DRY_RUN 0x0020
|
|
|
80f43a |
#define NTUX_DRIVER_VERBOSE 0x0040
|
|
|
80f43a |
#define NTUX_DRIVER_SILENT 0x0080
|
|
|
80f43a |
|
|
|
80f43a |
#define NTUX_DRIVER_RECURSIVE 0x0100
|
|
|
80f43a |
#define NTUX_DRIVER_CHANGES 0x0200
|
|
|
80f43a |
#define NTUX_DRIVER_ROOTED 0x0400
|
|
|
80f43a |
#define NTUX_DRIVER_ROOTLESS 0x0800
|
|
|
26e14f |
|
|
|
da20d8 |
#define NTUX_DRIVER_ANNOTATE_ALWAYS 0x10000000
|
|
|
da20d8 |
#define NTUX_DRIVER_ANNOTATE_NEVER 0x20000000
|
|
|
da20d8 |
#define NTUX_DRIVER_ANNOTATE_FULL 0x40000000
|
|
|
da20d8 |
|
|
|
da20d8 |
/* error flags */
|
|
|
da20d8 |
#define NTUX_ERROR_TOP_LEVEL 0x0001
|
|
|
da20d8 |
#define NTUX_ERROR_NESTED 0x0002
|
|
|
da20d8 |
#define NTUX_ERROR_CHILD 0x0004
|
|
|
da20d8 |
#define NTUX_ERROR_CUSTOM 0x0008
|
|
|
da20d8 |
#define NTUX_ERROR_NATIVE 0x0010
|
|
|
da20d8 |
|
|
|
da20d8 |
enum ntux_custom_error {
|
|
|
da20d8 |
NTUX_ERR_FLOW_ERROR,
|
|
|
da20d8 |
NTUX_ERR_FLEE_ERROR,
|
|
|
da20d8 |
NTUX_ERR_LDSO_INIT,
|
|
|
162c96 |
NTUX_ERR_NOT_IMPLEMENTED,
|
|
|
da20d8 |
};
|
|
|
da20d8 |
|
|
|
6a7c02 |
enum ntux_cmd {
|
|
|
6a7c02 |
NTUX_CMD_DEFAULT,
|
|
|
6a7c02 |
NTUX_CMD_STAT,
|
|
|
7deda5 |
NTUX_CMD_SPAWN,
|
|
|
7deda5 |
NTUX_CMD_STRACE,
|
|
|
80f43a |
NTUX_CMD_CHMOD,
|
|
|
c27a50 |
NTUX_CMD_CAP,
|
|
|
6a7c02 |
};
|
|
|
6a7c02 |
|
|
|
26e14f |
struct ntux_source_version {
|
|
|
26e14f |
int major;
|
|
|
26e14f |
int minor;
|
|
|
26e14f |
int revision;
|
|
|
26e14f |
const char * commit;
|
|
|
26e14f |
};
|
|
|
26e14f |
|
|
|
ec0005 |
struct ntux_fd_ctx {
|
|
|
ec0005 |
int fdin;
|
|
|
ec0005 |
int fdout;
|
|
|
ec0005 |
int fderr;
|
|
|
ec0005 |
int fdlog;
|
|
|
ec0005 |
int fdcwd;
|
|
|
ec0005 |
int fddst;
|
|
|
ec0005 |
};
|
|
|
ec0005 |
|
|
|
26e14f |
struct ntux_error_info {
|
|
|
26e14f |
const struct ntux_driver_ctx * edctx;
|
|
|
26e14f |
const struct ntux_unit_ctx * euctx;
|
|
|
26e14f |
const char * eunit;
|
|
|
26e14f |
int esyscode;
|
|
|
26e14f |
int elibcode;
|
|
|
26e14f |
const char * efunction;
|
|
|
26e14f |
int eline;
|
|
|
26e14f |
unsigned eflags;
|
|
|
26e14f |
void * eany;
|
|
|
26e14f |
};
|
|
|
26e14f |
|
|
|
26e14f |
struct ntux_common_ctx {
|
|
|
26e14f |
uint64_t drvflags;
|
|
|
26e14f |
uint64_t actflags;
|
|
|
26e14f |
uint64_t fmtflags;
|
|
|
6a7c02 |
enum ntux_cmd cmd;
|
|
|
74fb0c |
int32_t status;
|
|
|
7deda5 |
char ** sargv;
|
|
|
7deda5 |
char ** senvp;
|
|
|
9682ca |
const char * loader;
|
|
|
9682ca |
const char * logfile;
|
|
|
80f43a |
const char * refmode;
|
|
|
80f43a |
const char * strmode;
|
|
|
de8f1c |
const char * owner;
|
|
|
de8f1c |
const char * group;
|
|
|
9682ca |
uint32_t sysmask[16];
|
|
|
9682ca |
uint32_t dbgmask[16];
|
|
|
9682ca |
uint32_t osmask [32];
|
|
|
26e14f |
};
|
|
|
26e14f |
|
|
|
26e14f |
struct ntux_driver_ctx {
|
|
|
26e14f |
const char ** units;
|
|
|
26e14f |
const char * program;
|
|
|
26e14f |
const char * module;
|
|
|
26e14f |
const struct ntux_common_ctx * cctx;
|
|
|
26e14f |
struct ntux_error_info ** errv;
|
|
|
26e14f |
void * any;
|
|
|
26e14f |
};
|
|
|
26e14f |
|
|
|
da20d8 |
struct ntux_unit_ctx {
|
|
|
da20d8 |
const char * const * path;
|
|
|
da20d8 |
void * any;
|
|
|
da20d8 |
};
|
|
|
da20d8 |
|
|
|
26e14f |
/* driver api */
|
|
|
30077e |
ntux_api int ntux_get_driver_ctx (char **, char **, uint32_t,
|
|
|
ec0005 |
const struct ntux_fd_ctx *,
|
|
|
30077e |
struct ntux_driver_ctx **);
|
|
|
30077e |
|
|
|
30077e |
ntux_api void ntux_free_driver_ctx (struct ntux_driver_ctx *);
|
|
|
26e14f |
|
|
|
ec0005 |
ntux_api int ntux_get_driver_fdctx (const struct ntux_driver_ctx *, struct ntux_fd_ctx *);
|
|
|
ec0005 |
ntux_api int ntux_set_driver_fdctx (struct ntux_driver_ctx *, const struct ntux_fd_ctx *);
|
|
|
ec0005 |
|
|
|
f3d5e0 |
/* cmd api */
|
|
|
80f43a |
ntux_api int ntux_cmd_chmod (const struct ntux_driver_ctx *, const char *);
|
|
|
30077e |
ntux_api int ntux_cmd_stat (const struct ntux_driver_ctx *, const char *);
|
|
|
30077e |
ntux_api int ntux_cmd_spawn (const struct ntux_driver_ctx *);
|
|
|
30077e |
ntux_api int ntux_cmd_strace (const struct ntux_driver_ctx *);
|
|
|
f3d5e0 |
|
|
|
26e14f |
/* utility api */
|
|
|
1cf502 |
ntux_api int ntux_main (char **, char **, const struct ntux_fd_ctx *);
|
|
|
30077e |
|
|
|
30077e |
/* error trace api */
|
|
|
da20d8 |
ntux_api int ntux_output_error_vector (const struct ntux_driver_ctx *);
|
|
|
26e14f |
|
|
|
30077e |
/* package info */
|
|
|
30077e |
ntux_api const struct ntux_source_version * ntux_source_version(void);
|
|
|
30077e |
|
|
|
26e14f |
#ifdef __cplusplus
|
|
|
26e14f |
}
|
|
|
26e14f |
#endif
|
|
|
26e14f |
|
|
|
26e14f |
#endif
|