static void lsmod_request_cb (flux_t *h, flux_msg_handler_t *mh, const flux_msg_t *msg, void *arg) { json_t *mods = NULL; if (flux_request_decode (msg, NULL, NULL) < 0) goto error; mods = module_list (); if (flux_respond_pack (h, msg, "{s:O}", "mods", mods) < 0) flux_log_error (h, "%s: flux_respond", __FUNCTION__); json_decref (mods); return; error: if (flux_respond_error (h, msg, errno, NULL) < 0) flux_log_error (h, "%s: flux_respond_error", __FUNCTION__); }
/* return size of dump file */ static off_t dump(const char *s) { /* Build the big list */ at *ans = NIL, **where = &ans; /* 1 - the modules */ at *p = module_list(); at *q = p; while (CONSP(q)) { *where = new_cons(Car(q), NIL); where = &Cdr(*where); q = Cdr(q); } /* 2- the globals */ *where = global_defs(); /* Header */ at *atf = OPEN_WRITE(s,"dump"); FILE *f = Gptr(atf); write32(f, DUMPMAGIC); write32(f, DUMPVERSION); /* The macro character map */ errno = 0; fwrite(char_map,1,256,f); test_file_error(f, errno); /* Write the big list */ bool oldready = error_doc.ready_to_an_error; error_doc.ready_to_an_error = false; bwrite(ans, f, true); error_doc.ready_to_an_error = oldready; lush_delete(atf); /* close file */ /* get file size */ struct stat buf; if (stat(s, &buf)>=0) if (S_ISREG(buf.st_mode)) return buf.st_size; return (off_t)0; }