mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-05 16:00:05 +01:00
Allocate suitable sized buffer when reading a keyfile
If the keyfile size is explicitly given, then allocate a suitable sized buffer right from the start instead of increasing it in 4k steps. This speeds up reading larger keyfiles.
This commit is contained in:
committed by
Milan Broz
parent
596e374313
commit
e2fee206c2
@@ -412,10 +412,11 @@ int crypt_keyfile_read(struct crypt_device *cd, const char *keyfile,
|
||||
if (keyfile_size_max == 0) {
|
||||
keyfile_size_max = DEFAULT_KEYFILE_SIZE_MAXKB * 1024 + 1;
|
||||
unlimited_read = 1;
|
||||
}
|
||||
/* use 4k for buffer (page divisor but avoid huge pages) */
|
||||
buflen = 4096 - sizeof(struct safe_allocation);
|
||||
} else
|
||||
buflen = keyfile_size_max;
|
||||
|
||||
/* use 4k for buffer (page divisor but avoid huge pages) */
|
||||
buflen = 4096 - sizeof(struct safe_allocation);
|
||||
regular_file = 0;
|
||||
if (keyfile) {
|
||||
if (stat(keyfile, &st) < 0) {
|
||||
|
||||
Reference in New Issue
Block a user