]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
utils: switch to has_fs_type()
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 1 Aug 2017 21:33:43 +0000 (23:33 +0200)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 15 Aug 2017 20:36:34 +0000 (16:36 -0400)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/utils.c
src/lxc/utils.h

index 5409e7c04729cf2c180881d404de158f7735aed4..d36107020397db9524b81113f192a724c89c9949 100644 (file)
@@ -42,7 +42,6 @@
 #include <sys/prctl.h>
 #include <sys/stat.h>
 #include <sys/types.h>
-#include <sys/vfs.h>
 #include <sys/wait.h>
 
 #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;
 }
 
index 6351492b70069d4ebacf7249b1df3f01b91baa8f..4408c6d6925d2d52fcd15a7595555ca039c70461 100644 (file)
@@ -34,6 +34,7 @@
 #include <stdbool.h>
 #include <unistd.h>
 #include <linux/loop.h>
+#include <linux/magic.h>
 #include <sys/syscall.h>
 #include <sys/types.h>
 #include <sys/vfs.h>