#include "string-util.h"
#include "strv.h"
-int path_is_os_tree(const char *path) {
+int path_is_extension_tree(const char *path, const char *extension) {
int r;
assert(path);
if (laccess(path, F_OK) < 0)
return -errno;
- /* We use {/etc|/usr/lib}/os-release as flag file if something is an OS */
- r = open_os_release(path, NULL, NULL);
+ /* We use /usr/lib/extension-release.d/extension-release.NAME as flag file if something is a system extension,
+ * and {/etc|/usr/lib}/os-release as flag file if something is an OS (in case extension == NULL) */
+ r = open_extension_release(path, extension, NULL, NULL);
if (r == -ENOENT) /* We got nothing */
return 0;
if (r < 0)
#include <stdio.h>
-int path_is_os_tree(const char *path);
-
/* The *_extension_release flavours will look for /usr/lib/extension-release/extension-release.NAME
* in accordance with the OS extension specification, rather than for /usr/lib/ or /etc/os-release. */
+
+int path_is_extension_tree(const char *path, const char *extension);
+static inline int path_is_os_tree(const char *path) {
+ return path_is_extension_tree(path, NULL);
+}
+
int open_extension_release(const char *root, const char *extension, char **ret_path, int *ret_fd);
static inline int open_os_release(const char *root, char **ret_path, int *ret_fd) {
return open_extension_release(root, NULL, ret_path, ret_fd);