From: Danny Al-Gaaf Date: Sun, 27 Jan 2013 20:57:32 +0000 (+0100) Subject: rbd: don't ignore return value of system() X-Git-Tag: v0.57~98 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fb85c7f6cfe959cc63ce8bf637d852411ed102e7;p=ceph.git 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 --- diff --git a/src/rbd.cc b/src/rbd.cc index 833188ae33c1..dd56bc9309e6 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 << ")" <