mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-11 19:00:02 +01:00
Add dm flags for query for features.
Move adjust device helper to utils. Fix locking memory message. git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@416 36d66b0a-2a48-0410-832c-cd162a569da5
This commit is contained in:
46
lib/setup.c
46
lib/setup.c
@@ -246,52 +246,6 @@ out:
|
||||
return r;
|
||||
}
|
||||
|
||||
static int device_check_and_adjust(struct crypt_device *cd,
|
||||
const char *device,
|
||||
int open_exclusive,
|
||||
uint64_t *size,
|
||||
uint64_t *offset,
|
||||
int *read_only)
|
||||
{
|
||||
int r, real_readonly;
|
||||
uint64_t real_size;
|
||||
|
||||
if (!device)
|
||||
return -ENOTBLK;
|
||||
|
||||
r = get_device_infos(device, open_exclusive, &real_readonly, &real_size);
|
||||
if (r < 0) {
|
||||
if (r == -EBUSY)
|
||||
log_err(cd, _("Cannot use device %s which is in use "
|
||||
"(already mapped or mounted).\n"),
|
||||
device);
|
||||
else
|
||||
log_err(cd, _("Cannot get info about device %s.\n"),
|
||||
device);
|
||||
return r;
|
||||
}
|
||||
|
||||
if (!*size) {
|
||||
*size = real_size;
|
||||
if (!*size) {
|
||||
log_err(cd, _("Device %s has zero size.\n"), device);
|
||||
return -ENOTBLK;
|
||||
}
|
||||
if (*size < *offset) {
|
||||
log_err(cd, _("Device %s is too small.\n"), device);
|
||||
return -EINVAL;
|
||||
}
|
||||
*size -= *offset;
|
||||
}
|
||||
|
||||
if (real_readonly)
|
||||
*read_only = 1;
|
||||
|
||||
log_dbg("Calculated device size is %" PRIu64 " sectors (%s), offset %" PRIu64 ".",
|
||||
*size, *read_only ? "RO" : "RW", *offset);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int luks_remove_helper(struct crypt_device *cd,
|
||||
int key_slot,
|
||||
const char *other_key_file,
|
||||
|
||||
Reference in New Issue
Block a user