mirror of
https://github.com/systemd/systemd.git
synced 2025-01-27 18:04:05 +03:00
machine-image: add APIs for converting arbitrary image paths into Image objects
This commit is contained in:
parent
4c2e654b21
commit
2ddf182baa
@ -469,6 +469,20 @@ int image_find(ImageClass class, const char *name, Image **ret) {
|
||||
return -ENOENT;
|
||||
};
|
||||
|
||||
int image_from_path(const char *path, Image **ret) {
|
||||
if (path_equal(path, "/"))
|
||||
return image_make(".host", AT_FDCWD, NULL, "/", NULL, ret);
|
||||
|
||||
return image_make(NULL, AT_FDCWD, NULL, path, NULL, ret);
|
||||
}
|
||||
|
||||
int image_find_harder(ImageClass class, const char *name_or_path, Image **ret) {
|
||||
if (image_name_is_valid(name_or_path))
|
||||
return image_find(class, name_or_path, ret);
|
||||
|
||||
return image_from_path(name_or_path, ret);
|
||||
}
|
||||
|
||||
int image_discover(ImageClass class, Hashmap *h) {
|
||||
const char *path;
|
||||
int r;
|
||||
|
@ -66,6 +66,8 @@ 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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user