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 <zbestahu@gmail.com>
This commit is contained in:
Yue Hu 2018-12-17 17:09:55 +08:00
parent 2374693556
commit 9d6cc18bf1

View file

@ -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;
}