From 29a11a7f1bbf4021c7e34eea474a71fe5122e339 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Tue, 1 Aug 2017 23:33:43 +0200 Subject: [PATCH] utils: switch to has_fs_type() Signed-off-by: Christian Brauner --- src/lxc/utils.c | 23 ++++++++++++----------- src/lxc/utils.h | 1 + 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/lxc/utils.c b/src/lxc/utils.c index 88692035f..d3b0fdc5d 100644 --- a/src/lxc/utils.c +++ b/src/lxc/utils.c @@ -42,7 +42,6 @@ #include #include #include -#include #include #include "log.h" @@ -183,22 +182,24 @@ static int _recursive_rmdir(char *dirname, dev_t pdev, return failed ? -1 : 0; } -/* we have two different magic values for overlayfs, yay */ +/* We have two different magic values for overlayfs, yay. */ +#ifndef OVERLAYFS_SUPER_MAGIC #define OVERLAYFS_SUPER_MAGIC 0x794c764f +#endif + +#ifndef OVERLAY_SUPER_MAGIC #define OVERLAY_SUPER_MAGIC 0x794c7630 -/* - * In overlayfs, st_dev is unreliable. so on overlayfs we don't do - * the lxc_rmdir_onedev() +#endif + +/* In overlayfs, st_dev is unreliable. So on overlayfs we don't do the + * lxc_rmdir_onedev() */ static bool is_native_overlayfs(const char *path) { - struct statfs sb; - - if (statfs(path, &sb) < 0) - return false; - if (sb.f_type == OVERLAYFS_SUPER_MAGIC || - sb.f_type == OVERLAY_SUPER_MAGIC) + if (has_fs_type(path, OVERLAY_SUPER_MAGIC) || + has_fs_type(path, OVERLAYFS_SUPER_MAGIC)) return true; + return false; } diff --git a/src/lxc/utils.h b/src/lxc/utils.h index addfb7a05..fc0e5c01c 100644 --- a/src/lxc/utils.h +++ b/src/lxc/utils.h @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include