From ba3e123a228142da43902fda5f63b1cf7cd7d96d Mon Sep 17 00:00:00 2001 From: "Anthony G. Basile" Date: Tue, 5 Aug 2014 08:32:35 -0400 Subject: 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 7bed7f0e3b1f9596aedb64657e432e5b267adebb Signed-off-by: Anthony G. Basile --- src/libudev/missing.h | 105 ++++++++++++++++++++++++++++++++++-------- src/libudev/util.h | 1 + src/udev/udev-builtin-btrfs.c | 10 ++-- 3 files changed, 91 insertions(+), 25 deletions(-) (limited to 'src') 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 #include +#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 #include #include +#ifdef HAVE_LINUX_BTRFS_H +#include +#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) { -- cgit v1.2.3-54-g00ecf