From 5ca29818e96a354074626f3053454fd40ac4a764 Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Sat, 12 Mar 2011 21:05:47 +0000 Subject: [PATCH] Require loop autoclear support. git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@446 36d66b0a-2a48-0410-832c-cd162a569da5 --- lib/utils_loop.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/utils_loop.c b/lib/utils_loop.c index 3a8df47..cbaef4b 100644 --- a/lib/utils_loop.c +++ b/lib/utils_loop.c @@ -83,6 +83,15 @@ int crypt_loop_attach(const char *loop, const char *file, (void)ioctl(loop_fd, LOOP_CLR_FD, 0); goto out; } + + /* Verify that autoclear is really set */ + memset(&lo64, 0, sizeof(lo64)); + if (ioctl(loop_fd, LOOP_GET_STATUS64, &lo64) < 0 || + !(lo64.lo_flags & LO_FLAGS_AUTOCLEAR)) { + (void)ioctl(loop_fd, LOOP_CLR_FD, 0); + goto out; + } + r = 0; out: if (r && loop_fd >= 0) -- 2.7.4