]> git.proxmox.com Git - systemd.git/blobdiff - src/portable/portable.h
New upstream version 250.4
[systemd.git] / src / portable / portable.h
index ad81b584a5765bd7be3939006d084428a5b45c51..dff87857b31f5b20faf5b13ba6f006a629eb74a8 100644 (file)
@@ -1,4 +1,4 @@
-/* SPDX-License-Identifier: LGPL-2.1+ */
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
 #include "sd-bus.h"
 typedef struct PortableMetadata {
         int fd;
         char *source;
+        char *image_path;
+        char *selinux_label;
         char name[];
 } PortableMetadata;
 
 #define PORTABLE_METADATA_IS_OS_RELEASE(m) (streq((m)->name, "/etc/os-release"))
+#define PORTABLE_METADATA_IS_EXTENSION_RELEASE(m) (startswith((m)->name, "/usr/lib/extension-release.d/extension-release."))
 #define PORTABLE_METADATA_IS_UNIT(m) (!IN_SET((m)->name[0], 0, '/'))
 
 typedef enum PortableFlags {
-        PORTABLE_PREFER_COPY    = 1 << 0,
-        PORTABLE_PREFER_SYMLINK = 1 << 1,
-        PORTABLE_RUNTIME        = 1 << 2,
+        PORTABLE_RUNTIME        = 1 << 0, /* Public API via DBUS, do not change */
+        PORTABLE_PREFER_COPY    = 1 << 1,
+        PORTABLE_PREFER_SYMLINK = 1 << 2,
+        PORTABLE_REATTACH       = 1 << 3,
+        _PORTABLE_MASK_PUBLIC   = PORTABLE_RUNTIME,
+        _PORTABLE_TYPE_MAX,
+        _PORTABLE_TYPE_INVALID  = -EINVAL,
 } PortableFlags;
 
-typedef enum PortableChangeType {
+/* This enum is anonymous, since we usually store it in an 'int', as we overload it with negative errno
+ * values. */
+enum {
         PORTABLE_COPY,
         PORTABLE_SYMLINK,
         PORTABLE_UNLINK,
         PORTABLE_WRITE,
         PORTABLE_MKDIR,
         _PORTABLE_CHANGE_TYPE_MAX,
-        _PORTABLE_CHANGE_TYPE_INVALID = INT_MIN,
-} PortableChangeType;
+        _PORTABLE_CHANGE_TYPE_INVALID = -EINVAL,
+};
 
 typedef enum PortableState {
         PORTABLE_DETACHED,
@@ -42,11 +51,11 @@ typedef enum PortableState {
         PORTABLE_RUNNING,
         PORTABLE_RUNNING_RUNTIME,
         _PORTABLE_STATE_MAX,
-        _PORTABLE_STATE_INVALID = -1
+        _PORTABLE_STATE_INVALID = -EINVAL,
 } PortableState;
 
 typedef struct PortableChange {
-        int type; /* PortableFileChangeType or negative error number */
+        int type_or_errno; /* PORTABLE_COPY, PORTABLE_SYMLINK, … if positive, errno if negative */
         char *path;
         char *source;
 } PortableChange;
@@ -56,10 +65,10 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(PortableMetadata*, portable_metadata_unref);
 
 int portable_metadata_hashmap_to_sorted_array(Hashmap *unit_files, PortableMetadata ***ret);
 
-int portable_extract(const char *image, char **matches, PortableMetadata **ret_os_release, Hashmap **ret_unit_files, sd_bus_error *error);
+int portable_extract(const char *image, char **matches, char **extension_image_paths, PortableMetadata **ret_os_release, OrderedHashmap **ret_extension_releases, Hashmap **ret_unit_files, char ***ret_valid_prefixes, sd_bus_error *error);
 
-int portable_attach(sd_bus *bus, const char *name_or_path, char **matches, const char *profile, PortableFlags flags, PortableChange **changes, size_t *n_changes, sd_bus_error *error);
-int portable_detach(sd_bus *bus, const char *name_or_path, PortableFlags flags, PortableChange **changes, size_t *n_changes, sd_bus_error *error);
+int portable_attach(sd_bus *bus, const char *name_or_path, char **matches, const char *profile, char **extension_images, PortableFlags flags, PortableChange **changes, size_t *n_changes, sd_bus_error *error);
+int portable_detach(sd_bus *bus, const char *name_or_path, char **extension_image_paths, PortableFlags flags, PortableChange **changes, size_t *n_changes, sd_bus_error *error);
 
 int portable_get_state(sd_bus *bus, const char *name_or_path, PortableFlags flags, PortableState *ret, sd_bus_error *error);
 
@@ -67,8 +76,8 @@ int portable_get_profiles(char ***ret);
 
 void portable_changes_free(PortableChange *changes, size_t n_changes);
 
-const char *portable_change_type_to_string(PortableChangeType t) _const_;
-PortableChangeType portable_change_type_from_string(const char *t) _pure_;
+const char *portable_change_type_to_string(int t) _const_;
+int portable_change_type_from_string(const char *t) _pure_;
 
 const char *portable_state_to_string(PortableState t) _const_;
 PortableState portable_state_from_string(const char *t) _pure_;