summaryrefslogtreecommitdiff
path: root/src/basic/stat-util.c
diff options
context:
space:
mode:
authorSven Eden <yamakuzure@gmx.net>2018-03-13 19:11:43 +0100
committerSven Eden <yamakuzure@gmx.net>2018-03-26 18:25:45 +0200
commit5a1765290e87f45b970657cfc8ac1e7ca5c50d6a (patch)
tree316b8b753c02e894a621976a888d8741e3cf9156 /src/basic/stat-util.c
parent869eeae5727fa42bbb442ef10c0dde985fcdce4d (diff)
Prep v236 : Add missing SPDX-License-Identifier (2/9) src/basic
Diffstat (limited to 'src/basic/stat-util.c')
-rw-r--r--src/basic/stat-util.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/basic/stat-util.c b/src/basic/stat-util.c
index 0c8c301b6..064e316fc 100644
--- a/src/basic/stat-util.c
+++ b/src/basic/stat-util.c
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
/***
This file is part of systemd.
@@ -200,7 +201,7 @@ bool is_fs_type(const struct statfs *s, statfs_f_type_t magic_value) {
return F_TYPE_EQUAL(s->f_type, magic_value);
}
-int fd_check_fstype(int fd, statfs_f_type_t magic_value) {
+int fd_is_fs_type(int fd, statfs_f_type_t magic_value) {
struct statfs s;
if (fstatfs(fd, &s) < 0)
@@ -210,14 +211,14 @@ int fd_check_fstype(int fd, statfs_f_type_t magic_value) {
}
#if 0 /// UNNEEDED by elogind
-int path_check_fstype(const char *path, statfs_f_type_t magic_value) {
+int path_is_fs_type(const char *path, statfs_f_type_t magic_value) {
_cleanup_close_ int fd = -1;
fd = open(path, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_PATH);
if (fd < 0)
return -errno;
- return fd_check_fstype(fd, magic_value);
+ return fd_is_fs_type(fd, magic_value);
}
#endif // 0
@@ -236,6 +237,18 @@ int fd_is_temporary_fs(int fd) {
return is_temporary_fs(&s);
}
+int fd_is_network_ns(int fd) {
+ int r;
+
+ r = fd_is_fs_type(fd, NSFS_MAGIC);
+ if (r <= 0)
+ return r;
+ r = ioctl(fd, NS_GET_NSTYPE);
+ if (r < 0)
+ return -errno;
+ return r == CLONE_NEWNET;
+}
+
int path_is_temporary_fs(const char *path) {
_cleanup_close_ int fd = -1;