]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/machine-image.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
5 This file is part of systemd.
7 Copyright 2014 Lennart Poettering
14 #include "lockfile-util.h"
16 #include "path-util.h"
17 #include "string-util.h"
18 #include "time-util.h"
20 typedef enum ImageType
{
26 _IMAGE_TYPE_INVALID
= -1
29 typedef struct Image
{
39 uint64_t usage_exclusive
;
41 uint64_t limit_exclusive
;
44 sd_id128_t machine_id
;
53 Image
*image_unref(Image
*i
);
54 static inline Hashmap
* image_hashmap_free(Hashmap
*map
) {
55 return hashmap_free_with_destructor(map
, image_unref
);
58 DEFINE_TRIVIAL_CLEANUP_FUNC(Image
*, image_unref
);
59 DEFINE_TRIVIAL_CLEANUP_FUNC(Hashmap
*, image_hashmap_free
);
61 int image_find(const char *name
, Image
**ret
);
62 int image_discover(Hashmap
*map
);
64 int image_remove(Image
*i
);
65 int image_rename(Image
*i
, const char *new_name
);
66 int image_clone(Image
*i
, const char *new_name
, bool read_only
);
67 int image_read_only(Image
*i
, bool b
);
69 const char* image_type_to_string(ImageType t
) _const_
;
70 ImageType
image_type_from_string(const char *s
) _pure_
;
72 bool image_name_is_valid(const char *s
) _pure_
;
74 int image_path_lock(const char *path
, int operation
, LockFile
*global
, LockFile
*local
);
75 int image_name_lock(const char *name
, int operation
, LockFile
*ret
);
77 int image_set_limit(Image
*i
, uint64_t referenced_max
);
79 int image_read_metadata(Image
*i
);
81 static inline bool IMAGE_IS_HIDDEN(const struct Image
*i
) {
84 return i
->name
&& i
->name
[0] == '.';
87 static inline bool IMAGE_IS_VENDOR(const struct Image
*i
) {
90 return i
->path
&& path_startswith(i
->path
, "/usr");
93 static inline bool IMAGE_IS_HOST(const struct Image
*i
) {
96 if (i
->name
&& streq(i
->name
, ".host"))
99 if (i
->path
&& path_equal(i
->path
, "/"))