From: Sage Weil Date: Mon, 1 Jul 2019 22:25:32 +0000 (-0500) Subject: common/blkdev: fix smartctl output in error path X-Git-Tag: v15.1.0~2266^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9accb70e228eed6bdd9f82d64476f0b776cee30b;p=ceph.git common/blkdev: fix smartctl output in error path Signed-off-by: Sage Weil --- diff --git a/src/common/blkdev.cc b/src/common/blkdev.cc index 4ecd1d8d3f48..789e7e087c23 100644 --- a/src/common/blkdev.cc +++ b/src/common/blkdev.cc @@ -727,10 +727,11 @@ int block_device_get_metrics(const string& devname, int timeout, // smartctl if (int r = block_device_run_smartctl(devname, timeout, &s); r != 0) { + string orig = s; s = "{\"error\": \"smartctl failed\", \"dev\": \"/dev/"; s += devname; s += "\", \"smartctl_error_code\": " + stringify(r); - s += "\", \"smartctl_output\": \"" + s; + s += "\", \"smartctl_output\": \"" + escape_quotes(orig); s += + "\"}"; } else if (!json_spirit::read(s, *result)) { string orig = s;