]> granicus.if.org Git - sysstat/commitdiff
sadf: Fix bug preventing sadf from converting an old format datafile
authorSebastien GODARD <sysstat@users.noreply.github.com>
Fri, 18 Dec 2015 08:23:22 +0000 (09:23 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Fri, 18 Dec 2015 08:23:22 +0000 (09:23 +0100)
Version 11.1.5 added a check on file_magic.header_size present in the
header of a data file.
An error message should not be displayed if this check is not successful
when sadf is used to convert the data file (sadf -c) or used to display
its header contents (sadf -H).

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

index ea3a66604a22d640d943fa98356c4cdaa27fd975..8fec32cce18a5a4e21368f9952cc457892c6266e 100644 (file)
@@ -1250,7 +1250,7 @@ void read_file_stat_bunch(struct activity *act[], int curr, int ifd, int act_nr,
  * @dfile      Name of system activity data file.
  * @ignore     Set to 1 if a true sysstat activity file but with a bad
  *             format should not yield an error message. Useful with
- *             sadf -H.
+ *             sadf -H and sadf -c.
  *
  * OUT:
  * @fd         System activity data file descriptor.
@@ -1284,8 +1284,8 @@ int sa_open_read_magic(int *fd, char *dfile, struct file_magic *file_magic,
        if ((n != FILE_MAGIC_SIZE) ||
            (file_magic->sysstat_magic != SYSSTAT_MAGIC) ||
            ((file_magic->format_magic != FORMAT_MAGIC) && !ignore) ||
-           (file_magic->header_size > MAX_FILE_HEADER_SIZE) ||
-           (file_magic->header_size < FILE_HEADER_SIZE)) {
+           ((file_magic->header_size > MAX_FILE_HEADER_SIZE) && !ignore) ||
+           ((file_magic->header_size < FILE_HEADER_SIZE) && !ignore)) {
                /* Display error message and exit */
                handle_invalid_sa_file(fd, file_magic, dfile, n);
        }
@@ -1305,7 +1305,7 @@ int sa_open_read_magic(int *fd, char *dfile, struct file_magic *file_magic,
  * @act                Array of activities.
  * @ignore     Set to 1 if a true sysstat activity file but with a bad
  *             format should not yield an error message. Useful with
- *             sadf -H.
+ *             sadf -H and sadf -c.
  *
  * OUT:
  * @ifd                System activity data file descriptor.