diff options
author | Michael Biebl <biebl@debian.org> | 2017-12-14 23:22:02 +0100 |
---|---|---|
committer | Michael Biebl <biebl@debian.org> | 2017-12-14 23:22:02 +0100 |
commit | 52ad194e0b816b8273dd8d0fea3e6d467f6ca34e (patch) | |
tree | 1a3b3117e015f200ca0ce23f5ad27be6d0a7b0fb /src/basic/stat-util.c | |
parent | f5e65279187b6aa0c0c5a00b14dca9eab441ffb2 (diff) | |
download | systemd-52ad194e0b816b8273dd8d0fea3e6d467f6ca34e.tar.gz |
New upstream version 236
Diffstat (limited to 'src/basic/stat-util.c')
-rw-r--r-- | src/basic/stat-util.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/basic/stat-util.c b/src/basic/stat-util.c index d87370e672..96fc8b3787 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. @@ -192,7 +193,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) @@ -201,14 +202,14 @@ int fd_check_fstype(int fd, statfs_f_type_t magic_value) { return is_fs_type(&s, magic_value); } -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); } bool is_temporary_fs(const struct statfs *s) { @@ -225,6 +226,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; |