Commit f3ed801e authored by Milan Broz's avatar Milan Broz

Use /dev/loop-control if possible (kernel 3.1).

git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@605 36d66b0a-2a48-0410-832c-cd162a569da5
parent 19547928
2011-08-22 Milan Broz <mbroz@redhat.com>
* Add more paranoid checks for LUKS header and keyslot attributes.
* Fix crypt_load to properly check device size.
* Use new /dev/loop-control (kernel 3.1) if possible.
2011-07-25 Milan Broz <mbroz@redhat.com>
* Remove hash/hmac restart from crypto backend and make it part of hash/hmac final.
......
......@@ -29,11 +29,7 @@
#include "utils_loop.h"
#ifndef LOOP_CTL_GET_FREE
#define LOOP_CTL_GET_FREE 0x4C82
#endif
char *crypt_loop_get_device(void)
static char *crypt_loop_get_device_old(void)
{
char dev[20];
int i, loop_fd;
......@@ -60,8 +56,6 @@ char *crypt_loop_get_device(void)
return NULL;
}
/* loop-control not yet upstream */
#if 0
char *crypt_loop_get_device(void)
{
char dev[64];
......@@ -70,7 +64,7 @@ char *crypt_loop_get_device(void)
loop_fd = open("/dev/loop-control", O_RDONLY);
if (loop_fd < 0)
return NULL;
return crypt_loop_get_device_old();
i = ioctl(loop_fd, LOOP_CTL_GET_FREE);
if (i < 0) {
......@@ -79,14 +73,14 @@ char *crypt_loop_get_device(void)
}
close(loop_fd);
snprintf(dev, "/dev/loop%d", i, sizeof(dev));
if (sprintf(dev, "/dev/loop%d", i) < 0)
return NULL;
if (stat(dev, &st) || !S_ISBLK(st.st_mode))
return NULL;
return strdup(dev);
}
#endif
int crypt_loop_attach(const char *loop, const char *file, int offset,
int autoclear, int *readonly)
......
......@@ -9,6 +9,10 @@
#define LO_FLAGS_AUTOCLEAR 4
#endif
#ifndef LOOP_CTL_GET_FREE
#define LOOP_CTL_GET_FREE 0x4C82
#endif
char *crypt_loop_get_device(void);
char *crypt_loop_backing_file(const char *loop);
int crypt_loop_device(const char *loop);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment