]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/machine-image.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
10 #include "lockfile-util.h"
12 #include "path-util.h"
13 #include "string-util.h"
14 #include "time-util.h"
16 typedef enum ImageClass
{
20 _IMAGE_CLASS_INVALID
= -1
23 typedef enum ImageType
{
29 _IMAGE_TYPE_INVALID
= -1
32 typedef struct Image
{
44 uint64_t usage_exclusive
;
46 uint64_t limit_exclusive
;
49 sd_id128_t machine_id
;
53 bool metadata_valid
:1;
54 bool discoverable
:1; /* true if we know for sure that image_find() would find the image given just the short name */
59 Image
*image_unref(Image
*i
);
60 Image
*image_ref(Image
*i
);
62 DEFINE_TRIVIAL_CLEANUP_FUNC(Image
*, image_unref
);
64 int image_find(ImageClass
class, const char *name
, Image
**ret
);
65 int image_from_path(const char *path
, Image
**ret
);
66 int image_find_harder(ImageClass
class, const char *name_or_path
, Image
**ret
);
67 int image_discover(ImageClass
class, Hashmap
*map
);
69 int image_remove(Image
*i
);
70 int image_rename(Image
*i
, const char *new_name
);
71 int image_clone(Image
*i
, const char *new_name
, bool read_only
);
72 int image_read_only(Image
*i
, bool b
);
74 const char* image_type_to_string(ImageType t
) _const_
;
75 ImageType
image_type_from_string(const char *s
) _pure_
;
77 bool image_name_is_valid(const char *s
) _pure_
;
79 int image_path_lock(const char *path
, int operation
, LockFile
*global
, LockFile
*local
);
80 int image_name_lock(const char *name
, int operation
, LockFile
*ret
);
82 int image_set_limit(Image
*i
, uint64_t referenced_max
);
84 int image_read_metadata(Image
*i
);
86 bool image_in_search_path(ImageClass
class, const char *image
);
88 static inline bool IMAGE_IS_HIDDEN(const struct Image
*i
) {
91 return i
->name
&& i
->name
[0] == '.';
94 static inline bool IMAGE_IS_VENDOR(const struct Image
*i
) {
97 return i
->path
&& path_startswith(i
->path
, "/usr");
100 static inline bool IMAGE_IS_HOST(const struct Image
*i
) {
103 if (i
->name
&& streq(i
->name
, ".host"))
106 if (i
->path
&& path_equal(i
->path
, "/"))
112 extern const struct hash_ops image_hash_ops
;