diff options
Diffstat (limited to 'sys-fs/btrfs-progs/files/btrfs-progs-0.18-apple.patch')
-rw-r--r-- | sys-fs/btrfs-progs/files/btrfs-progs-0.18-apple.patch | 319 |
1 files changed, 319 insertions, 0 deletions
diff --git a/sys-fs/btrfs-progs/files/btrfs-progs-0.18-apple.patch b/sys-fs/btrfs-progs/files/btrfs-progs-0.18-apple.patch new file mode 100644 index 0000000..8770fa9 --- /dev/null +++ b/sys-fs/btrfs-progs/files/btrfs-progs-0.18-apple.patch @@ -0,0 +1,319 @@ +--- btrfs-image.c.orig 2009-02-15 14:49:17.000000000 +0100 ++++ btrfs-image.c 2009-02-15 12:42:10.000000000 +0100 +@@ -249,7 +249,7 @@ + static int metadump_init(struct metadump_struct *md, struct btrfs_root *root, + FILE *out, int num_threads, int compress_level) + { +- int i, ret; ++ int i, ret = 0; + + memset(md, 0, sizeof(*md)); + pthread_cond_init(&md->cond, NULL); +@@ -608,7 +608,11 @@ + if (async->start == BTRFS_SUPER_INFO_OFFSET) + update_super(outbuf); + ++#ifdef __APPLE__ ++ ret = pwrite(outfd, outbuf, size, async->start); ++#else + ret = pwrite64(outfd, outbuf, size, async->start); ++#endif + BUG_ON(ret != size); + + pthread_mutex_lock(&mdres->mutex); +@@ -834,7 +838,9 @@ + } + + if (num_threads == 0 && compress_level > 0) { ++#ifdef _SC_NPROCESSORS_ONLN + num_threads = sysconf(_SC_NPROCESSORS_ONLN); ++#endif + if (num_threads <= 0) + num_threads = 1; + } +--- btrfsck.c.orig 2009-02-15 14:40:07.000000000 +0100 ++++ btrfsck.c 2009-02-15 12:32:04.000000000 +0100 +@@ -21,6 +21,9 @@ + #include <stdio.h> + #include <stdlib.h> + #include <fcntl.h> ++ ++#include <sys/stat.h> ++ + #include "kerncompat.h" + #include "ctree.h" + #include "disk-io.h" +--- disk-io.c.orig 2009-02-15 13:35:46.000000000 +0100 ++++ disk-io.c 2009-02-14 20:41:42.000000000 +0100 +@@ -143,7 +143,11 @@ + device = multi->stripes[0].dev; + device->total_ios++; + blocksize = min(blocksize, (u32)(64 * 1024)); ++#ifdef __APPLE__ ++ read(device->fd, &multi->stripes[0].physical, blocksize); ++#else + readahead(device->fd, multi->stripes[0].physical, blocksize); ++#endif + kfree(multi); + return 0; + } +@@ -699,7 +703,11 @@ + u64 bytenr; + + if (sb_bytenr != BTRFS_SUPER_INFO_OFFSET) { ++#ifdef __APPLE__ ++ ret = pread(fd, &buf, sizeof(buf), sb_bytenr); ++#else + ret = pread64(fd, &buf, sizeof(buf), sb_bytenr); ++#endif + if (ret < sizeof(buf)) + return -1; + +@@ -714,7 +722,11 @@ + + for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) { + bytenr = btrfs_sb_offset(i); ++#ifdef __APPLE__ ++ ret = pread(fd, &buf, sizeof(buf), bytenr); ++#else + ret = pread64(fd, &buf, sizeof(buf), bytenr); ++#endif + if (ret < sizeof(buf)) + break; + +@@ -747,8 +759,13 @@ + BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE); + btrfs_csum_final(crc, (char *)&sb->csum[0]); + ++#ifdef __APPLE__ ++ ret = pwrite(device->fd, sb, BTRFS_SUPER_INFO_SIZE, ++ root->fs_info->super_bytenr); ++#else + ret = pwrite64(device->fd, sb, BTRFS_SUPER_INFO_SIZE, + root->fs_info->super_bytenr); ++#endif + BUG_ON(ret != BTRFS_SUPER_INFO_SIZE); + return 0; + } +@@ -765,7 +782,11 @@ + BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE); + btrfs_csum_final(crc, (char *)&sb->csum[0]); + ++#ifdef __APPLE__ ++ ret = pwrite(device->fd, sb, BTRFS_SUPER_INFO_SIZE, bytenr); ++#else + ret = pwrite64(device->fd, sb, BTRFS_SUPER_INFO_SIZE, bytenr); ++#endif + BUG_ON(ret != BTRFS_SUPER_INFO_SIZE); + } + return 0; +--- extent-tree.c.orig 2009-02-15 13:39:33.000000000 +0100 ++++ extent-tree.c 2009-02-14 20:43:40.000000000 +0100 +@@ -2564,7 +2564,7 @@ + u64 total_metadata = 0; + u64 chunk_objectid; + int ret; +- int bit; ++ int bit = 0; + struct btrfs_root *extent_root; + struct btrfs_block_group_cache *cache; + struct extent_io_tree *block_group_cache; +--- file-item.c.orig 2009-02-15 13:41:47.000000000 +0100 ++++ file-item.c 2009-02-14 20:44:17.000000000 +0100 +@@ -193,7 +193,7 @@ + struct btrfs_root *root, u64 alloc_end, + u64 bytenr, char *data, size_t len) + { +- int ret; ++ int ret = 0; + struct btrfs_key file_key; + struct btrfs_key found_key; + u64 next_offset = (u64)-1; +--- ioctl.h.orig 2009-02-15 13:46:49.000000000 +0100 ++++ ioctl.h 2009-02-15 13:48:54.000000000 +0100 +@@ -18,15 +18,23 @@ + + #ifndef __IOCTL_ + #define __IOCTL_ ++#ifndef __APPLE__ + #include <asm/types.h> + #include <linux/ioctl.h> ++#endif ++ ++#include <stdint.h> + + #define BTRFS_IOCTL_MAGIC 0x94 + #define BTRFS_VOL_NAME_MAX 255 + #define BTRFS_PATH_NAME_MAX 4087 + + struct btrfs_ioctl_vol_args { ++#ifdef __APPLE__ ++ int64_t fd; ++#else + __s64 fd; ++#endif + char name[BTRFS_PATH_NAME_MAX + 1]; + }; + +--- kerncompat.h.orig 2009-02-15 13:25:46.000000000 +0100 ++++ kerncompat.h 2009-02-15 13:28:49.000000000 +0100 +@@ -22,8 +22,13 @@ + #include <stdlib.h> + #include <errno.h> + #include <string.h> ++#ifdef __APPLE__ ++#include <stdint.h> ++#include <libkern/OSByteOrder.h> ++#else + #include <endian.h> + #include <byteswap.h> ++#endif + #include <assert.h> + + #ifndef READ +@@ -42,7 +47,7 @@ + #define GFP_NOFS 0 + #define __read_mostly + #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +-#define ULONG_MAX (~0UL) ++//#define ULONG_MAX (~0UL) + #define BUG() abort() + #ifdef __CHECKER__ + #define __force __attribute__((force)) +@@ -53,11 +58,18 @@ + #endif + + #ifndef __CHECKER__ ++#ifdef __APPLE__ ++typedef uint32_t u32; ++typedef uint64_t u64; ++typedef uint16_t u16; ++typedef uint8_t u8; ++#else + #include <asm/types.h> + typedef __u32 u32; + typedef __u64 u64; + typedef __u16 u16; + typedef __u8 u8; ++#endif /* __APPLE__ */ + #else + typedef unsigned int u32; + typedef unsigned int __u32; +@@ -236,12 +248,21 @@ + #define __le8 u8 + + #if __BYTE_ORDER == __BIG_ENDIAN ++#ifdef __APPLE__ ++#define cpu_to_le64(x) ((__force __le64)(u64)(OSSwapHostToLittleInt64(x))) ++#define le64_to_cpu(x) ((__force u64)(__le64)(OSSwapLittleToHostInt64(x))) ++#define cpu_to_le32(x) ((__force __le32)(u32)(OSSwapHostToLittleInt32(x))) ++#define le32_to_cpu(x) ((__force u32)(__le32)(OSSwapLittleToHostInt32(x))) ++#define cpu_to_le16(x) ((__force __le16)(u16)(OSSwapHostToLittleInt16(x))) ++#define le16_to_cpu(x) ((__force u16)(__le16)(OSSwapLittleToHostInt16(x))) ++#else + #define cpu_to_le64(x) ((__force __le64)(u64)(bswap_64(x))) + #define le64_to_cpu(x) ((__force u64)(__le64)(bswap_64(x))) + #define cpu_to_le32(x) ((__force __le32)(u32)(bswap_32(x))) + #define le32_to_cpu(x) ((__force u32)(__le32)(bswap_32(x))) + #define cpu_to_le16(x) ((__force __le16)(u16)(bswap_16(x))) + #define le16_to_cpu(x) ((__force u16)(__le16)(bswap_16(x))) ++#endif /* __APPLE__ */ + #else + #define cpu_to_le64(x) ((__force __le64)(u64)(x)) + #define le64_to_cpu(x) ((__force u64)(__le64)(x)) +--- list.h.orig 2009-02-15 13:57:31.000000000 +0100 ++++ list.h 2009-02-14 20:55:04.000000000 +0100 +@@ -38,7 +38,7 @@ + + #define LIST_HEAD_INIT(name) { &(name), &(name) } + +-#define LIST_HEAD(name) \ ++#define BTRFS_LIST_HEAD(name) \ + struct list_head name = LIST_HEAD_INIT(name) + + static inline void INIT_LIST_HEAD(struct list_head *list) +--- mkfs.c.orig 2009-02-15 14:42:49.000000000 +0100 ++++ mkfs.c 2009-02-15 14:47:19.000000000 +0100 +@@ -18,6 +18,7 @@ + + #define _XOPEN_SOURCE 500 + #define _GNU_SOURCE ++#define _DARWIN_C_SOURCE + + #ifndef __CHECKER__ + #include <sys/ioctl.h> +@@ -33,7 +34,9 @@ + #include <unistd.h> + #include <getopt.h> + #include <uuid/uuid.h> ++#ifndef __APPLE__ + #include <linux/fs.h> ++#endif + #include <ctype.h> + #include "kerncompat.h" + #include "ctree.h" +--- utils.c.orig 2009-02-15 13:52:25.000000000 +0100 ++++ utils.c 2009-02-15 13:53:35.000000000 +0100 +@@ -18,6 +18,7 @@ + + #define _XOPEN_SOURCE 600 + #define __USE_XOPEN2K ++#define _DARWIN_C_SOURCE + #include <stdio.h> + #include <stdlib.h> + #ifndef __CHECKER__ +@@ -30,7 +31,13 @@ + #include <dirent.h> + #include <fcntl.h> + #include <unistd.h> ++#ifdef __APPLE__ ++#include <sys/disk.h> ++#else + #include <mntent.h> ++#endif ++ ++ + #include "kerncompat.h" + #include "radix-tree.h" + #include "ctree.h" +@@ -393,7 +400,11 @@ + if (!S_ISBLK(st->st_mode)) { + return 0; + } ++#ifdef __APPLE__ ++ if (ioctl(fd, DKIOCGETBLOCKCOUNT, &size) >= 0) { ++#else + if (ioctl(fd, BLKGETSIZE64, &size) >= 0) { ++#endif + return size; + } + return 0; +@@ -594,6 +605,9 @@ + */ + int check_mounted(char *file) + { ++#ifdef __APPLE__ ++ return 0; ++#else + struct mntent *mnt; + struct stat st_buf; + dev_t file_dev = 0; +@@ -638,6 +652,7 @@ + + endmntent (f); + return ret; ++#endif + } + + struct pending_dir { +--- volumes.c.orig 2009-02-15 14:02:34.000000000 +0100 ++++ volumes.c 2009-02-14 20:55:25.000000000 +0100 +@@ -50,7 +50,7 @@ + #define map_lookup_size(n) (sizeof(struct map_lookup) + \ + (sizeof(struct btrfs_bio_stripe) * (n))) + +-static LIST_HEAD(fs_uuids); ++static BTRFS_LIST_HEAD(fs_uuids); + + static struct btrfs_device *__find_device(struct list_head *head, u64 devid, + u8 *uuid) |