--- 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;
