chiark / gitweb /
build-sys: Add configure check for linux/btrfs.h
authorMichael Marineau <michael.marineau@coreos.com>
Thu, 15 Aug 2013 15:50:57 +0000 (11:50 -0400)
committerKay Sievers <kay@vrfy.org>
Fri, 16 Aug 2013 21:29:41 +0000 (23:29 +0200)
btrfs.h was added to uapi in Linux 3.9. To fix building with older
header versions this adds a configure check for the header and re-adds
btrfs definitions to missing.h which was removed in bed2e820 along with
two other ioctls used by gpt-auto-generator.

[ Apparently, btrfs.h was only added recently:
  http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=55e301fd57a6239ec14b91a1cf2e70b3dd135194
  let's re-add it for now -- kay ]

configure.ac
src/gpt-auto-generator/gpt-auto-generator.c
src/readahead/readahead-collect.c
src/shared/missing.h

index 6ef6382c4c2c93436c9b2ca31ec63a4d0d919e4d..2541344f0c1ae7f27e040d362f70e69e4691e9b1 100644 (file)
@@ -192,6 +192,7 @@ AM_CONDITIONAL([HAVE_PYTHON_DEVEL], [test "$have_python_devel" = "yes"])
 
 AC_SEARCH_LIBS([dlsym], [dl], [], [AC_MSG_ERROR([*** Dynamic linking loader library not found])])
 AC_CHECK_HEADERS([sys/capability.h], [], [AC_MSG_ERROR([*** POSIX caps headers not found])])
+AC_CHECK_HEADERS([linux/btrfs.h], [], [])
 
 # unconditionally pull-in librt with old glibc versions
 AC_SEARCH_LIBS([clock_gettime], [rt], [], [])
@@ -220,6 +221,7 @@ m4_pattern_forbid([^_?PKG_[A-Z_]+$],[*** pkg.m4 missing, please install pkg-conf
 
 PKG_CHECK_MODULES(DBUS, [dbus-1 >= 1.3.2])
 
+
 # ------------------------------------------------------------------------------
 have_coverage=no
 AC_ARG_ENABLE(coverage, AS_HELP_STRING([--enable-coverage], [enable test coverage]))
index 81d692c51368c034ff14ad51932c1fbfcffbbd4b..a26655f096fe6ddf4a62b1c8bec58b7d79a18330 100644 (file)
 #include <unistd.h>
 #include <stdlib.h>
 #include <fcntl.h>
-#include <linux/btrfs.h>
 #include <sys/ioctl.h>
 #include <sys/statfs.h>
 #include <blkid.h>
 
+#ifdef HAVE_LINUX_BTRFS_H
+#include <linux/btrfs.h>
+#endif
+
 #include "path-util.h"
 #include "util.h"
 #include "mkdir.h"
index 658c230d65e985cbdd43a753ac3f2a515562110d..5d37bb75f3c3da7b11f507906afd892d3d6899ad 100644 (file)
 #include <sys/mman.h>
 #include <linux/fs.h>
 #include <linux/fiemap.h>
-#include <linux/btrfs.h>
 #include <sys/ioctl.h>
 #include <sys/vfs.h>
 #include <getopt.h>
 #include <sys/inotify.h>
 #include <math.h>
 
+#ifdef HAVE_LINUX_BTRFS_H
+#include <linux/btrfs.h>
+#endif
+
 #ifdef HAVE_FANOTIFY_INIT
 #include <sys/fanotify.h>
 #endif
index 6e4b398fcbc39d4754200a06c38955f6dbd728a4..d1ca135c5533e829f7cf2fa63f5c942b5d21d56f 100644 (file)
@@ -154,6 +154,63 @@ static inline int fanotify_mark(int fanotify_fd, unsigned int flags, uint64_t ma
 }
 #endif
 
+#ifndef BTRFS_IOCTL_MAGIC
+#define BTRFS_IOCTL_MAGIC 0x94
+#endif
+
+#ifndef BTRFS_PATH_NAME_MAX
+#define BTRFS_PATH_NAME_MAX 4087
+#endif
+
+#ifndef BTRFS_DEVICE_PATH_NAME_MAX
+#define BTRFS_DEVICE_PATH_NAME_MAX 1024
+#endif
+
+#ifndef BTRFS_FSID_SIZE
+#define BTRFS_FSID_SIZE 16
+#endif
+
+#ifndef BTRFS_UUID_SIZE
+#define BTRFS_UUID_SIZE 16
+#endif
+
+#ifndef HAVE_LINUX_BTRFS_H
+struct btrfs_ioctl_vol_args {
+        int64_t fd;
+        char name[BTRFS_PATH_NAME_MAX + 1];
+};
+
+struct btrfs_ioctl_dev_info_args {
+        uint64_t devid;                         /* in/out */
+        uint8_t uuid[BTRFS_UUID_SIZE];          /* in/out */
+        uint64_t bytes_used;                    /* out */
+        uint64_t total_bytes;                   /* out */
+        uint64_t unused[379];                   /* pad to 4k */
+        char path[BTRFS_DEVICE_PATH_NAME_MAX];  /* out */
+};
+
+struct btrfs_ioctl_fs_info_args {
+        uint64_t max_id;                        /* out */
+        uint64_t num_devices;                   /* out */
+        uint8_t fsid[BTRFS_FSID_SIZE];          /* out */
+        uint64_t reserved[124];                 /* pad to 1k */
+};
+#endif
+
+#ifndef BTRFS_IOC_DEFRAG
+#define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, struct btrfs_ioctl_vol_args)
+#endif
+
+#ifndef BTRFS_IOC_DEV_INFO
+#define BTRFS_IOC_DEV_INFO _IOWR(BTRFS_IOCTL_MAGIC, 30, \
+                                 struct btrfs_ioctl_dev_info_args)
+#endif
+
+#ifndef BTRFS_IOC_FS_INFO
+#define BTRFS_IOC_FS_INFO _IOR(BTRFS_IOCTL_MAGIC, 31, \
+                               struct btrfs_ioctl_fs_info_args)
+#endif
+
 #ifndef BTRFS_SUPER_MAGIC
 #define BTRFS_SUPER_MAGIC 0x9123683E
 #endif