summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2014-08-05 08:32:35 -0400
committerAnthony G. Basile <blueness@gentoo.org>2014-08-05 08:32:35 -0400
commitba3e123a228142da43902fda5f63b1cf7cd7d96d (patch)
tree6f3aedae504f6bbb73cf36ffde4ec273233cb3b8
parent93bc913f142b42a481ca0466ebf31228e1132cdb (diff)
Include missing.h in udev-builtin-btrfs.c, and move BTRFS_IOC_DEVICES_READY to missing.h
This is a combination of upstream commits dced15575f7bf172e3c9d798c43477539525558c 7bed7f0e3b1f9596aedb64657e432e5b267adebb by Simon McVittie <simon.mcvittie@collabora.co.uk> 7bed7f0e3b1f9596aedb64657e432e5b267adebb Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
-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) {