int common_close(struct recording_entity *re, void *stats) { D("Closing writer"); struct common_io_info *ioi = (struct common_io_info *)re->opt; if (stats != NULL) get_io_stats(re->opt, stats); free(ioi->curfilename); free(ioi); D("COMMON_WRT: Writer closed"); return 0; }
char * format_next_io(caddr_t handle, char *(*get_userid) (uid_t)) { static char fmt[MAX_COLS]; /* static area where result is built */ static struct io_node *head = NULL; struct top_proc *p = *nextactive++; struct io_node *node = NULL; head = upsert_io_stats(head, p->pid, p->rchar, p->wchar, p->syscr, p->syscw, p->read_bytes, p->write_bytes, p->cancelled_write_bytes); if (mode_stats == STATS_DIFF) { node = get_io_stats(head, p->pid); if (node == NULL) { snprintf(fmt, sizeof(fmt), "%5d %5d %5d %7d %7d %5d %6d %7d %s", p->pid, 0, 0, 0, 0, 0, 0, 0, p->name); } else { snprintf(fmt, sizeof(fmt), "%5d %5s %5s %7lld %7lld %5s %6s %7s %s", p->pid, format_b(node->diff_rchar), format_b(node->diff_wchar), node->diff_syscr, node->diff_syscw, format_b(node->diff_read_bytes), format_b(node->diff_write_bytes), format_b(node->diff_cancelled_write_bytes), p->name); } } else { snprintf(fmt, sizeof(fmt), "%5d %5s %5s %7lld %7lld %5s %6s %7s %s", p->pid, format_b(p->rchar), format_b(p->wchar), p->syscr, p->syscw, format_b(p->read_bytes), format_b(p->write_bytes), format_b(p->cancelled_write_bytes), p->name); } return (fmt); }