]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/discover-image.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
10 #include "lock-util.h"
12 #include "path-util.h"
13 #include "string-util.h"
14 #include "time-util.h"
16 typedef enum ImageClass
{
21 _IMAGE_CLASS_INVALID
= -EINVAL
,
24 typedef enum ImageType
{
30 _IMAGE_TYPE_INVALID
= -EINVAL
,
33 typedef struct Image
{
46 uint64_t usage_exclusive
;
48 uint64_t limit_exclusive
;
51 sd_id128_t machine_id
;
54 char **extension_release
;
56 bool metadata_valid
:1;
57 bool discoverable
:1; /* true if we know for sure that image_find() would find the image given just the short name */
62 Image
*image_unref(Image
*i
);
63 Image
*image_ref(Image
*i
);
65 DEFINE_TRIVIAL_CLEANUP_FUNC(Image
*, image_unref
);
67 int image_find(ImageClass
class, const char *root
, const char *name
, Image
**ret
);
68 int image_from_path(const char *path
, Image
**ret
);
69 int image_find_harder(ImageClass
class, const char *root
, const char *name_or_path
, Image
**ret
);
70 int image_discover(ImageClass
class, const char *root
, Hashmap
*map
);
72 int image_remove(Image
*i
);
73 int image_rename(Image
*i
, const char *new_name
);
74 int image_clone(Image
*i
, const char *new_name
, bool read_only
);
75 int image_read_only(Image
*i
, bool b
);
77 const char* image_type_to_string(ImageType t
) _const_
;
78 ImageType
image_type_from_string(const char *s
) _pure_
;
80 const char* image_class_to_string(ImageClass cl
) _const_
;
81 ImageClass
image_class_from_string(const char *s
) _pure_
;
83 int image_path_lock(const char *path
, int operation
, LockFile
*global
, LockFile
*local
);
84 int image_name_lock(const char *name
, int operation
, LockFile
*ret
);
86 int image_set_limit(Image
*i
, uint64_t referenced_max
);
88 int image_read_metadata(Image
*i
);
90 bool image_in_search_path(ImageClass
class, const char *root
, const char *image
);
92 static inline bool IMAGE_IS_HIDDEN(const struct Image
*i
) {
95 return i
->name
&& i
->name
[0] == '.';
98 static inline bool IMAGE_IS_VENDOR(const struct Image
*i
) {
101 return i
->path
&& path_startswith(i
->path
, "/usr");
104 static inline bool IMAGE_IS_HOST(const struct Image
*i
) {
107 if (i
->name
&& streq(i
->name
, ".host"))
110 if (i
->path
&& path_equal(i
->path
, "/"))
116 extern const struct hash_ops image_hash_ops
;