]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/discover-image.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
9 typedef enum ImageType
{
15 _IMAGE_TYPE_INVALID
= -EINVAL
,
18 typedef struct Image
{
31 uint64_t usage_exclusive
;
33 uint64_t limit_exclusive
;
36 sd_id128_t machine_id
;
39 char **sysext_release
;
40 char **confext_release
;
42 bool metadata_valid
:1;
43 bool discoverable
:1; /* true if we know for sure that image_find() would find the image given just the short name */
48 Image
* image_unref(Image
*i
);
49 Image
* image_ref(Image
*i
);
51 DEFINE_TRIVIAL_CLEANUP_FUNC(Image
*, image_unref
);
53 int image_find(RuntimeScope scope
, ImageClass
class, const char *name
, const char *root
, Image
**ret
);
54 int image_from_path(const char *path
, Image
**ret
);
55 int image_find_harder(RuntimeScope scope
, ImageClass
class, const char *name_or_path
, const char *root
, Image
**ret
);
56 int image_discover(RuntimeScope scope
, ImageClass
class, const char *root
, Hashmap
**images
);
58 int image_remove(Image
*i
);
59 int image_rename(Image
*i
, const char *new_name
, RuntimeScope scope
);
60 int image_clone(Image
*i
, const char *new_name
, bool read_only
, RuntimeScope scope
);
61 int image_read_only(Image
*i
, bool b
);
63 const char* image_type_to_string(ImageType t
) _const_
;
64 ImageType
image_type_from_string(const char *s
) _pure_
;
66 int image_path_lock(const char *path
, int operation
, LockFile
*global
, LockFile
*local
);
67 int image_name_lock(const char *name
, int operation
, LockFile
*ret
);
69 int image_set_limit(Image
*i
, uint64_t referenced_max
);
70 int image_set_pool_limit(ImageClass
class, uint64_t referenced_max
);
72 int image_read_metadata(Image
*i
, const ImagePolicy
*image_policy
);
74 bool image_in_search_path(RuntimeScope scope
, ImageClass
class, const char *root
, const char *image
);
76 static inline char** image_extension_release(Image
*image
, ImageClass
class) {
79 if (class == IMAGE_SYSEXT
)
80 return image
->sysext_release
;
81 if (class == IMAGE_CONFEXT
)
82 return image
->confext_release
;
87 static inline bool image_is_hidden(const struct Image
*i
) {
90 return i
->name
&& i
->name
[0] == '.';
93 bool image_is_vendor(const struct Image
*i
);
94 bool image_is_host(const struct Image
*i
);
96 int image_to_json(const struct Image
*i
, sd_json_variant
**ret
);
98 const char* image_root_to_string(ImageClass c
) _const_
;
99 const char* image_root_runtime_to_string(ImageClass c
) _const_
;
101 extern const struct hash_ops image_hash_ops
;
103 extern const char* const image_search_path
[_IMAGE_CLASS_MAX
];