old_path = xasprintf("%ls\\%ls", entry->directory, entry->current_name);
err = root->Open(root, &handle, old_path, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, 0ULL);
+ if (EFI_STATUS_IS_WRITE_REFUSED(err))
+ goto read_only;
if (err != EFI_SUCCESS)
return log_error_status(err, "Error opening boot entry '%ls': %m", old_path);
if (err != EFI_SUCCESS)
return log_error_status(err, "Error getting boot entry file info: %m");
+ /* If the boot entry file is marked read-only take this as a hint that the boot counter logic shall
+ * not be applied to it, and skip it. */
+ if (FLAGS_SET(file_info->Attribute, EFI_FILE_READ_ONLY))
+ goto read_only;
+
/* And rename the file */
strcpy16(file_info->FileName, entry->next_name);
err = handle->SetInfo(handle, MAKE_GUID_PTR(EFI_FILE_INFO), file_info_size, file_info);
}
return EFI_SUCCESS;
+
+read_only:
+ log_debug("Boot entry '%ls' is read-only, skipping boot counter logic.", old_path);
+ return EFI_SUCCESS;
}
static EFI_STATUS call_image_start(const BootEntry *entry, EFI_FILE *root_dir, EFI_HANDLE parent_image);