static void print_nodes(const char *be_name, boolean_t dsets, boolean_t snaps, boolean_t parsable, be_node_list_t *be_nodes) { struct hdr_info hdr; enum be_fmt be_fmt = BE_FMT_DEFAULT; if (dsets) be_fmt |= BE_FMT_DATASET; if (snaps) be_fmt |= BE_FMT_SNAPSHOT; if (!parsable) { init_hdr_cols(be_fmt, &hdr); count_widths(be_fmt, &hdr, be_nodes); print_hdr(&hdr); } if (be_fmt == BE_FMT_DEFAULT) print_be_nodes(be_name, parsable, &hdr, be_nodes); else print_fmt_nodes(be_name, be_fmt, parsable, &hdr, be_nodes); }
static void print_fmt_nodes(const char *be_name, enum be_fmt be_fmt, boolean_t parsable, be_node_list_t *nodes) { char buf[64]; char datetime[DT_BUF_LEN]; struct hdr_info *hdr = NULL; be_node_list_t *cur_be; hdr = hdrs + be_fmt; init_hdr_cols(be_fmt, hdr); count_widths(be_fmt, hdr, nodes); if (!parsable) print_hdr(hdr); for (cur_be = nodes; cur_be != NULL; cur_be = cur_be->be_next_node) { char active[3] = "-\0"; int ai = 0; const char *datetime_fmt = "%F %R"; const char *name = cur_be->be_node_name; const char *mntpt = cur_be->be_mntpt; uint64_t used = cur_be->be_space_used; time_t creation = cur_be->be_node_creation; struct tm *tm; if (be_name != NULL && strcmp(be_name, name) != 0) continue; if (!parsable) (void) printf("%-s\n", name); else active[0] = '\0'; tm = localtime(&creation); (void) strftime(datetime, DT_BUF_LEN, datetime_fmt, tm); if (cur_be->be_active) active[ai++] = 'N'; if (cur_be->be_active_on_boot) active[ai] = 'R'; nicenum(used, buf, sizeof (buf)); if (be_fmt & BE_FMT_DATASET) if (parsable) (void) printf("%s;%s;%s;%s;%llu;%s;%ld\n", cur_be->be_node_name, cur_be->be_root_ds, active, (cur_be->be_mounted ? mntpt: ""), used, cur_be->be_policy_type, creation); else (void) printf(" %-*s %-*s %-*s %-*s %-*s " "%-*s\n", hdr->cols[0].width-3, cur_be->be_root_ds, hdr->cols[1].width, active, hdr->cols[2].width, (cur_be->be_mounted ? mntpt: "-"), hdr->cols[3].width, buf, hdr->cols[4].width, cur_be->be_policy_type, hdr->cols[5].width, datetime); if (be_fmt & BE_FMT_SNAPSHOT) print_be_snapshots(cur_be, hdr, parsable); } }