Blame SOURCES/0027-ras-mc-ctl-Print-useful-message-when-run-without-ras.patch

d9e469
From caa44c3946ddc900896830297c28b90ce5b9034b Mon Sep 17 00:00:00 2001
d9e469
From: Betty Dall <betty.dall@hp.com>
d9e469
Date: Wed, 19 Mar 2014 15:54:56 -0600
d9e469
Subject: [PATCH 27/32] ras-mc-ctl: Print useful message when run without rasdaemon -r
d9e469
d9e469
The utility script ras-mc-ctl requires that rasdaemon --record be run
d9e469
to create the me_event table in the SQLite database. The current behaviour
d9e469
is this:
d9e469
[root@sa1 util]# ras-mc-ctl --errors
d9e469
DBD::SQLite::db prepare failed: no such table: mc_event at
d9e469
/usr/local/sbin/ras-mc-ctl line 914.
d9e469
Can't call method "execute" on an undefined value at
d9e469
/usr/local/sbin/ras-mc-ctl line 915.
d9e469
d9e469
With this change, the user sees:
d9e469
[root@sa1 util]# ras-mc-ctl --errors
d9e469
DBD::SQLite::db prepare failed: no such table: mc_event at
d9e469
/usr/local/sbin/ras-mc-ctl line 914.
d9e469
ras-mc-ctl: Error: mc_event table missing from
d9e469
/usr/local/var/lib/rasdaemon/ras-mc_event.db. Run 'rasdaemon --record'.
d9e469
d9e469
Signed-off-by: Betty Dall <betty.dall@hp.com>
d9e469
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
d9e469
---
d9e469
 util/ras-mc-ctl.in |    4 ++++
d9e469
 1 files changed, 4 insertions(+), 0 deletions(-)
d9e469
d9e469
diff --git a/util/ras-mc-ctl.in b/util/ras-mc-ctl.in
d9e469
index 196a643..e9f9c59 100755
d9e469
--- a/util/ras-mc-ctl.in
d9e469
+++ b/util/ras-mc-ctl.in
d9e469
@@ -912,6 +912,10 @@ sub errors
d9e469
     # Memory controller mc_event errors
d9e469
     $query = "select id, timestamp, err_count, err_type, err_msg, label, mc, top_layer,middle_layer,lower_layer, address, grain, syndrome, driver_detail from mc_event order by id";
d9e469
     $query_handle = $dbh->prepare($query);
d9e469
+    if (!$query_handle) {
d9e469
+        log_error ("mc_event table missing from $dbname. Run 'rasdaemon --record'.\n");
d9e469
+        exit -1
d9e469
+    }
d9e469
     $query_handle->execute();
d9e469
     $query_handle->bind_columns(\($id, $time, $count, $type, $msg, $label, $mc, $top, $mid, $low, $addr, $grain, $syndrome, $detail));
d9e469
     $out = "";
d9e469
-- 
d9e469
1.7.1
d9e469