diff options
-rw-r--r-- | src/shared/machine-image.c | 25 | ||||
-rw-r--r-- | src/shared/machine-image.h | 3 |
2 files changed, 24 insertions, 4 deletions
diff --git a/src/shared/machine-image.c b/src/shared/machine-image.c index 36861d93fc..41e9513abc 100644 --- a/src/shared/machine-image.c +++ b/src/shared/machine-image.c @@ -477,16 +477,32 @@ int image_find(ImageClass class, const char *name, Image **ret) { if (r < 0) return r; + if (ret) + (*ret)->discoverable = true; + return 1; } - if (class == IMAGE_MACHINE && streq(name, ".host")) - return image_make(".host", AT_FDCWD, NULL, "/", NULL, ret); + if (class == IMAGE_MACHINE && streq(name, ".host")) { + r = image_make(".host", AT_FDCWD, NULL, "/", NULL, ret); + if (r < 0) + return r; + + if (ret) + (*ret)->discoverable = true; + + return r; + } return -ENOENT; }; int image_from_path(const char *path, Image **ret) { + + /* Note that we don't set the 'discoverable' field of the returned object, because we don't check here whether + * the image is in the image search path. And if it is we don't know if the path we used is actually not + * overriden by another, different image earlier in the search path */ + if (path_equal(path, "/")) return image_make(".host", AT_FDCWD, NULL, "/", NULL, ret); @@ -567,6 +583,8 @@ int image_discover(ImageClass class, Hashmap *h) { if (r < 0) return r; + image->discoverable = true; + r = hashmap_put(h, image->name, image); if (r < 0) return r; @@ -582,12 +600,13 @@ int image_discover(ImageClass class, Hashmap *h) { if (r < 0) return r; + image->discoverable = true; + r = hashmap_put(h, image->name, image); if (r < 0) return r; image = NULL; - } return 0; diff --git a/src/shared/machine-image.h b/src/shared/machine-image.h index 899268dbd1..7e09e8002a 100644 --- a/src/shared/machine-image.h +++ b/src/shared/machine-image.h @@ -54,7 +54,8 @@ typedef struct Image { char **machine_info; char **os_release; - bool metadata_valid; + bool metadata_valid:1; + bool discoverable:1; /* true if we know for sure that image_find() would find the image given just the short name */ void *userdata; } Image; |