[systemd-devel] [PATCH v2] cryptsetup: Implement offset and skip options

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Thu Apr 16 16:42:17 PDT 2015


On Thu, Apr 16, 2015 at 02:56:39PM -0500, Martin Pitt wrote:
> +        } else if (startswith(option, "offset=")) {
> +
> +                if (safe_atou64(option+7, &arg_offset) < 0) {
> +                        log_error("offset= parse failure, refusing.");
> +                        return -EINVAL;
> +                }
> +
> +        } else if (startswith(option, "skip=")) {
> +
> +                if (safe_atou64(option+5, &arg_skip) < 0) {
> +                        log_error("skip= parse failure, refusing.");
> +                        return -EINVAL;
> +                }
> +
>          } else if (!streq(option, "none"))
>                  log_error("Encountered unknown /etc/crypttab option '%s', ignoring.", option);
>  
> @@ -423,6 +437,9 @@ static int attach_luks_or_plain(struct crypt_device *cd,
>                           * package is to not hash when a key file is provided */
>                          params.hash = "ripemd160";
>  
> +                params.offset = arg_offset;
> +                params.skip = arg_skip;
> +
>                  if (arg_cipher) {
>                          size_t l;

Hm, I'd go even further and add a check:

if (arg_offset && arg_type != NULL && arg_type != CRYPT_PLAIN)
      log_warning("offset= ignored with type %s", arg_type);
if (arg_skip && arg_type != NULL && arg_type != CRYPT_PLAIN)
      log_warning("skip= ignored with type %s", arg_type);

But patch looks fine without this too.

Zbyszek


More information about the systemd-devel mailing list