From fb85c7f6cfe959cc63ce8bf637d852411ed102e7 Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Sun, 27 Jan 2013 21:57:32 +0100 Subject: [PATCH] rbd: don't ignore return value of system() Check for the return value of system() and handle the error if needed Signed-off-by: Danny Al-Gaaf --- src/rbd.cc | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/src/rbd.cc b/src/rbd.cc index 833188ae33c17..dd56bc9309e6d 100644 --- a/src/rbd.cc +++ b/src/rbd.cc @@ -1428,8 +1428,16 @@ static int do_kernel_add(const char *poolname, const char *imgname, // modprobe the rbd module if /sys/bus/rbd doesn't exist struct stat sb; - if ((stat("/sys/bus/rbd", &sb) < 0) || (!S_ISDIR(sb.st_mode))) - system("/sbin/modprobe rbd"); + if ((stat("/sys/bus/rbd", &sb) < 0) || (!S_ISDIR(sb.st_mode))) { + r = system("/sbin/modprobe rbd"); + if (r) { + if (r < 0) + cerr << "rbd: error executing modprobe as shell command!" << std::endl; + else + cerr << "rbd: modprobe rbd failed! (" << r << ")" <