bootctl: split-out entry token related definitions into boot-entry.[ch]

No functional change, just preparation for later commits.
These can be used in kernel-install later.

Note, unlike the our usual coding style, the arguments for
boot_entry_token_ensure() and parse_boot_entry_token_type() are
referenced, updated, and may freed, hence, always pass initialized
values. That's why they are not named as 'ret_xyz'.
This commit is contained in:
Yu Watanabe
2023-03-27 09:51:18 +02:00
committed by Zbigniew Jędrzejewski-Szmek
parent 600362aa11
commit 9e43296fd2
7 changed files with 267 additions and 125 deletions
+25
View File
@@ -0,0 +1,25 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <stdbool.h>
#include "sd-id128.h"
typedef enum BootEntryTokenType {
BOOT_ENTRY_TOKEN_MACHINE_ID,
BOOT_ENTRY_TOKEN_OS_IMAGE_ID,
BOOT_ENTRY_TOKEN_OS_ID,
BOOT_ENTRY_TOKEN_LITERAL,
BOOT_ENTRY_TOKEN_AUTO,
} BootEntryTokenType;
bool boot_entry_token_valid(const char *p);
int boot_entry_token_ensure(
const char *root,
const char *etc_kernel, /* will be prefixed with root, typically /etc/kernel. */
sd_id128_t machine_id,
BootEntryTokenType *type, /* input and output */
char **token); /* output, but do not pass uninitialized value. */
int parse_boot_entry_token_type(const char *s, BootEntryTokenType *type, char **token);