From 9d6cc18bf175d742950a424690f0829e86332afb Mon Sep 17 00:00:00 2001 From: Yue Hu Date: Mon, 17 Dec 2018 17:09:55 +0800 Subject: [PATCH] cryptfs: Add error messages when remove dm-crypt device is failed We do not know what happened if remove dm-crypt device is failed, so the error status added is useful to debug failed ioctl. Change-Id: I49be91b9087ef2a213a706dd6b2a07eb6dafe6e6 Signed-off-by: Yue Hu --- cryptfs.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cryptfs.cpp b/cryptfs.cpp index 28facac..d661952 100644 --- a/cryptfs.cpp +++ b/cryptfs.cpp @@ -1144,6 +1144,7 @@ static int delete_crypto_blk_dev(const char* name) { char buffer[DM_CRYPT_BUF_SIZE]; struct dm_ioctl* io; int retval = -1; + int err; if ((fd = open("/dev/device-mapper", O_RDWR | O_CLOEXEC)) < 0) { SLOGE("Cannot open device-mapper\n"); @@ -1153,8 +1154,9 @@ static int delete_crypto_blk_dev(const char* name) { io = (struct dm_ioctl*)buffer; ioctl_init(io, DM_CRYPT_BUF_SIZE, name, 0); - if (ioctl(fd, DM_DEV_REMOVE, io)) { - SLOGE("Cannot remove dm-crypt device\n"); + err = ioctl(fd, DM_DEV_REMOVE, io); + if (err) { + SLOGE("Cannot remove dm-crypt device %s: %s\n", name, strerror(errno)); goto errout; }