From 277d0c5729bd21cd925596d4ca806c32aa7c8db5 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 8 Dec 2016 19:39:50 +0100 Subject: [PATCH] util-lib: add new path_is_temporary_fs() API As simple wrapper around fd_is_temporary_fs(). --- src/basic/stat-util.c | 10 ++++++++++ src/basic/stat-util.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/basic/stat-util.c b/src/basic/stat-util.c index b62acdb7a..0c3fbc8e1 100644 --- a/src/basic/stat-util.c +++ b/src/basic/stat-util.c @@ -233,3 +233,13 @@ int fd_is_temporary_fs(int fd) { return is_temporary_fs(&s); } + +int path_is_temporary_fs(const char *path) { + _cleanup_close_ int fd = -1; + + fd = open(path, O_RDONLY|O_CLOEXEC|O_NOCTTY); + if (fd < 0) + return -errno; + + return fd_is_temporary_fs(fd); +} diff --git a/src/basic/stat-util.h b/src/basic/stat-util.h index 077bfdd50..168cb3cb5 100644 --- a/src/basic/stat-util.h +++ b/src/basic/stat-util.h @@ -71,6 +71,7 @@ int path_check_fstype(const char *path, statfs_f_type_t magic_value); bool is_temporary_fs(const struct statfs *s) _pure_; int fd_is_temporary_fs(int fd); +int path_is_temporary_fs(const char *path); /* Because statfs.t_type can be int on some architectures, we have to cast * the const magic to the type, otherwise the compiler warns about -- 2.30.2