--- util-linux-ng-2.13-rc3/mount/lomount.c.CHANGE-FD 2007-08-25 14:17:48.000000000 +0200 +++ util-linux-ng-2.13-rc3/mount/lomount.c 2007-08-25 14:30:07.000000000 +0200 @@ -1034,6 +1034,10 @@ close_fd_ffd_return1: } if (ioctl(fd, LOOP_SET_FD, ffd) < 0) { + int saved_errno = errno; +#define LOOP_CHANGE_FD 0x4C06 + if (ioctl (fd, LOOP_CHANGE_FD, ffd) < 0) { + errno = saved_errno; memset(loopinfo.lo_encrypt_key, 0, sizeof(loopinfo.lo_encrypt_key)); memset(&multiKeyBits[0][0], 0, sizeof(multiKeyBits)); close (fd); @@ -1046,6 +1050,10 @@ close_fd_ffd_return1: perror("ioctl: LOOP_SET_FD"); return 1; } + } + close (ffd); + close (fd); + return 0; } /* type 18 == LO_CRYPT_CRYPTOAPI */