From cfddf05021b151fdd16830cef764bf180b273ec8 Mon Sep 17 00:00:00 2001
From: Zhikun Shan <shanzhikun@huawei.com>
Date: Wed, 7 Aug 2019 02:23:19 -0400
Subject: [PATCH] sysstat: bugfix sysstat 10.1.5 read ttyAMA first for arm64

reason:read ttyAMA first for arm64.
Signed-off-by: Zhikun Shan <shanzhikun@huawei.com>
---
 count.c    | 7 +++++--
 rd_stats.c | 7 +++++--
 rd_stats.h | 1 +
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/count.c b/count.c
index d84ae7a..56864d3 100644
--- a/count.c
+++ b/count.c
@@ -317,8 +317,11 @@ __nr_t get_serial_nr(void)
 	char line[256];
 	__nr_t sl = 0;
 
-	if ((fp = fopen(SERIAL, "r")) == NULL)
-		return 0;	/* No SERIAL file */
+	if ((fp = fopen(TTYAMA, "r")) == NULL) {
+		if ((fp = fopen(SERIAL, "r")) == NULL) {
+			return 0;      /* No SERIAL file */
+		}
+	}
 
 	while (fgets(line, sizeof(line), fp) != NULL) {
 		/*
diff --git a/rd_stats.c b/rd_stats.c
index 68e2799..8ccfec4 100644
--- a/rd_stats.c
+++ b/rd_stats.c
@@ -871,8 +871,11 @@ __nr_t read_tty_driver_serial(struct stats_serial *st_serial, __nr_t nr_alloc)
 	char *p;
 	__nr_t sl_read = 0;
 
-	if ((fp = fopen(SERIAL, "r")) == NULL)
-		return 0;
+	if ((fp = fopen(TTYAMA, "r")) == NULL) {
+		if ((fp = fopen(SERIAL, "r")) == NULL) {
+			return 0;
+		}
+	}
 
 	while (fgets(line, sizeof(line), fp) != NULL ) {
 
diff --git a/rd_stats.h b/rd_stats.h
index bc99127..599fbea 100644
--- a/rd_stats.h
+++ b/rd_stats.h
@@ -54,6 +54,7 @@
 
 /* Files */
 #define SERIAL			PRE "/proc/tty/driver/serial"
+#define TTYAMA			PRE "/proc/tty/driver/ttyAMA"
 #define FDENTRY_STATE		PRE "/proc/sys/fs/dentry-state"
 #define FFILE_NR		PRE "/proc/sys/fs/file-nr"
 #define FINODE_STATE		PRE "/proc/sys/fs/inode-state"
-- 
2.19.1

