journal: move code that checks for network fs to stat-util.[ch]
We have similar code in stat-util.[ch] and managing this at a central place almost definitely is the better choice.
This commit is contained in:
+25
-4
@@ -214,8 +214,19 @@ int path_is_fs_type(const char *path, statfs_f_type_t magic_value) {
|
||||
}
|
||||
|
||||
bool is_temporary_fs(const struct statfs *s) {
|
||||
return is_fs_type(s, TMPFS_MAGIC) ||
|
||||
is_fs_type(s, RAMFS_MAGIC);
|
||||
return is_fs_type(s, TMPFS_MAGIC) ||
|
||||
is_fs_type(s, RAMFS_MAGIC);
|
||||
}
|
||||
|
||||
bool is_network_fs(const struct statfs *s) {
|
||||
return is_fs_type(s, CIFS_MAGIC_NUMBER) ||
|
||||
is_fs_type(s, CODA_SUPER_MAGIC) ||
|
||||
is_fs_type(s, NCP_SUPER_MAGIC) ||
|
||||
is_fs_type(s, NFS_SUPER_MAGIC) ||
|
||||
is_fs_type(s, SMB_SUPER_MAGIC) ||
|
||||
is_fs_type(s, V9FS_MAGIC) ||
|
||||
is_fs_type(s, AFS_SUPER_MAGIC) ||
|
||||
is_fs_type(s, OCFS2_SUPER_MAGIC);
|
||||
}
|
||||
|
||||
int fd_is_temporary_fs(int fd) {
|
||||
@@ -227,15 +238,25 @@ int fd_is_temporary_fs(int fd) {
|
||||
return is_temporary_fs(&s);
|
||||
}
|
||||
|
||||
int fd_is_network_fs(int fd) {
|
||||
struct statfs s;
|
||||
|
||||
if (fstatfs(fd, &s) < 0)
|
||||
return -errno;
|
||||
|
||||
return is_network_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)
|
||||
|
||||
if (ioctl(fd, NS_GET_NSTYPE) < 0)
|
||||
return -errno;
|
||||
|
||||
return r == CLONE_NEWNET;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user