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:
Milan Broz
2011-01-25 18:48:41 +00:00
parent af87ffbd37
commit 66bea4b3be
4 changed files with 73 additions and 55 deletions

View File

@@ -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,