static xapi xmain_jump() { enter; fatal(xmain); finally: if(XAPI_UNWINDING) { #if DEBUG || DEVEL || XAPI xapi_infos("name", "fab"); xapi_infof("pgid", "%ld", (long)getpgid(0)); xapi_infof("pid", "%ld", (long)getpid()); xapi_infof("tid", "%ld", (long)gettid()); fatal(logger_trace_full, L_ERROR, XAPI_TRACE_COLORIZE); #else fatal(logger_trace_pithy, L_ERROR, XAPI_TRACE_COLORIZE); #endif xmain_exit = XAPI_ERRVAL; xapi_calltree_unwind(); } coda; }
static xapi rmdirp_fn(const char * fpath, const struct stat * sb, int typeflag, struct FTW * ftwbuf, void * arg) { enter; struct context * ctx = arg; if(typeflag == FTW_F || typeflag == FTW_SL) { fatal(xunlinks, fpath); } else if(typeflag == FTW_DP) { if(ftwbuf->level > 0 || ctx->rmself) { fatal(xrmdir, fpath); } } else { // WTF } finally: xapi_infos("path", fpath); coda; };
static xapi zeta() { enter; fail(TEST_ERROR_ONE); finally: xapi_infos("foo", "42"); fatal(lambda); coda; }
/// inotify_add_watch // // SUMMARY // proxy for inotify_add_watch // API xapi xinotify_add_watch(int * wd, int id, const char *path, uint32_t mask) { enter; int rv; if((rv = inotify_add_watch(id, path, mask)) < 0) tfail(perrtab_KERNEL, errno); *wd = rv; finally: xapi_infos("path", path); xapi_infof("id", "%d", id); coda; }
API xapi xreadlinks(const char * pathname, char * buf, size_t bufsiz, ssize_t * r) { enter; ssize_t lr; if(!r) r = &lr; if((*r = readlink(pathname, buf, bufsiz)) == -1) tfail(perrtab_KERNEL, errno); finally: xapi_infos("pathname", pathname); coda; }
/// test_masking // // SUMMARY // verify that infos from lower frames mask infos in higher frames with the same key // static xapi test_masking() { enter; #if XAPI_STACKTRACE char space[4096]; size_t z; #endif fatal(epsilon); finally: #if XAPI_STACKTRACE xapi_infos("foo", "87"); z = xapi_trace_pithy(space, sizeof(space)); assertf(strstr(space, "foo=42"), "expected foo=42, actual trace\n**\n%.*s\n**\n", (int)z, space); assertf(!strstr(space, "foo=87"), "expected !foo=87, actual trace\n**\n%.*s\n**\n", (int)z, space); #endif coda; }
int main(int argc, char** argv, char ** envp) { enter; xapi R = 0; char space[512]; char * fabw_path = 0; const command * cmd = 0; memblk * mb = 0; fab_client * client = 0; fab_request * request = 0; int fd = -1; size_t tracesz = 0; // libraries fatal(fab_load); fatal(logger_load); fatal(valyria_load); fatal(narrator_load); fatal(xlinux_load); xapi_errtab_register(perrtab_MAIN); // logging fatal(logging_setup); fatal(logger_arguments_setup, envp); fatal(logger_finalize); // modules fatal(params_setup); fatal(params_report); fatal(sigbank_setup, "fab"); // parse cmdline arguments fatal(args_parse, &cmd); fatal(args_report, cmd); // ensure fabd can write to my stdout/stderr fatal(xfchmod, 1, 0777); fatal(xfchmod, 2, 0777); #if DEVEL snprintf(space, sizeof(space), "%s/../fabw/fabw.devel", g_params.exedir); fabw_path = space; #endif fatal(fab_client_create, &client, ".", XQUOTE(FABIPCDIR), fabw_path); #if DEBUG || DEVEL logs(L_IPC, "started"); #endif #if 0 // possibly kill the existing fabd instance, if any if(changed credentials) fatal(client_terminate); #endif fatal(fab_client_prepare, client); fatal(fab_client_launchp, client); fatal(memblk_mk, &mb); fatal(args_collate, cmd, mb, &request); fatal(fab_client_make_request, client, mb, request); finally: #if DEBUG || DEVEL if(log_would(L_IPC)) { xapi_infos("name", "fab"); xapi_infof("pid", "%ld", (long)getpid()); if(client) xapi_infos("hash", fab_client_gethash(client)); } #endif if(XAPI_UNWINDING) { if(XAPI_ERRVAL == FAB_FABDEXIT || XAPI_ERRVAL == FAB_UNSUCCESS) { // on orderly shutdown fabd has already backtraced to our stdout } else { #if DEBUG || DEVEL || XAPI tracesz = xapi_trace_full(space, sizeof(space)); #else tracesz = xapi_trace_pithy(space, sizeof(space)); #endif xlogw(L_ERROR, L_RED, space, tracesz); } if(XAPI_ERRVAL == MAIN_BADARGS) { fatal(args_usage, cmd, 0, 0); } } // locals fatal(ixclose, &fd); fatal(fab_client_dispose, &client); memblk_free(mb); // module teardown sigbank_teardown(); params_teardown(); fatal(build_command_cleanup); // libraries fatal(fab_unload); fatal(logger_unload); fatal(valyria_unload); fatal(narrator_unload); fatal(xlinux_unload); conclude(&R); xapi_teardown(); return !!R; }