If device is not rotational, do not use Gutmann wipe method.

git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@615 36d66b0a-2a48-0410-832c-cd162a569da5
This commit is contained in:
Milan Broz
2011-10-08 16:17:08 +00:00
parent 61bec51be0
commit d2fbc963ca
8 changed files with 221 additions and 103 deletions

View File

@@ -475,41 +475,6 @@ int device_check_and_adjust(struct crypt_device *cd,
return 0;
}
int wipe_device_header(const char *device, int sectors)
{
struct stat st;
char *buffer;
int size = sectors * SECTOR_SIZE;
int r = -1;
int devfd;
int flags = O_RDWR | O_DIRECT | O_SYNC;
if (stat(device, &st) < 0)
return -EINVAL;
/* never wipe header on mounted device */
if (S_ISBLK(st.st_mode))
flags |= O_EXCL;
devfd = open(device, flags);
if(devfd == -1)
return errno == EBUSY ? -EBUSY : -EINVAL;
buffer = malloc(size);
if (!buffer) {
close(devfd);
return -ENOMEM;
}
memset(buffer, 0, size);
r = write_blockwise(devfd, buffer, size) < size ? -EIO : 0;
free(buffer);
close(devfd);
return r;
}
/* MEMLOCK */
#define DEFAULT_PROCESS_PRIORITY -18