+ l = strstrip(line);
+ if (*l == '#' || *l == 0)
+ continue;
+
+ k = sscanf(l, "%ms %ms %ms %ms", &name, &device, &password, &options);
+ if (k < 2 || k > 4) {
+ log_error("Failed to parse /etc/crypttab:%u, ignoring.", n);
+ continue;
+ }
+
+ /*
+ If options are specified on the kernel commandline, let them override
+ the ones from crypttab.
+ */
+ STRV_FOREACH(i, arg_options) {
+ _cleanup_free_ char *proc_uuid = NULL, *proc_options = NULL;
+ const char *p = *i;
+
+ k = sscanf(p, "%m[0-9a-fA-F-]=%ms", &proc_uuid, &proc_options);
+ if (k == 2 && streq(proc_uuid, device + 5)) {
+ free(options);
+ options = strdup(p);
+ if (!proc_options) {
+ log_oom();
+ goto cleanup;
+ }
+ }
+ }
+
+ if (arg_disks) {
+ /*
+ If luks UUIDs are specified on the kernel command line, use them as a filter
+ for /etc/crypttab and only generate units for those.
+ */
+ STRV_FOREACH(i, arg_disks) {
+ _cleanup_free_ char *proc_device = NULL, *proc_name = NULL;
+ const char *p = *i;
+
+ if (startswith(p, "luks-"))
+ p += 5;
+
+ proc_name = strappend("luks-", p);
+ proc_device = strappend("UUID=", p);
+
+ if (!proc_name || !proc_device) {
+ log_oom();
+ goto cleanup;
+ }
+
+ if (streq(proc_device, device) || streq(proc_name, name)) {
+ if (create_disk(name, device, password, options) < 0)
+ goto cleanup;
+
+ if (strv_extend(&disks_done, p) < 0) {
+ log_oom();
+ goto cleanup;
+ }
+ }
+ }
+ } else if (create_disk(name, device, password, options) < 0)
+ goto cleanup;
+
+ }