[CRIU] [PATCH 2/4] util: Add is_anon_inode helper
Cyrill Gorcunov
gorcunov at openvz.org
Tue Apr 24 09:15:31 EDT 2012
Will need it for eventfd, inotify and friends.
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
include/util.h | 1 +
util.c | 15 +++++++++++++++
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/include/util.h b/include/util.h
index 60ff126..d526ca8 100644
--- a/include/util.h
+++ b/include/util.h
@@ -276,5 +276,6 @@ static inline dev_t kdev_to_odev(u32 kdev)
}
int copy_file(int fd_in, int fd_out, size_t bytes);
+bool is_anon_inode(int fd);
#endif /* UTIL_H_ */
diff --git a/util.c b/util.c
index 82b06db..2be5a3f 100644
--- a/util.c
+++ b/util.c
@@ -301,3 +301,18 @@ int copy_file(int fd_in, int fd_out, size_t bytes)
return 0;
}
+
+bool is_anon_inode(int fd)
+{
+ struct statfs statfs;
+
+ if (fstatfs(fd, &statfs)) {
+ pr_perror("Can't obtain statfs on fd %d\n", fd);
+ return false;
+ }
+
+ if (statfs.f_type != ANON_INODE_FS_MAGIC)
+ return false;
+
+ return true;
+}
--
1.7.7.6
More information about the CRIU
mailing list