/* 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"
} ImageType;
typedef struct Image {
+ unsigned n_ref;
+
ImageType type;
char *name;
char *path;
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);
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);
return false;
}
+
+extern const struct hash_ops image_hash_ops;