]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/shared/machine-image.h
Merge pull request #11827 from keszybz/pkgconfig-variables
[thirdparty/systemd.git] / src / shared / machine-image.h
index dafea0c903d2c0c2012fc51dbfd502b2962f0354..9fd45899c80d3a5e160ca4a2a4ee04481ba3900b 100644 (file)
@@ -1,15 +1,11 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 #pragma once
 
-/***
-  This file is part of systemd.
-
-  Copyright 2014 Lennart Poettering
-***/
-
 #include <stdbool.h>
 #include <stdint.h>
 
+#include "sd-id128.h"
+
 #include "hashmap.h"
 #include "lockfile-util.h"
 #include "macro.h"
@@ -34,6 +30,8 @@ typedef enum ImageType {
 } ImageType;
 
 typedef struct Image {
+        unsigned n_ref;
+
         ImageType type;
         char *name;
         char *path;
@@ -52,20 +50,20 @@ typedef struct Image {
         char **machine_info;
         char **os_release;
 
-        bool metadata_valid;
+        bool metadata_valid:1;
+        bool discoverable:1;  /* true if we know for sure that image_find() would find the image given just the short name */
 
         void *userdata;
 } Image;
 
 Image *image_unref(Image *i);
-static inline Hashmap* image_hashmap_free(Hashmap *map) {
-        return hashmap_free_with_destructor(map, image_unref);
-}
+Image *image_ref(Image *i);
 
 DEFINE_TRIVIAL_CLEANUP_FUNC(Image*, image_unref);
-DEFINE_TRIVIAL_CLEANUP_FUNC(Hashmap*, image_hashmap_free);
 
 int image_find(ImageClass class, const char *name, Image **ret);
+int image_from_path(const char *path, Image **ret);
+int image_find_harder(ImageClass class, const char *name_or_path, Image **ret);
 int image_discover(ImageClass class, Hashmap *map);
 
 int image_remove(Image *i);
@@ -85,6 +83,8 @@ int image_set_limit(Image *i, uint64_t referenced_max);
 
 int image_read_metadata(Image *i);
 
+bool image_in_search_path(ImageClass class, const char *image);
+
 static inline bool IMAGE_IS_HIDDEN(const struct Image *i) {
         assert(i);
 
@@ -108,3 +108,5 @@ static inline bool IMAGE_IS_HOST(const struct Image *i) {
 
         return false;
 }
+
+extern const struct hash_ops image_hash_ops;