summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--src/libudev/missing.h105
-rw-r--r--src/libudev/util.h1
-rw-r--r--src/udev/udev-builtin-btrfs.c10
4 files changed, 92 insertions, 26 deletions
diff --git a/configure.ac b/configure.ac
index ed0635e685..6945976027 100644
--- a/configure.ac
+++ b/configure.ac
@@ -49,7 +49,7 @@ AC_CHECK_HEADERS(
)
AC_CHECK_HEADERS(
- [mtd/mtd-user.h],
+ [linux/btrfs.h mtd/mtd-user.h],
[],
[AC_MSG_ERROR([*** KERNEL header not found])]
)
diff --git a/src/libudev/missing.h b/src/libudev/missing.h
index cb97c93a6c..242e3c8d2e 100644
--- a/src/libudev/missing.h
+++ b/src/libudev/missing.h
@@ -41,12 +41,79 @@
#define RLIMIT_RTTIME 15
#endif
-#ifndef MS_PRIVATE
-#define MS_PRIVATE (1 << 18)
+#ifndef BTRFS_IOCTL_MAGIC
+#define BTRFS_IOCTL_MAGIC 0x94
#endif
-#ifndef MS_REC
-#define MS_REC 16384
+#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_IOC_DEVICES_READY
+#define BTRFS_IOC_DEVICES_READY _IOR(BTRFS_IOCTL_MAGIC, 39, \
+ struct btrfs_ioctl_vol_args)
+#endif
+
+#ifndef BTRFS_SUPER_MAGIC
+#define BTRFS_SUPER_MAGIC 0x9123683E
+#endif
+
+#ifndef MS_MOVE
+#define MS_MOVE 8192
+#endif
+
+#ifndef MS_PRIVATE
+#define MS_PRIVATE (1 << 18)
#endif
#if !HAVE_DECL_GETTID
@@ -55,29 +122,29 @@ static inline pid_t gettid(void) {
}
#endif
+#ifndef MS_PRIVATE
+#define MS_PRIVATE (1 << 18)
+#endif
+
+#ifndef MS_REC
+#define MS_REC 16384
+#endif
+
#ifndef MAX_HANDLE_SZ
#define MAX_HANDLE_SZ 128
#endif
-#if defined __x86_64__
-# ifndef __NR_name_to_handle_at
+#ifndef __NR_name_to_handle_at
+# if defined(__x86_64__)
# define __NR_name_to_handle_at 303
-# endif
-#elif defined __i386__
-# ifndef __NR_name_to_handle_at
+# elif defined(__i386__)
# define __NR_name_to_handle_at 341
-# endif
-#elif defined __arm__
-# ifndef __NR_name_to_handle_at
+# elif defined(__arm__)
# define __NR_name_to_handle_at 370
-# endif
-#elif defined __powerpc__
-# ifndef __NR_name_to_handle_at
+# elif defined(__powerpc__)
# define __NR_name_to_handle_at 345
-# endif
-#else
-# ifndef __NR_name_to_handle_at
-# error __NR_name_to_handle_at is not defined
+# else
+# error "__NR_name_to_handle_at is not defined"
# endif
#endif
diff --git a/src/libudev/util.h b/src/libudev/util.h
index 15a11cc537..5e699ca5a8 100644
--- a/src/libudev/util.h
+++ b/src/libudev/util.h
@@ -32,6 +32,7 @@
#include <unistd.h>
#include <sys/socket.h>
+#include "missing.h"
#include "config.h"
#if SIZEOF_PID_T == 4
diff --git a/src/udev/udev-builtin-btrfs.c b/src/udev/udev-builtin-btrfs.c
index 4e80a1d1d1..49fa16559f 100644
--- a/src/udev/udev-builtin-btrfs.c
+++ b/src/udev/udev-builtin-btrfs.c
@@ -24,15 +24,13 @@
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
+#ifdef HAVE_LINUX_BTRFS_H
+#include <linux/btrfs.h>
+#endif
+#include "missing.h"
#include "udev.h"
-#define BTRFS_PATH_NAME_MAX 4087
-struct btrfs_ioctl_vol_args {
- int64_t fd;
- char name[BTRFS_PATH_NAME_MAX + 1];
-};
-#define BTRFS_IOCTL_MAGIC 0x94
#define BTRFS_IOC_DEVICES_READY _IOR(BTRFS_IOCTL_MAGIC, 39, struct btrfs_ioctl_vol_args)
static int builtin_btrfs(struct udev_device *dev, int argc, char *argv[], bool test) {