]> granicus.if.org Git - sysstat/commitdiff
sadf: Add new flag FO_ITEM_LIST
authorSebastien GODARD <sysstat@users.noreply.github.com>
Fri, 12 Apr 2019 16:29:50 +0000 (18:29 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Fri, 12 Apr 2019 16:29:50 +0000 (18:29 +0200)
This flag indicates that the linked list containing items names should
be created.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
format.c
sadf.c
sadf.h

index 7d6987acabab4f105c25bc28d30814b0dcf70dd4..64c578a585882e308699beda0949c1eebd140c75 100644 (file)
--- a/format.c
+++ b/format.c
@@ -155,7 +155,8 @@ struct report_format raw_fmt = {
  */
 struct report_format pcp_fmt = {
        .id             = F_PCP_OUTPUT,
-       .options        = FO_HEADER_ONLY + FO_LOCAL_TIME + FO_NO_TRUE_TIME,
+       .options        = FO_HEADER_ONLY + FO_LOCAL_TIME + FO_NO_TRUE_TIME +
+                         FO_ITEM_LIST,
        .f_header       = print_pcp_header,
        .f_statistics   = print_pcp_statistics,
        .f_timestamp    = print_pcp_timestamp,
diff --git a/sadf.c b/sadf.c
index 8e7100ef430406a77ca20a8973bd3c92fe722405..e19cb85f8d84179c9f3462a2b5dc9992e4a0f061 100644 (file)
--- a/sadf.c
+++ b/sadf.c
@@ -1025,9 +1025,11 @@ void logic1_display_loop(int ifd, char *file, struct file_activity *file_actlst,
        long cnt = 1;
        char *pcparchive = (char *) dparm;
 
-       /* Count items in file. Needed only for PCP output */
-       if (format == F_PCP_OUTPUT) {
-               count_file_items(ifd, file, file_magic, file_actlst, rectime, loctime);
+       if (CREATE_ITEM_LIST(fmt[f_position]->options)) {
+               /* Count items in file (e.g. for PCP output) */
+               if (!count_file_items(ifd, file, file_magic, file_actlst, rectime, loctime))
+                       /* No record to display */
+                       return;
        }
 
        /* Save current file position */
diff --git a/sadf.h b/sadf.h
index e93dd530951c5f7c3e3841b58207c988be8a74ac..7e96abdd1d852c6f72678ddfe602c73c74cec70a 100644 (file)
--- a/sadf.h
+++ b/sadf.h
  */
 #define FO_NO_TRUE_TIME                0x100
 
+/*
+ * Indicate that the number of different items should be counted and
+ * a list created (see @item_list and @item_list_sz in struct activity).
+ */
+#define FO_ITEM_LIST           0x200
+
 #define SET_LC_NUMERIC_C(m)            (((m) & FO_LC_NUMERIC_C)        == FO_LC_NUMERIC_C)
 #define ACCEPT_HEADER_ONLY(m)          (((m) & FO_HEADER_ONLY)         == FO_HEADER_ONLY)
 #define ACCEPT_BAD_FILE_FORMAT(m)      (((m) & FO_BAD_FILE_FORMAT)     == FO_BAD_FILE_FORMAT)
 #define DISPLAY_FIELD_LIST(m)          (((m) & FO_FIELD_LIST)          == FO_FIELD_LIST)
 #define TEST_MARKUP(m)                 (((m) & FO_TEST_MARKUP)         == FO_TEST_MARKUP)
 #define REJECT_TRUE_TIME(m)            (((m) & FO_NO_TRUE_TIME)        == FO_NO_TRUE_TIME)
+#define CREATE_ITEM_LIST(m)            (((m) & FO_ITEM_LIST)           == FO_ITEM_LIST)
 
 
 /*