#ifndef NTUX_H #define NTUX_H #include #include "ntux_api.h" #ifdef __cplusplus extern "C" { #endif /* pre-alpha */ #ifndef NTUX_APP #ifndef NTUX_PRE_ALPHA #error libntux: pre-alpha: ABI is not final! #error to use the library, please pass -DNTUX_PRE_ALPHA to the compiler. #endif #endif /* status codes */ #define NTUX_OK 0x00 #define NTUX_USAGE 0x01 #define NTUX_ERROR 0x02 /* driver flags */ #define NTUX_DRIVER_VERBOSITY_NONE 0x0000 #define NTUX_DRIVER_VERBOSITY_ERRORS 0x0001 #define NTUX_DRIVER_VERBOSITY_STATUS 0x0002 #define NTUX_DRIVER_VERBOSITY_USAGE 0x0004 #define NTUX_DRIVER_CLONE_VECTOR 0x0008 #define NTUX_DRIVER_VERSION 0x0010 #define NTUX_DRIVER_DRY_RUN 0x0020 #define NTUX_DRIVER_VERBOSE 0x0040 #define NTUX_DRIVER_SILENT 0x0080 #define NTUX_DRIVER_RECURSIVE 0x0100 #define NTUX_DRIVER_CHANGES 0x0200 #define NTUX_DRIVER_ROOTED 0x0400 #define NTUX_DRIVER_ROOTLESS 0x0800 #define NTUX_DRIVER_DUMP 0x1000 #define NTUX_DRIVER_RPATH 0X10000 #define NTUX_DRIVER_APATH 0X20000 #define NTUX_DRIVER_NPATH 0X40000 #define NTUX_DRIVER_DPATH 0X80000 #define NTUX_DRIVER_ANNOTATE_ALWAYS 0x10000000 #define NTUX_DRIVER_ANNOTATE_NEVER 0x20000000 #define NTUX_DRIVER_ANNOTATE_FULL 0x40000000 /* error flags */ #define NTUX_ERROR_TOP_LEVEL 0x0001 #define NTUX_ERROR_NESTED 0x0002 #define NTUX_ERROR_CHILD 0x0004 #define NTUX_ERROR_CUSTOM 0x0008 #define NTUX_ERROR_NATIVE 0x0010 enum ntux_custom_error { NTUX_ERR_FLOW_ERROR, NTUX_ERR_FLEE_ERROR, NTUX_ERR_LDSO_INIT, NTUX_ERR_NOT_IMPLEMENTED, NTUX_ERR_CONFLICTING_ARGUMENTS, NTUX_ERR_NON_POSIX_DESCRIPTOR, }; enum ntux_cmd { NTUX_CMD_DEFAULT, NTUX_CMD_STAT, NTUX_CMD_SPAWN, NTUX_CMD_STRACE, NTUX_CMD_CHMOD, NTUX_CMD_ACEIT, NTUX_CMD_FSPATH, NTUX_CMD_BRIDGE, NTUX_CMD_CAP, }; struct ntux_source_version { int major; int minor; int revision; const char * commit; }; struct ntux_fd_ctx { int fdin; int fdout; int fderr; int fdlog; int fdcwd; int fddst; }; struct ntux_error_info { const struct ntux_driver_ctx * edctx; const struct ntux_unit_ctx * euctx; const char * eunit; int esyscode; int elibcode; const char * efunction; int eline; unsigned eflags; void * eany; }; struct ntux_common_ctx { uint64_t drvflags; uint64_t actflags; uint64_t fmtflags; enum ntux_cmd cmd; int32_t status; char ** sargv; char ** senvp; const char * loader; const char * logfile; const char * refobj; const char * strmode; const char * owner; const char * group; const char * interp; const char * optarg; uint32_t sysmask[16]; uint32_t dbgmask[16]; uint32_t osmask [32]; }; struct ntux_driver_ctx { const char ** units; const char * program; const char * module; const struct ntux_common_ctx * cctx; struct ntux_error_info ** errv; void * any; }; struct ntux_unit_ctx { const char * const * path; void * any; }; /* driver api */ ntux_api int ntux_get_driver_ctx (char **, char **, uint32_t, const struct ntux_fd_ctx *, struct ntux_driver_ctx **); ntux_api void ntux_free_driver_ctx (struct ntux_driver_ctx *); ntux_api int ntux_get_driver_fdctx (const struct ntux_driver_ctx *, struct ntux_fd_ctx *); ntux_api int ntux_set_driver_fdctx (struct ntux_driver_ctx *, const struct ntux_fd_ctx *); /* cmd api */ ntux_api int ntux_cmd_aceit (const struct ntux_driver_ctx *, const char *); ntux_api int ntux_cmd_chmod (const struct ntux_driver_ctx *, const char *); ntux_api int ntux_cmd_fspath (const struct ntux_driver_ctx *, const char *); ntux_api int ntux_cmd_stat (const struct ntux_driver_ctx *, const char *); ntux_api int ntux_cmd_spawn (const struct ntux_driver_ctx *); ntux_api int ntux_cmd_strace (const struct ntux_driver_ctx *); ntux_api int ntux_cmd_bridge (const struct ntux_driver_ctx *); /* utility api */ ntux_api int ntux_main (char **, char **, const struct ntux_fd_ctx *); /* error trace api */ ntux_api int ntux_output_error_vector (const struct ntux_driver_ctx *); /* package info */ ntux_api const struct ntux_source_version * ntux_source_version(void); #ifdef __cplusplus } #endif #endif