mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-14 20:30:04 +01:00
Make resize action accept --device-size parameter (supports units).
Fixes #368.
This commit is contained in:
committed by
Milan Broz
parent
ecb898c7ff
commit
8b959158e3
@@ -110,9 +110,9 @@ Reports the status for the mapping <name>.
|
|||||||
.IP
|
.IP
|
||||||
Resizes an active mapping <name>.
|
Resizes an active mapping <name>.
|
||||||
|
|
||||||
If \-\-size (in 512-bytes sectors) is not specified, the size is computed
|
If \-\-size (in 512-bytes sectors) or \-\-device\-size are not specified,
|
||||||
from the underlying device. For LUKS it is the size of the
|
the size is computed from the underlying device. For LUKS it is the size
|
||||||
underlying device without the area reserved for LUKS header
|
of the underlying device without the area reserved for LUKS header
|
||||||
(see data payload offset in \fBluksDump\fR command).
|
(see data payload offset in \fBluksDump\fR command).
|
||||||
For plain crypt device, the whole device size is used.
|
For plain crypt device, the whole device size is used.
|
||||||
|
|
||||||
@@ -981,11 +981,14 @@ Hence, if \-\-offset \fIn\fR, and \-\-skip \fIs\fR, sector \fIn\fR
|
|||||||
(the first sector of the encrypted device) will get a sector number
|
(the first sector of the encrypted device) will get a sector number
|
||||||
of \fIs\fR for the IV calculation.
|
of \fIs\fR for the IV calculation.
|
||||||
.TP
|
.TP
|
||||||
.B "\-\-device-size \fIsize[units]\fR"
|
.B "\-\-device\-size \fIsize[units]\fR"
|
||||||
Instead of real device size, use specified value.
|
Instead of real device size, use specified value.
|
||||||
|
|
||||||
It means that only specified area (from the start of the device
|
With \fIreencrypt\fR action it means that only specified area
|
||||||
to the specified size) will be reencrypted.
|
(from the start of the device to the specified size) will be
|
||||||
|
reencrypted.
|
||||||
|
|
||||||
|
With \fIresize\fR action it sets new size of the device.
|
||||||
|
|
||||||
If no unit suffix is specified, the size is in bytes.
|
If no unit suffix is specified, the size is in bytes.
|
||||||
|
|
||||||
|
|||||||
@@ -659,6 +659,9 @@ static int action_resize(void)
|
|||||||
crypt_safe_free(password);
|
crypt_safe_free(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opt_device_size)
|
||||||
|
opt_size = opt_device_size / SECTOR_SIZE;
|
||||||
|
|
||||||
if (r >= 0)
|
if (r >= 0)
|
||||||
r = crypt_resize(cd, action_argv[0], opt_size);
|
r = crypt_resize(cd, action_argv[0], opt_size);
|
||||||
out:
|
out:
|
||||||
@@ -3827,6 +3830,10 @@ int main(int argc, const char **argv)
|
|||||||
usage(popt_context, EXIT_FAILURE, _("Options --reduce-device-size and --data-size cannot be combined."),
|
usage(popt_context, EXIT_FAILURE, _("Options --reduce-device-size and --data-size cannot be combined."),
|
||||||
poptGetInvocationName(popt_context));
|
poptGetInvocationName(popt_context));
|
||||||
|
|
||||||
|
if (opt_device_size && opt_size)
|
||||||
|
usage(popt_context, EXIT_FAILURE, _("Options --device-size and --size cannot be combined."),
|
||||||
|
poptGetInvocationName(popt_context));
|
||||||
|
|
||||||
r = run_action(action);
|
r = run_action(action);
|
||||||
poptFreeContext(popt_context);
|
poptFreeContext(popt_context);
|
||||||
return r;
|
return r;
|
||||||
|
|||||||
Reference in New Issue
Block a user