From: Masatake YAMATO Date: Tue, 28 Sep 2021 12:57:31 +0000 (+0900) Subject: lsfd: collect threads level information if TID is specified in a filter X-Git-Tag: v2.38-rc1~144^2~77 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7b36646951dc927204065f533ea352fe6dedc546;p=thirdparty%2Futil-linux.git lsfd: collect threads level information if TID is specified in a filter Signed-off-by: Masatake YAMATO --- diff --git a/misc-utils/lsfd.c b/misc-utils/lsfd.c index 8da659fbc3..3e5d65f52b 100644 --- a/misc-utils/lsfd.c +++ b/misc-utils/lsfd.c @@ -233,7 +233,7 @@ static struct libscols_column *add_column(struct libscols_table *tb, const struc return cl; } -static struct libscols_column *add_column_by_id_cb(struct libscols_table *tb, int colid, void *data __attribute__((__unused__))) +static struct libscols_column *add_column_by_id_cb(struct libscols_table *tb, int colid, void *data) { if (ncolumns >= ARRAY_SIZE(columns)) errx(EXIT_FAILURE, _("too many columns are added via filter expression")); @@ -244,6 +244,12 @@ static struct libscols_column *add_column_by_id_cb(struct libscols_table *tb, in if (!cl) err(EXIT_FAILURE, _("failed to allocate output column")); columns[ncolumns++] = colid; + + if (colid == COL_TID) { + struct lsfd_control *ctl = data; + ctl->threads = 1; + } + return cl; } @@ -1137,7 +1143,7 @@ int main(int argc, char *argv[]) ctl.filter = lsfd_filter_new(filter_expr, ctl.tb, LSFD_N_COLS, column_name_to_id_cb, - add_column_by_id_cb, NULL); + add_column_by_id_cb, &ctl); const char *errmsg = lsfd_filter_get_errmsg(ctl.filter); if (errmsg) errx(EXIT_FAILURE, "%s", errmsg);