summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/path-util.c12
-rw-r--r--src/shared/path-util.h1
-rw-r--r--src/shared/util.h12
3 files changed, 25 insertions, 0 deletions
diff --git a/src/shared/path-util.c b/src/shared/path-util.c
index 0b50ea646a..b623fc3dd5 100644
--- a/src/shared/path-util.c
+++ b/src/shared/path-util.c
@@ -413,3 +413,15 @@ int path_is_read_only_fs(const char *path) {
return !!(st.f_flag & ST_RDONLY);
}
+
+int path_is_os_tree(const char *path) {
+ char *p;
+ int r;
+
+ /* We use /etc/os-release as flag file if something is an OS */
+
+ p = strappenda(path, "/etc/os-release");
+ r = access(p, F_OK);
+
+ return r < 0 ? 0 : 1;
+}
diff --git a/src/shared/path-util.h b/src/shared/path-util.h
index 9347bc3a9b..ea0f173082 100644
--- a/src/shared/path-util.h
+++ b/src/shared/path-util.h
@@ -40,3 +40,4 @@ char **path_strv_canonicalize_uniq(char **l);
int path_is_mount_point(const char *path, bool allow_symlink);
int path_is_read_only_fs(const char *path);
+int path_is_os_tree(const char *path);
diff --git a/src/shared/util.h b/src/shared/util.h
index 3aac165e67..cfb54939cd 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -684,3 +684,15 @@ int unlink_noerrno(const char *path);
_new_ = alloca(_len_); \
(void *) memset(_new_, 0, _len_); \
})
+
+#define strappenda(a, b) \
+ ({ \
+ const char *_a_ = (a), *_b_ = (b); \
+ char *_c_; \
+ size_t _x_, _y_; \
+ _x_ = strlen(_a_); \
+ _y_ = strlen(_b_); \
+ _c_ = alloca(_x_ + _y_ + 1); \
+ strcpy(stpcpy(_c_, _a_), _b_); \
+ _c_; \
+ })