summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Wilcox <AWilcox@Wilcox-Tech.com>2016-01-24 03:43:33 -0600
committerAndrew Wilcox <AWilcox@Wilcox-Tech.com>2016-01-24 03:43:33 -0600
commit897095052aabbe5e1173489e2e2e95ab7fc8b1f9 (patch)
tree018df398ac28a65df4a1f98d14f9339c51898d6f
parentce08c4a8bed21dd61229556b105dc1d4c779d607 (diff)
downloadpackages-897095052aabbe5e1173489e2e2e95ab7fc8b1f9.tar.gz
packages-897095052aabbe5e1173489e2e2e95ab7fc8b1f9.tar.bz2
packages-897095052aabbe5e1173489e2e2e95ab7fc8b1f9.tar.xz
packages-897095052aabbe5e1173489e2e2e95ab7fc8b1f9.zip
sys-fs/mac-fdisk: Apple *smh*
-rw-r--r--profiles/categories1
-rw-r--r--sys-fs/mac-fdisk/Manifest2
-rw-r--r--sys-fs/mac-fdisk/files/mac-fdisk-0.1-headers.patch112
-rw-r--r--sys-fs/mac-fdisk/files/mac-fdisk-0.1-r6-ppc64.patch481
-rw-r--r--sys-fs/mac-fdisk/files/mac-fdisk-0.1_p16-ppc64.patch455
-rw-r--r--sys-fs/mac-fdisk/files/mac-fdisk-amd64.patch190
-rw-r--r--sys-fs/mac-fdisk/files/mac-fdisk-large-disk-support.patch80
-rw-r--r--sys-fs/mac-fdisk/files/mac-fdisk-largerthan2gb.patch14
-rw-r--r--sys-fs/mac-fdisk/files/mac-fdisk-non-glibc-support.patch14
-rw-r--r--sys-fs/mac-fdisk/mac-fdisk-0.1_p16.ebuild49
-rw-r--r--sys-fs/mac-fdisk/metadata.xml4
11 files changed, 1402 insertions, 0 deletions
diff --git a/profiles/categories b/profiles/categories
index 87d68ddeb..2d86aa7b5 100644
--- a/profiles/categories
+++ b/profiles/categories
@@ -1,3 +1,4 @@
dev-libs
sys-apps
+sys-fs
virtual
diff --git a/sys-fs/mac-fdisk/Manifest b/sys-fs/mac-fdisk/Manifest
new file mode 100644
index 000000000..60cdbee76
--- /dev/null
+++ b/sys-fs/mac-fdisk/Manifest
@@ -0,0 +1,2 @@
+DIST mac-fdisk_0.1-16.diff.gz 19896 SHA256 0ab4247a80734cffcebd439b2c6021a5560daf4d5bb246af3ee0a75d52bfd486 SHA512 deb44217afae097594e14dea6cd128f6cb1e8ed6e62e646d2aa311508ea27d164c94187e8eb1f1d018ee6044346f6785770981a655b6ad536dbbce550df13359 WHIRLPOOL 5f34bdc9ef8e0b823e5113cf79ddc2e9007f5e18c90c7c162e025e65c349407baf7f0da9aae4a5d1615af87ab3b2cade65265aef88d7413625a44c8a531b426c
+DIST mac-fdisk_0.1.orig.tar.gz 55817 SHA256 7059fc4ba41ca2ef857e1092e9c56e910f27693d407b5c3d78f7102ad0c56a66 SHA512 1263e60a18111162f5ef439b5f9615cef9de94e7836cb998782a6e6d3bcf92a69e49566b33c7330bdea05de5e6ca83f7920c6707f342ce515440160695f07120 WHIRLPOOL 3a25aba4950933c677d56a1f8c8aa000520818cf413c3cf3f418be5ec2ad520f9d9542771b61b2e53ad58e4dfa3298acab551eef8fb1a0cbac93a390f9968bb4
diff --git a/sys-fs/mac-fdisk/files/mac-fdisk-0.1-headers.patch b/sys-fs/mac-fdisk/files/mac-fdisk-0.1-headers.patch
new file mode 100644
index 000000000..2ac7eaf41
--- /dev/null
+++ b/sys-fs/mac-fdisk/files/mac-fdisk-0.1-headers.patch
@@ -0,0 +1,112 @@
+Include a lot more headers and remove a bunch of braindead __linux__ checks
+
+--- a/dump.c
++++ b/dump.c
+@@ -30,10 +30,8 @@
+ */
+
+ #include <stdio.h>
+-#ifndef __linux__
+ #include <stdlib.h>
+ #include <unistd.h>
+-#endif
+ #include <string.h>
+ #include <errno.h>
+ #include <fcntl.h>
+--- a/errors.c
++++ b/errors.c
+@@ -26,9 +26,7 @@
+ */
+
+ #include <stdio.h>
+-#ifndef __linux__
+ #include <stdlib.h>
+-#endif
+ #include <string.h>
+ #include <stdarg.h>
+
+@@ -115,8 +113,8 @@
+ va_end(ap);
+
+ #ifdef __linux__
+- if (value > 0 && value < sys_nerr) {
+- fprintf(stderr, " (%s)\n", sys_errlist[value]);
++ if (value > 0) {
++ fprintf(stderr, " (%s)\n", strerror(value));
+ } else {
+ fprintf(stderr, "\n");
+ }
+@@ -144,8 +142,8 @@
+ va_end(ap);
+
+ #ifdef __linux__
+- if (value > 0 && value < sys_nerr) {
+- fprintf(stderr, " (%s)\n", sys_errlist[value]);
++ if (value > 0) {
++ fprintf(stderr, " (%s)\n", strerror(value));
+ } else {
+ fprintf(stderr, "\n");
+ }
+--- a/fdisk.c
++++ b/fdisk.c
+@@ -62,6 +62,7 @@
+ #include <unistd.h>
+ #include <stdio.h>
+ #include <stdlib.h>
++#include <string.h>
+ #include <fcntl.h>
+ #include <ctype.h>
+ #include <setjmp.h>
+--- a/fdisklabel.c
++++ b/fdisklabel.c
+@@ -38,6 +38,7 @@
+ #include <unistd.h>
+ #include <stdio.h>
+ #include <stdlib.h>
++#include <string.h>
+ #include <fcntl.h>
+ #include <ctype.h>
+ #include <setjmp.h>
+--- a/io.c
++++ b/io.c
+@@ -26,9 +26,9 @@
+ */
+
+ #include <stdio.h>
+-#ifndef __linux__
+ #include <stdlib.h>
+ #include <fcntl.h>
++#ifndef __linux__
+ #include <SCSI.h>
+ #else
+ #ifdef __GLIBC__
+--- a/partition_map.c
++++ b/partition_map.c
+@@ -26,10 +26,9 @@
+ */
+
+ #include <stdio.h>
+-#ifndef __linux__
++#include <string.h>
+ #include <stdlib.h>
+ #include <unistd.h>
+-#endif
+ #include <errno.h>
+
+ #include <fcntl.h>
+--- a/pdisk.c
++++ b/pdisk.c
+@@ -32,10 +32,11 @@
+ #include <getopt.h>
+ #include <stddef.h>
+ #else
+-#include <stdlib.h>
+-#include <unistd.h>
+ #include <SIOUX.h>
+ #endif
++#include <stdlib.h>
++#include <unistd.h>
++#include <string.h>
+ #include <errno.h>
+
+ #ifdef __linux__
diff --git a/sys-fs/mac-fdisk/files/mac-fdisk-0.1-r6-ppc64.patch b/sys-fs/mac-fdisk/files/mac-fdisk-0.1-r6-ppc64.patch
new file mode 100644
index 000000000..4fb1617ee
--- /dev/null
+++ b/sys-fs/mac-fdisk/files/mac-fdisk-0.1-r6-ppc64.patch
@@ -0,0 +1,481 @@
+--- a/bitfield.c
++++ b/bitfield.c
+@@ -67,13 +67,12 @@
+ //
+ // Routines
+ //
+-unsigned long
+-bitfield_set(unsigned long *bf, int base, int length, unsigned long value)
++unsigned int
++bitfield_set(unsigned int *bf, int base, int length, unsigned int value)
+ {
+- unsigned long t;
+- unsigned long m;
++ unsigned int t;
++ unsigned int m;
+ int s;
+- int i;
+
+ // compute shift & mask, coerce value to correct number of bits,
+ // zap the old bits and stuff the new value
+@@ -86,12 +85,11 @@
+ }
+
+
+-unsigned long
+-bitfield_get(unsigned long bf, int base, int length)
++unsigned int
++bitfield_get(unsigned int bf, int base, int length)
+ {
+- unsigned long m;
++ unsigned int m;
+ int s;
+- int i;
+
+ // compute shift & mask
+ // return the correct number of bits (shifted to low end)
+--- a/bitfield.h
++++ b/bitfield.h
+@@ -63,5 +63,5 @@
+ //
+ // Forward declarations
+ //
+-unsigned long bitfield_set(unsigned long *bf, int base, int length, unsigned long value);
+-unsigned long bitfield_get(unsigned long bf, int base, int length);
++unsigned int bitfield_set(unsigned int *bf, int base, int length, unsigned int value);
++unsigned int bitfield_get(unsigned int bf, int base, int length);
+--- a/dpme.h
++++ b/dpme.h
+@@ -61,7 +61,7 @@
+ //
+ typedef unsigned char u8;
+ typedef unsigned short u16;
+-typedef unsigned long u32;
++typedef unsigned int u32;
+
+
+ // Physical block zero of the disk has this format
+@@ -113,10 +113,10 @@
+ #endif
+ u32 dpme_boot_block ;
+ u32 dpme_boot_bytes ;
+- u8 *dpme_load_addr ;
+- u8 *dpme_load_addr_2 ;
+- u8 *dpme_goto_addr ;
+- u8 *dpme_goto_addr_2 ;
++ u32 dpme_load_addr ;
++ u32 dpme_load_addr_2 ;
++ u32 dpme_goto_addr ;
++ u32 dpme_goto_addr_2 ;
+ u32 dpme_checksum ;
+ char dpme_process_id[16] ;
+ u32 dpme_boot_args[32] ;
+--- a/dump.c
++++ b/dump.c
+@@ -61,16 +61,16 @@
+ // Global Constants
+ //
+ NAMES plist[] = {
+- "Drvr", "Apple_Driver",
+- "Dr43", "Apple_Driver43",
+- "Free", "Apple_Free",
+- " HFS", "Apple_HFS",
+- " MFS", "Apple_MFS",
+- "PDOS", "Apple_PRODOS",
+- "junk", "Apple_Scratch",
+- "unix", "Apple_UNIX_SVR2",
+- " map", "Apple_partition_map",
+- 0, 0
++ {"Drvr"}, {"Apple_Driver"},
++ {"Dr43"}, {"Apple_Driver43"},
++ {"Free"}, {"Apple_Free"},
++ {" HFS"}, {"Apple_HFS"},
++ {" MFS"}, {"Apple_MFS"},
++ {"PDOS"}, {"Apple_PRODOS"},
++ {"junk"}, {"Apple_Scratch"},
++ {"unix"}, {"Apple_UNIX_SVR2"},
++ {" map"}, {"Apple_partition_map"},
++ {0}, {0}
+ };
+
+ const char * kStringEmpty = "";
+@@ -162,10 +162,10 @@
+ }
+ #ifdef __mc68000__
+ printf("%*s type name "
+- "%*s %-*s ( size ) system\n", strlen(map->name)+1, "#", j, "length", j, "base");
++ "%*s %-*s ( size ) system\n", (int)strlen(map->name)+1, "#", j, "length", j, "base");
+ #else
+ printf("%*s type name "
+- "%*s %-*s ( size ) system\n", strlen(map->name)+1, "#", j, "length", j, "base");
++ "%*s %-*s ( size ) system\n", (int)strlen(map->name)+1, "#", j, "length", j, "base");
+ #endif
+
+ /* Grok devfs names. (courtesy Colin Walters)*/
+@@ -199,7 +199,6 @@
+ partition_map_header *map;
+ int j;
+ DPME *p;
+- BZB *bp;
+ char *s;
+ #ifdef __mc68000__
+ int aflag = 1;
+@@ -222,13 +221,13 @@
+ }
+ }
+ #ifdef __mc68000__
+- printf("%s%-2d %.4s %-12.12s ", dev, entry->disk_address, s, p->dpme_name);
++ printf("%s%-2d %.4s %-12.12s ", dev, (int)entry->disk_address, s, p->dpme_name);
+ #else
+- printf("%s%-4d %.4s %-18.32s ", dev, entry->disk_address, s, p->dpme_name);
++ printf("%s%-4d %.4s %-18.32s ", dev, (int)entry->disk_address, s, p->dpme_name);
+ #endif
+ } else {
+ printf("%s%-4d %20.32s %-18.32s ", dev,
+- entry->disk_address, p->dpme_type, p->dpme_name);
++ (int)entry->disk_address, p->dpme_type, p->dpme_name);
+ }
+
+ if (pflag) {
+@@ -312,7 +311,6 @@
+ int i;
+ int fd;
+ DPME * data;
+- long t;
+
+ data = (DPME *) malloc(PBLOCK_SIZE);
+ if (data == NULL) {
+@@ -380,7 +378,7 @@
+ printf("Header:\n");
+ printf("fd=%d (%s)\n", map->fd, (map->regular_file)?"file":"device");
+ printf("map %d blocks out of %d, media %u blocks\n",
+- map->blocks_in_map, map->maximum_in_map, map->media_size);
++ map->blocks_in_map, map->maximum_in_map, (unsigned int)map->media_size);
+ printf("Map is%s writeable", (map->writeable)?kStringEmpty:kStringNot);
+ printf(", but%s changed\n", (map->changed)?kStringEmpty:kStringNot);
+ printf("\n");
+@@ -424,7 +422,7 @@
+ for (entry = map->disk_order; entry != NULL; entry = entry->next_on_disk) {
+ p = entry->data;
+ printf("%2d: %20.32s ",
+- entry->disk_address, p->dpme_type);
++ (int)entry->disk_address, p->dpme_type);
+ printf("%7u @ %-7u ", p->dpme_pblocks, p->dpme_pblock_start);
+ printf("%c%c%c%c%c%c%c%c%c%c ",
+ (dpme_valid_get(p))?'V':'v',
+@@ -447,7 +445,7 @@
+ "goto_address checksum processor\n");
+ for (entry = map->disk_order; entry != NULL; entry = entry->next_on_disk) {
+ p = entry->data;
+- printf("%2d: ", entry->disk_address);
++ printf("%2d: ", (int)entry->disk_address);
+ printf("%7u ", p->dpme_boot_block);
+ printf("%7u ", p->dpme_boot_bytes);
+ printf("%8x ", p->dpme_load_addr);
+@@ -464,7 +462,7 @@
+ */
+ for (entry = map->disk_order; entry != NULL; entry = entry->next_on_disk) {
+ p = entry->data;
+- printf("%2d: ", entry->disk_address);
++ printf("%2d: ", (int)entry->disk_address);
+
+ bp = (BZB *) (p->dpme_bzb);
+ j = -1;
+--- a/errors.c
++++ b/errors.c
+@@ -30,6 +30,7 @@
+ #include <string.h>
+ #include <stdarg.h>
+
++#include <errno.h>
+ #include "errors.h"
+ #include "pdisk.h"
+
+@@ -113,7 +114,7 @@
+ va_end(ap);
+
+ #ifdef __linux__
+- if (value > 0) {
++ if (value > 0 && value < errno) {
+ fprintf(stderr, " (%s)\n", strerror(value));
+ } else {
+ fprintf(stderr, "\n");
+@@ -142,7 +143,7 @@
+ va_end(ap);
+
+ #ifdef __linux__
+- if (value > 0) {
++ if (value > 0 && value < errno) {
+ fprintf(stderr, " (%s)\n", strerror(value));
+ } else {
+ fprintf(stderr, "\n");
+--- a/fdisk.c
++++ b/fdisk.c
+@@ -71,12 +71,65 @@
+
+ #include <sys/ioctl.h>
+
+-typedef unsigned short kdev_t; /* BAD hack; kdev_t is not exported */
+-
+ #include "kernel-defs.h"
+
+ #include "fdisk.h"
+
++/* ----------- */
++#define _PPC64_TYPES_H
++#define BITS_PER_LONG 64
++
++typedef __signed__ char __s8;
++typedef signed char s8;
++typedef unsigned char u8;
++typedef unsigned char __u8;
++
++typedef __signed__ short __s16;
++typedef signed short s16;
++/*typedef unsigned short __u16;*/
++typedef unsigned short u16;
++
++typedef __signed__ int __s32;
++typedef signed int s32;
++/*typedef unsigned int __u32;*/
++typedef unsigned int u32;
++
++typedef __signed__ long __s64;
++typedef signed long s64;
++typedef unsigned long __u64;
++typedef unsigned long u64;
++
++typedef struct {
++ __u32 u[4];
++} __attribute((aligned(16))) __vector128;
++
++typedef __vector128 vector128;
++
++typedef u32 dma_addr_t;
++typedef u64 dma64_addr_t;
++
++typedef struct {
++ unsigned long entry;
++ unsigned long toc;
++ unsigned long env;
++} func_descr_t;
++
++typedef unsigned int umode_t;
++
++#define BITS_TO_LONGS(bits) \
++ (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG)
++#define DECLARE_BITMAP(name,bits) \
++ unsigned long name[BITS_TO_LONGS(bits)]
++#define CLEAR_BITMAP(name,bits) \
++ memset(name, 0, BITS_TO_LONGS(bits)*sizeof(unsigned long))
++
++/* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x030n/0x031n */
++#define HDIO_GETGEO 0x0301 /* get device geometry */
++
++#define BLKRRPART _IO(0x12,95) /* re-read partition table */
++
++/* ---------- */
++
+ #define hex_val(c) ({ \
+ char _c = (c); \
+ isdigit(_c) ? _c - '0' : \
+@@ -1416,7 +1469,7 @@
+ }
+ }
+
+-void main(int argc, char **argv)
++int main(int argc, char **argv)
+ {
+ if (argc > 3)
+ fatal(usage);
+--- a/fdisklabel.c
++++ b/fdisklabel.c
+@@ -35,6 +35,7 @@
+ SUCH DAMAGE.
+ */
+
++#include <sys/types.h>
+ #include <unistd.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+@@ -47,6 +48,8 @@
+ #include <sys/ioctl.h>
+ #include <sys/param.h>
+
++#include <asm/types.h>
++
+ #include "kernel-defs.h"
+
+ #include "fdisk.h"
+@@ -263,8 +266,8 @@
+ fprintf(f, "type: %s\n", bsd_dktypenames[lp->d_type]);
+ else
+ fprintf(f, "type: %d\n", lp->d_type);
+- fprintf(f, "disk: %.*s\n", sizeof(lp->d_typename), lp->d_typename);
+- fprintf(f, "label: %.*s\n", sizeof(lp->d_packname), lp->d_packname);
++ fprintf(f, "disk: %.*s\n", (int)sizeof(lp->d_typename), lp->d_typename);
++ fprintf(f, "label: %.*s\n", (int)sizeof(lp->d_packname), lp->d_packname);
+ fprintf(f, "flags:");
+ if (lp->d_flags & BSD_D_REMOVABLE)
+ fprintf(f, " removable");
+@@ -273,17 +276,17 @@
+ if (lp->d_flags & BSD_D_BADSECT)
+ fprintf(f, " badsect");
+ fprintf(f, "\n");
+- fprintf(f, "bytes/sector: %d\n", lp->d_secsize);
+- fprintf(f, "sectors/track: %d\n", lp->d_nsectors);
+- fprintf(f, "tracks/cylinder: %d\n", lp->d_ntracks);
+- fprintf(f, "sectors/cylinder: %d\n", lp->d_secpercyl);
+- fprintf(f, "cylinders: %d\n", lp->d_ncylinders);
++ fprintf(f, "bytes/sector: %d\n", (int)lp->d_secsize);
++ fprintf(f, "sectors/track: %d\n", (int)lp->d_nsectors);
++ fprintf(f, "tracks/cylinder: %d\n", (int)lp->d_ntracks);
++ fprintf(f, "sectors/cylinder: %d\n", (int)lp->d_secpercyl);
++ fprintf(f, "cylinders: %d\n", (int)lp->d_ncylinders);
+ fprintf(f, "rpm: %d\n", lp->d_rpm);
+ fprintf(f, "interleave: %d\n", lp->d_interleave);
+ fprintf(f, "trackskew: %d\n", lp->d_trackskew);
+ fprintf(f, "cylinderskew: %d\n", lp->d_cylskew);
+- fprintf(f, "headswitch: %d\t\t# milliseconds\n", lp->d_headswitch);
+- fprintf(f, "track-to-track seek: %d\t# milliseconds\n", lp->d_trkseek);
++ fprintf(f, "headswitch: %d\t\t# milliseconds\n", (int)lp->d_headswitch);
++ fprintf(f, "track-to-track seek: %d\t# milliseconds\n", (int)lp->d_trkseek);
+ fprintf(f, "drivedata: ");
+ for (i = NDDATA - 1; i >= 0; i--)
+ if (lp->d_drivedata[i])
+@@ -291,7 +294,7 @@
+ if (i < 0)
+ i = 0;
+ for (j = 0; j <= i; j++)
+- fprintf(f, "%d ", lp->d_drivedata[j]);
++ fprintf(f, "%d ", (int)lp->d_drivedata[j]);
+ }
+ fprintf (f, "\n%d partitions:\n", lp->d_npartitions);
+ fprintf (f, "# size offset fstype [fsize bsize cpg]\n");
+@@ -299,7 +302,7 @@
+ for (i = 0; i < lp->d_npartitions; i++, pp++) {
+ if (pp->p_size) {
+ fprintf(f, " %c: %8d %8d ", 'a' + i,
+- pp->p_size, pp->p_offset);
++ (int)pp->p_size, (int)pp->p_offset);
+ if ((unsigned) pp->p_fstype < BSD_FSMAXTYPES)
+ fprintf(f, "%8.8s", bsd_fstypes[pp->p_fstype].name);
+ else
+@@ -308,12 +311,12 @@
+ {
+ case BSD_FS_UNUSED:
+ fprintf(f, " %5d %5d %5.5s ",
+- pp->p_fsize, pp->p_fsize * pp->p_frag, "");
++ (int)pp->p_fsize, (int)pp->p_fsize * pp->p_frag, "");
+ break;
+
+ case BSD_FS_BSDFFS:
+ fprintf(f, " %5d %5d %5d ",
+- pp->p_fsize, pp->p_fsize * pp->p_frag,
++ (int)pp->p_fsize, (int)pp->p_fsize * pp->p_frag,
+ pp->p_cpg);
+ break;
+
+@@ -323,21 +326,21 @@
+ }
+ fprintf(f, "\t# (Cyl. %4d",
+ #if 0
+- pp->p_offset / lp->d_secpercyl); /* differs from Linux fdisk */
++ (int)(pp->p_offset / lp->d_secpercyl)); /* differs from Linux fdisk */
+ #else
+- pp->p_offset / lp->d_secpercyl + 1);
++ (int)(pp->p_offset / lp->d_secpercyl + 1));
+ #endif
+ if (pp->p_offset % lp->d_secpercyl)
+ putc('*', f);
+ else
+ putc(' ', f);
+ fprintf(f, "- %d",
+- (pp->p_offset +
++ (int)((pp->p_offset +
+ pp->p_size + lp->d_secpercyl - 1) /
+ #if 0
+- lp->d_secpercyl - 1); /* differs from Linux fdisk */
++ lp->d_secpercyl - 1)); /* differs from Linux fdisk */
+ #else
+- lp->d_secpercyl);
++ lp->d_secpercyl));
+ #endif
+ if (pp->p_size % lp->d_secpercyl)
+ putc('*', f);
+--- a/io.c
++++ b/io.c
+@@ -33,8 +33,10 @@
+ #else
+ #ifdef __GLIBC__
+ #include <sys/types.h>
++#include <sys/stat.h>
+ #endif
+ #endif
++#include <linux/unistd.h>
+ #include <unistd.h>
+ #include <string.h>
+ #include <stdarg.h>
+@@ -466,7 +468,7 @@
+ long t;
+
+ if (rflag) {
+- printf("Can't write block %u to file", num);
++ printf("Can't write block %u to file", (unsigned int)num);
+ return 0;
+ }
+ #ifndef __linux__
+--- a/partition_map.c
++++ b/partition_map.c
+@@ -105,7 +105,6 @@
+ int fd;
+ partition_map_header * map;
+ int writeable;
+- unsigned long length;
+ #ifdef __linux__
+ struct stat info;
+ #endif
+@@ -402,9 +401,7 @@
+ {
+ int fd;
+ partition_map_header * map;
+- unsigned long length;
+ DPME *data;
+- int ok;
+ unsigned long number;
+ #ifdef __linux__
+ struct stat info;
+@@ -433,13 +430,13 @@
+ map->maximum_in_map = -1;
+
+ number = compute_device_size(fd);
+- printf("size of 'device' is %u blocks: ", number);
++ printf("size of 'device' is %u blocks: ", (unsigned int)number);
+ flush_to_newline(0);
+ get_number_argument("what should be the size? ", (long *)&number, number);
+ if (number < 4) {
+ number = 4;
+ }
+- printf("new size of 'device' is %u blocks\n", number);
++ printf("new size of 'device' is %u blocks\n", (unsigned int)number);
+ map->media_size = number;
+
+ #ifdef __linux__
+--- a/pdisk.c
++++ b/pdisk.c
+@@ -437,7 +437,6 @@
+ {
+ long base;
+ long length;
+- long mult;
+ char *name;
+ char *type_name;
+
+@@ -599,7 +598,6 @@
+ void
+ do_reorder(partition_map_header *map)
+ {
+- partition_map * cur;
+ long old_index;
+ long index;
+
diff --git a/sys-fs/mac-fdisk/files/mac-fdisk-0.1_p16-ppc64.patch b/sys-fs/mac-fdisk/files/mac-fdisk-0.1_p16-ppc64.patch
new file mode 100644
index 000000000..616adc5b8
--- /dev/null
+++ b/sys-fs/mac-fdisk/files/mac-fdisk-0.1_p16-ppc64.patch
@@ -0,0 +1,455 @@
+--- a/bitfield.c
++++ b/bitfield.c
+@@ -67,13 +67,12 @@
+ //
+ // Routines
+ //
+-unsigned long
+-bitfield_set(unsigned long *bf, int base, int length, unsigned long value)
++unsigned int
++bitfield_set(unsigned int *bf, int base, int length, unsigned int value)
+ {
+- unsigned long t;
+- unsigned long m;
++ unsigned int t;
++ unsigned int m;
+ int s;
+- int i;
+
+ // compute shift & mask, coerce value to correct number of bits,
+ // zap the old bits and stuff the new value
+@@ -86,12 +85,11 @@
+ }
+
+
+-unsigned long
+-bitfield_get(unsigned long bf, int base, int length)
++unsigned int
++bitfield_get(unsigned int bf, int base, int length)
+ {
+- unsigned long m;
++ unsigned int m;
+ int s;
+- int i;
+
+ // compute shift & mask
+ // return the correct number of bits (shifted to low end)
+--- a/bitfield.h
++++ b/bitfield.h
+@@ -63,5 +63,5 @@
+ //
+ // Forward declarations
+ //
+-unsigned long bitfield_set(unsigned long *bf, int base, int length, unsigned long value);
+-unsigned long bitfield_get(unsigned long bf, int base, int length);
++unsigned int bitfield_set(unsigned int *bf, int base, int length, unsigned int value);
++unsigned int bitfield_get(unsigned int bf, int base, int length);
+--- a/dump.c
++++ b/dump.c
+@@ -61,16 +61,16 @@
+ // Global Constants
+ //
+ NAMES plist[] = {
+- "Drvr", "Apple_Driver",
+- "Dr43", "Apple_Driver43",
+- "Free", "Apple_Free",
+- " HFS", "Apple_HFS",
+- " MFS", "Apple_MFS",
+- "PDOS", "Apple_PRODOS",
+- "junk", "Apple_Scratch",
+- "unix", "Apple_UNIX_SVR2",
+- " map", "Apple_partition_map",
+- 0, 0
++ {"Drvr"}, {"Apple_Driver"},
++ {"Dr43"}, {"Apple_Driver43"},
++ {"Free"}, {"Apple_Free"},
++ {" HFS"}, {"Apple_HFS"},
++ {" MFS"}, {"Apple_MFS"},
++ {"PDOS"}, {"Apple_PRODOS"},
++ {"junk"}, {"Apple_Scratch"},
++ {"unix"}, {"Apple_UNIX_SVR2"},
++ {" map"}, {"Apple_partition_map"},
++ {0}, {0}
+ };
+
+ const char * kStringEmpty = "";
+@@ -162,10 +162,10 @@
+ }
+ #ifdef __mc68000__
+ printf("%*s type name "
+- "%*s %-*s ( size ) system\n", strlen(map->name)+1, "#", j, "length", j, "base");
++ "%*s %-*s ( size ) system\n", (int)strlen(map->name)+1, "#", j, "length", j, "base");
+ #else
+ printf("%*s type name "
+- "%*s %-*s ( size ) system\n", strlen(map->name)+1, "#", j, "length", j, "base");
++ "%*s %-*s ( size ) system\n", (int)strlen(map->name)+1, "#", j, "length", j, "base");
+ #endif
+
+ /* Grok devfs names. (courtesy Colin Walters)*/
+@@ -199,7 +199,6 @@
+ partition_map_header *map;
+ int j;
+ DPME *p;
+- BZB *bp;
+ char *s;
+ #ifdef __mc68000__
+ int aflag = 1;
+@@ -222,13 +221,13 @@
+ }
+ }
+ #ifdef __mc68000__
+- printf("%s%-2d %.4s %-12.12s ", dev, entry->disk_address, s, p->dpme_name);
++ printf("%s%-2d %.4s %-12.12s ", dev, (int)entry->disk_address, s, p->dpme_name);
+ #else
+- printf("%s%-4d %.4s %-18.32s ", dev, entry->disk_address, s, p->dpme_name);
++ printf("%s%-4d %.4s %-18.32s ", dev, (int)entry->disk_address, s, p->dpme_name);
+ #endif
+ } else {
+ printf("%s%-4d %20.32s %-18.32s ", dev,
+- entry->disk_address, p->dpme_type, p->dpme_name);
++ (int)entry->disk_address, p->dpme_type, p->dpme_name);
+ }
+
+ if (pflag) {
+@@ -312,7 +311,6 @@
+ int i;
+ int fd;
+ DPME * data;
+- long t;
+
+ data = (DPME *) malloc(PBLOCK_SIZE);
+ if (data == NULL) {
+@@ -380,7 +378,7 @@
+ printf("Header:\n");
+ printf("fd=%d (%s)\n", map->fd, (map->regular_file)?"file":"device");
+ printf("map %d blocks out of %d, media %u blocks\n",
+- map->blocks_in_map, map->maximum_in_map, map->media_size);
++ map->blocks_in_map, map->maximum_in_map, (unsigned int)map->media_size);
+ printf("Map is%s writeable", (map->writeable)?kStringEmpty:kStringNot);
+ printf(", but%s changed\n", (map->changed)?kStringEmpty:kStringNot);
+ printf("\n");
+@@ -424,7 +422,7 @@
+ for (entry = map->disk_order; entry != NULL; entry = entry->next_on_disk) {
+ p = entry->data;
+ printf("%2d: %20.32s ",
+- entry->disk_address, p->dpme_type);
++ (int)entry->disk_address, p->dpme_type);
+ printf("%7u @ %-7u ", p->dpme_pblocks, p->dpme_pblock_start);
+ printf("%c%c%c%c%c%c%c%c%c%c ",
+ (dpme_valid_get(p))?'V':'v',
+@@ -447,7 +445,7 @@
+ "goto_address checksum processor\n");
+ for (entry = map->disk_order; entry != NULL; entry = entry->next_on_disk) {
+ p = entry->data;
+- printf("%2d: ", entry->disk_address);
++ printf("%2d: ", (int)entry->disk_address);
+ printf("%7u ", p->dpme_boot_block);
+ printf("%7u ", p->dpme_boot_bytes);
+ printf("%8x ", p->dpme_load_addr);
+@@ -464,7 +462,7 @@
+ */
+ for (entry = map->disk_order; entry != NULL; entry = entry->next_on_disk) {
+ p = entry->data;
+- printf("%2d: ", entry->disk_address);
++ printf("%2d: ", (int)entry->disk_address);
+
+ bp = (BZB *) (p->dpme_bzb);
+ j = -1;
+--- a/errors.c
++++ b/errors.c
+@@ -30,6 +30,7 @@
+ #include <string.h>
+ #include <stdarg.h>
+
++#include <errno.h>
+ #include "errors.h"
+ #include "pdisk.h"
+
+@@ -113,7 +114,7 @@
+ va_end(ap);
+
+ #ifdef __linux__
+- if (value > 0) {
++ if (value > 0 && value < errno) {
+ fprintf(stderr, " (%s)\n", strerror(value));
+ } else {
+ fprintf(stderr, "\n");
+@@ -142,7 +143,7 @@
+ va_end(ap);
+
+ #ifdef __linux__
+- if (value > 0) {
++ if (value > 0 && value < errno) {
+ fprintf(stderr, " (%s)\n", strerror(value));
+ } else {
+ fprintf(stderr, "\n");
+--- a/fdisk.c
++++ b/fdisk.c
+@@ -71,12 +71,65 @@
+
+ #include <sys/ioctl.h>
+
+-typedef unsigned short kdev_t; /* BAD hack; kdev_t is not exported */
+-
+ #include "kernel-defs.h"
+
+ #include "fdisk.h"
+
++/* ----------- */
++#define _PPC64_TYPES_H
++#define BITS_PER_LONG 64
++
++typedef __signed__ char __s8;
++typedef signed char s8;
++typedef unsigned char u8;
++typedef unsigned char __u8;
++
++typedef __signed__ short __s16;
++typedef signed short s16;
++/*typedef unsigned short __u16;*/
++typedef unsigned short u16;
++
++typedef __signed__ int __s32;
++typedef signed int s32;
++/*typedef unsigned int __u32;*/
++typedef unsigned int u32;
++
++typedef __signed__ long __s64;
++typedef signed long s64;
++typedef unsigned long __u64;
++typedef unsigned long u64;
++
++typedef struct {
++ __u32 u[4];
++} __attribute((aligned(16))) __vector128;
++
++typedef __vector128 vector128;
++
++typedef u32 dma_addr_t;
++typedef u64 dma64_addr_t;
++
++typedef struct {
++ unsigned long entry;
++ unsigned long toc;
++ unsigned long env;
++} func_descr_t;
++
++typedef unsigned int umode_t;
++
++#define BITS_TO_LONGS(bits) \
++ (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG)
++#define DECLARE_BITMAP(name,bits) \
++ unsigned long name[BITS_TO_LONGS(bits)]
++#define CLEAR_BITMAP(name,bits) \
++ memset(name, 0, BITS_TO_LONGS(bits)*sizeof(unsigned long))
++
++/* hd/ide ctl's that pass (arg) ptrs to user space are numbered 0x030n/0x031n */
++#define HDIO_GETGEO 0x0301 /* get device geometry */
++
++#define BLKRRPART _IO(0x12,95) /* re-read partition table */
++
++/* ---------- */
++
+ #define hex_val(c) ({ \
+ char _c = (c); \
+ isdigit(_c) ? _c - '0' : \
+@@ -1416,7 +1469,7 @@
+ }
+ }
+
+-void main(int argc, char **argv)
++int main(int argc, char **argv)
+ {
+ if (argc > 3)
+ fatal(usage);
+--- a/fdisklabel.c
++++ b/fdisklabel.c
+@@ -35,6 +35,7 @@
+ SUCH DAMAGE.
+ */
+
++#include <sys/types.h>
+ #include <unistd.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+@@ -47,6 +48,8 @@
+ #include <sys/ioctl.h>
+ #include <sys/param.h>
+
++#include <asm/types.h>
++
+ #include "kernel-defs.h"
+
+ #include "fdisk.h"
+@@ -263,8 +266,8 @@
+ fprintf(f, "type: %s\n", bsd_dktypenames[lp->d_type]);
+ else
+ fprintf(f, "type: %d\n", lp->d_type);
+- fprintf(f, "disk: %.*s\n", sizeof(lp->d_typename), lp->d_typename);
+- fprintf(f, "label: %.*s\n", sizeof(lp->d_packname), lp->d_packname);
++ fprintf(f, "disk: %.*s\n", (int)sizeof(lp->d_typename), lp->d_typename);
++ fprintf(f, "label: %.*s\n", (int)sizeof(lp->d_packname), lp->d_packname);
+ fprintf(f, "flags:");
+ if (lp->d_flags & BSD_D_REMOVABLE)
+ fprintf(f, " removable");
+@@ -273,17 +276,17 @@
+ if (lp->d_flags & BSD_D_BADSECT)
+ fprintf(f, " badsect");
+ fprintf(f, "\n");
+- fprintf(f, "bytes/sector: %d\n", lp->d_secsize);
+- fprintf(f, "sectors/track: %d\n", lp->d_nsectors);
+- fprintf(f, "tracks/cylinder: %d\n", lp->d_ntracks);
+- fprintf(f, "sectors/cylinder: %d\n", lp->d_secpercyl);
+- fprintf(f, "cylinders: %d\n", lp->d_ncylinders);
++ fprintf(f, "bytes/sector: %d\n", (int)lp->d_secsize);
++ fprintf(f, "sectors/track: %d\n", (int)lp->d_nsectors);
++ fprintf(f, "tracks/cylinder: %d\n", (int)lp->d_ntracks);
++ fprintf(f, "sectors/cylinder: %d\n", (int)lp->d_secpercyl);
++ fprintf(f, "cylinders: %d\n", (int)lp->d_ncylinders);
+ fprintf(f, "rpm: %d\n", lp->d_rpm);
+ fprintf(f, "interleave: %d\n", lp->d_interleave);
+ fprintf(f, "trackskew: %d\n", lp->d_trackskew);
+ fprintf(f, "cylinderskew: %d\n", lp->d_cylskew);
+- fprintf(f, "headswitch: %d\t\t# milliseconds\n", lp->d_headswitch);
+- fprintf(f, "track-to-track seek: %d\t# milliseconds\n", lp->d_trkseek);
++ fprintf(f, "headswitch: %d\t\t# milliseconds\n", (int)lp->d_headswitch);
++ fprintf(f, "track-to-track seek: %d\t# milliseconds\n", (int)lp->d_trkseek);
+ fprintf(f, "drivedata: ");
+ for (i = NDDATA - 1; i >= 0; i--)
+ if (lp->d_drivedata[i])
+@@ -291,7 +294,7 @@
+ if (i < 0)
+ i = 0;
+ for (j = 0; j <= i; j++)
+- fprintf(f, "%d ", lp->d_drivedata[j]);
++ fprintf(f, "%d ", (int)lp->d_drivedata[j]);
+ }
+ fprintf (f, "\n%d partitions:\n", lp->d_npartitions);
+ fprintf (f, "# size offset fstype [fsize bsize cpg]\n");
+@@ -299,7 +302,7 @@
+ for (i = 0; i < lp->d_npartitions; i++, pp++) {
+ if (pp->p_size) {
+ fprintf(f, " %c: %8d %8d ", 'a' + i,
+- pp->p_size, pp->p_offset);
++ (int)pp->p_size, (int)pp->p_offset);
+ if ((unsigned) pp->p_fstype < BSD_FSMAXTYPES)
+ fprintf(f, "%8.8s", bsd_fstypes[pp->p_fstype].name);
+ else
+@@ -308,12 +311,12 @@
+ {
+ case BSD_FS_UNUSED:
+ fprintf(f, " %5d %5d %5.5s ",
+- pp->p_fsize, pp->p_fsize * pp->p_frag, "");
++ (int)pp->p_fsize, (int)pp->p_fsize * pp->p_frag, "");
+ break;
+
+ case BSD_FS_BSDFFS:
+ fprintf(f, " %5d %5d %5d ",
+- pp->p_fsize, pp->p_fsize * pp->p_frag,
++ (int)pp->p_fsize, (int)pp->p_fsize * pp->p_frag,
+ pp->p_cpg);
+ break;
+
+@@ -323,21 +326,21 @@
+ }
+ fprintf(f, "\t# (Cyl. %4d",
+ #if 0
+- pp->p_offset / lp->d_secpercyl); /* differs from Linux fdisk */
++ (int)(pp->p_offset / lp->d_secpercyl)); /* differs from Linux fdisk */
+ #else
+- pp->p_offset / lp->d_secpercyl + 1);
++ (int)(pp->p_offset / lp->d_secpercyl + 1));
+ #endif
+ if (pp->p_offset % lp->d_secpercyl)
+ putc('*', f);
+ else
+ putc(' ', f);
+ fprintf(f, "- %d",
+- (pp->p_offset +
++ (int)((pp->p_offset +
+ pp->p_size + lp->d_secpercyl - 1) /
+ #if 0
+- lp->d_secpercyl - 1); /* differs from Linux fdisk */
++ lp->d_secpercyl - 1)); /* differs from Linux fdisk */
+ #else
+- lp->d_secpercyl);
++ lp->d_secpercyl));
+ #endif
+ if (pp->p_size % lp->d_secpercyl)
+ putc('*', f);
+--- a/io.c
++++ b/io.c
+@@ -33,8 +33,10 @@
+ #else
+ #ifdef __GLIBC__
+ #include <sys/types.h>
++#include <sys/stat.h>
+ #endif
+ #endif
++#include <linux/unistd.h>
+ #include <unistd.h>
+ #include <string.h>
+ #include <stdarg.h>
+@@ -466,7 +468,7 @@
+ long t;
+
+ if (rflag) {
+- printf("Can't write block %u to file", num);
++ printf("Can't write block %u to file", (unsigned int)num);
+ return 0;
+ }
+ #ifndef __linux__
+--- a/partition_map.c
++++ b/partition_map.c
+@@ -105,7 +105,6 @@
+ int fd;
+ partition_map_header * map;
+ int writeable;
+- unsigned long length;
+ #ifdef __linux__
+ struct stat info;
+ #endif
+@@ -402,9 +401,7 @@
+ {
+ int fd;
+ partition_map_header * map;
+- unsigned long length;
+ DPME *data;
+- int ok;
+ unsigned long number;
+ #ifdef __linux__
+ struct stat info;
+@@ -433,13 +430,13 @@
+ map->maximum_in_map = -1;
+
+ number = compute_device_size(fd);
+- printf("size of 'device' is %u blocks: ", number);
++ printf("size of 'device' is %u blocks: ", (unsigned int)number);
+ flush_to_newline(0);
+ get_number_argument("what should be the size? ", (long *)&number, number);
+ if (number < 4) {
+ number = 4;
+ }
+- printf("new size of 'device' is %u blocks\n", number);
++ printf("new size of 'device' is %u blocks\n", (unsigned int)number);
+ map->media_size = number;
+
+ #ifdef __linux__
+--- a/pdisk.c
++++ b/pdisk.c
+@@ -437,7 +437,6 @@
+ {
+ long base;
+ long length;
+- long mult;
+ char *name;
+ char *type_name;
+
+@@ -599,7 +598,6 @@
+ void
+ do_reorder(partition_map_header *map)
+ {
+- partition_map * cur;
+ long old_index;
+ long index;
+
diff --git a/sys-fs/mac-fdisk/files/mac-fdisk-amd64.patch b/sys-fs/mac-fdisk/files/mac-fdisk-amd64.patch
new file mode 100644
index 000000000..8658ba9a6
--- /dev/null
+++ b/sys-fs/mac-fdisk/files/mac-fdisk-amd64.patch
@@ -0,0 +1,190 @@
+--- a/fdisklabel.c
++++ b/fdisklabel.c
+@@ -72,7 +72,7 @@
+ static int bsd_readlabel (struct partition *p, struct disklabel *d);
+ static int bsd_writelabel (struct partition *p, struct disklabel *d);
+ static void sync_disks (void);
+-#if defined (i386)
++#if defined (i386) || defined (__amd64)
+ static int bsd_translate_fstype (int linux_type);
+ static void bsd_link_part (void);
+ #endif
+@@ -82,7 +82,7 @@
+
+ static struct disklabel bsd_dlabel;
+ static char buffer[BSD_BBSIZE];
+-#if defined (i386)
++#if defined (i386) || defined (__amd64)
+ static struct partition *bsd_part;
+ static int bsd_part_index;
+ #endif
+@@ -99,13 +99,13 @@
+ " n add a new BSD partition\n"
+ " p print BSD partition table\n"
+ " q quit without saving changes\n"
+-#if defined (i386)
++#if defined (i386) || defined (__amd64)
+ " r return to main menu\n"
+ #endif
+ " s show complete disklabel\n"
+ " t change a partition's filesystem id\n"
+ " w write disklabel to disk\n"
+-#if defined (i386)
++#if defined (i386) || defined (__amd64)
+ " x link BSD partition to non-BSD partition"
+ #endif
+ );
+@@ -114,7 +114,7 @@
+ void
+ bselect (void)
+ {
+-#if defined (i386)
++#if defined (i386) || defined (__amd64)
+ int t;
+
+ for (t=0; t<4; t++)
+@@ -185,7 +185,7 @@
+ case 'w':
+ bsd_write_disklabel ();
+ break;
+-#if defined (i386)
++#if defined (i386) || defined (__amd64)
+ case 'r':
+ return;
+ case 'x':
+@@ -223,7 +223,7 @@
+ if (!bsd_check_new_partition (&i))
+ return;
+
+-#if defined (i386)
++#if defined (i386) || defined (__amd64)
+ begin = bsd_part -> start_sect;
+ end = begin + bsd_part -> nr_sects - 1;
+ #elif defined (__alpha__) || defined (__powerpc__)
+@@ -257,7 +257,7 @@
+
+ if (show_all)
+ {
+-#if defined (i386)
++#if defined (i386) || defined (__amd64)
+ fprintf(f, "# %s%d:\n", disk_device, bsd_part_index+1);
+ #elif defined (__alpha__) || defined (__powerpc__)
+ fprintf(f, "# %s:\n", disk_device);
+@@ -352,7 +352,7 @@
+ static void
+ bsd_write_disklabel (void)
+ {
+-#if defined (i386)
++#if defined (i386) || defined (__amd64)
+ printf ("Writing disklabel to %s%d.\n", disk_device, bsd_part_index+1);
+ bsd_writelabel (bsd_part, &bsd_dlabel);
+ #elif defined (__alpha__) || defined (__powerpc__)
+@@ -366,7 +366,7 @@
+ {
+ char c;
+
+-#if defined (i386)
++#if defined (i386) || defined(__amd64)
+ fprintf (stderr, "%s%d contains no disklabel.\n",
+ disk_device, bsd_part_index+1);
+ #elif defined (__alpha__) || defined (__powerpc__)
+@@ -376,7 +376,7 @@
+ while (1)
+ if ((c = tolower (read_char ("Do you want to create a disklabel? (y/n) "))) == 'y')
+ {
+-#if defined (i386)
++#if defined (i386) || defined(__amd64)
+ if (bsd_initlabel (bsd_part, &bsd_dlabel, bsd_part_index) == 1)
+ #elif defined (__alpha__) || defined (__powerpc__) || defined (__mc68000__)
+ if (bsd_initlabel (NULL, &bsd_dlabel, 0) == 1)
+@@ -507,7 +507,7 @@
+
+ bcopy (&dl, d, sizeof (struct disklabel));
+
+-#if defined (i386)
++#if defined (i386) || defined (__amd64)
+ sector = bsd_part -> start_sect;
+ #elif defined (__powerpc__)
+ sector = 0;
+@@ -521,7 +521,7 @@
+ if (BSD_BBSIZE != write (fd, buffer, BSD_BBSIZE))
+ fatal (unable_to_write);
+
+-#if defined (i386)
++#if defined (i386) || defined (__amd64)
+ printf ("Bootstrap installed on %s%d.\n", disk_device, bsd_part_index+1);
+ #elif defined (__alpha__) || defined (__powerpc__)
+ printf ("Bootstrap installed on %s.\n", disk_device);
+@@ -625,7 +625,7 @@
+ d -> d_subtype = BSD_DSTYPE_INDOSPART & pindex;
+ #endif
+
+-#if defined (i386)
++#if defined (i386) || defined (__amd64)
+ d -> d_flags = BSD_D_DOSPART;
+ #else
+ d -> d_flags = 0;
+@@ -648,7 +648,7 @@
+ d -> d_bbsize = BSD_BBSIZE;
+ d -> d_sbsize = BSD_SBSIZE;
+
+-#if defined (i386)
++#if defined (i386) || defined (__amd64)
+ d -> d_npartitions = 4;
+ pp = &d -> d_partitions[2]; /* Partition C should be the NetBSD partition */
+ pp -> p_offset = p -> start_sect;
+@@ -674,7 +674,7 @@
+ {
+ int t, sector;
+
+-#if defined (i386)
++#if defined (i386) || defined (__amd64)
+ sector = p -> start_sect;
+ #elif defined (__alpha__) || defined (__powerpc__)
+ sector = 0;
+@@ -708,7 +708,7 @@
+ {
+ int sector;
+
+-#if defined (i386)
++#if defined (i386) || defined (__amd64)
+ sector = p -> start_sect + BSD_LABELSECTOR;
+ #elif defined (__alpha__) || defined (__powerpc__)
+ sector = BSD_LABELSECTOR;
+@@ -749,7 +749,7 @@
+ sleep (4);
+ }
+
+-#if defined (i386)
++#if defined (i386) || defined (__amd64)
+ static int
+ bsd_translate_fstype (int linux_type)
+ {
+--- a/fdisklabel.h
++++ b/fdisklabel.h
+@@ -35,7 +35,7 @@
+ #define BSD_MAXPARTITIONS 8
+ #define BSD_LINUX_BOOTDIR "/usr/ucb/mdec"
+
+-#if defined (i386)
++#if defined (i386) || defined(__amd64)
+ #define BSD_LABELSECTOR 1
+ #define BSD_LABELOFFSET 0
+ #define BSD_BBSIZE 8192 /* size of boot area, with label */
+--- a/kernel-defs.h
++++ b/kernel-defs.h
+@@ -15,8 +15,14 @@
+ /* from asm/ioctl.h */
+ #define _IOC_NRBITS 8
+ #define _IOC_TYPEBITS 8
++
++#ifndef _IOC_SIZEBITS
+ #define _IOC_SIZEBITS 13
++#endif
++
++#ifndef _IOC_DIRBITS
+ #define _IOC_DIRBITS 3
++#endif
+
+ #define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
+ #define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
diff --git a/sys-fs/mac-fdisk/files/mac-fdisk-large-disk-support.patch b/sys-fs/mac-fdisk/files/mac-fdisk-large-disk-support.patch
new file mode 100644
index 000000000..fe9e78ec7
--- /dev/null
+++ b/sys-fs/mac-fdisk/files/mac-fdisk-large-disk-support.patch
@@ -0,0 +1,80 @@
+--- a/partition_map.c
++++ b/partition_map.c
+@@ -25,6 +25,11 @@
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
++//
++// Defines
++//
++// #define TEST_COMPUTE
++
+ #include <stdio.h>
+ #include <string.h>
+ #include <stdlib.h>
+@@ -36,6 +41,10 @@
+ #include <sys/ioctl.h>
+ #include "kernel-defs.h"
+ #include <sys/stat.h>
++#ifdef TEST_COMPUTE
++#include <linux/fs.h>
++#endif
++
+ #endif
+
+ #include "partition_map.h"
+@@ -45,10 +54,6 @@
+ #include "errors.h"
+
+
+-//
+-// Defines
+-//
+-// #define TEST_COMPUTE
+
+
+ //
+@@ -666,7 +671,7 @@
+ loff_t pos;
+ #endif
+ char* data;
+- unsigned long l, r, x;
++ unsigned long long l, r, x;
+ int valid;
+
+ #ifdef TEST_COMPUTE
+@@ -720,9 +725,11 @@
+ } else {
+ r = r * 2;
+ }
+- if (r >= (1024*1024*1024)) {
+- break;
+- }
++// There's no explanation for this, but I suspect the author was trying to
++// prevent going over the 32 bit size
++// if (r >= (1024*1024*1024*2)) {
++// break;
++// }
+ }
+ // binary search for end
+ while (l <= r) {
+@@ -740,11 +747,17 @@
+ if (valid != 0) {
+ x = x + 1;
+ }
+- // printf("size in blocks = %d\n", x);
++#ifdef TEST_COMPUTE
++ printf("size in blocks = %d\n", x);
++#endif
+ free(data);
+ }
++
++ // Add a warning just in case...
++ if(x > 0x80000000)
++ printf("Warning: Large disks may not work with this tool!\n");
+
+- return x;
++ return (unsigned long) x;
+ }
+
+
diff --git a/sys-fs/mac-fdisk/files/mac-fdisk-largerthan2gb.patch b/sys-fs/mac-fdisk/files/mac-fdisk-largerthan2gb.patch
new file mode 100644
index 000000000..b33487ca9
--- /dev/null
+++ b/sys-fs/mac-fdisk/files/mac-fdisk-largerthan2gb.patch
@@ -0,0 +1,14 @@
+--- a/fdisk.h
++++ b/fdisk.h
+@@ -2,6 +2,11 @@
+ fdisk.h
+ */
+
++#ifdef __linux__
++#define _FILE_OFFSET_BITS 64
++#define _LARGE_FILES
++#endif
++
+ #define SECTOR_SIZE 512
+ #define NETBSD_PARTITION 0xa5
+ #define cround(n) (((n) + display_factor * unit_flag) / display_factor)
diff --git a/sys-fs/mac-fdisk/files/mac-fdisk-non-glibc-support.patch b/sys-fs/mac-fdisk/files/mac-fdisk-non-glibc-support.patch
new file mode 100644
index 000000000..c22c2b20a
--- /dev/null
+++ b/sys-fs/mac-fdisk/files/mac-fdisk-non-glibc-support.patch
@@ -0,0 +1,14 @@
+--- /var/tmp/portage/sys-fs/mac-fdisk-0.1_p16/work/mac-fdisk-0.1.orig/io.c 2016-01-24 03:19:51.647734970 -0600
++++ /usr/powerpc-foxkit-linux-musl/tmp/portage/sys-fs/mac-fdisk-0.1_p16/work/mac-fdisk-0.1.orig/io.c 2016-01-24 03:27:08.952825190 -0600
+@@ -31,11 +31,9 @@
+ #ifndef __linux__
+ #include <SCSI.h>
+ #else
+-#ifdef __GLIBC__
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #endif
+-#endif
+ #include <linux/unistd.h>
+ #include <unistd.h>
+ #include <string.h>
diff --git a/sys-fs/mac-fdisk/mac-fdisk-0.1_p16.ebuild b/sys-fs/mac-fdisk/mac-fdisk-0.1_p16.ebuild
new file mode 100644
index 000000000..5794eaa69
--- /dev/null
+++ b/sys-fs/mac-fdisk/mac-fdisk-0.1_p16.ebuild
@@ -0,0 +1,49 @@
+# Copyright 2015-2016 Adélie Linux Team
+# Distributed under the terms of the NCSA License
+
+EAPI=5
+inherit eutils
+
+DESCRIPTION="Mac/PowerMac disk partitioning utility"
+HOMEPAGE="ftp://ftp.mklinux.apple.com/pub/Other_Tools/"
+SRC_URI="
+ mirror://debian/pool/main/m/mac-fdisk/${PN}_${PV/_p*}.orig.tar.gz
+ mirror://debian/pool/main/m/mac-fdisk/${PN}_${PV/_p*}-${PV/*_p}.diff.gz
+"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~ppc ~ppc64 ~x86"
+
+S=${WORKDIR}/${P/_p*}.orig
+
+EPATCH_SOURCES=(
+ "${WORKDIR}"/${PN}_${PV/_p*}-${PV/*_p}.diff
+ "${FILESDIR}"/${PN}-largerthan2gb.patch
+ "${FILESDIR}"/${PN}-0.1-headers.patch
+ # Gentoo bug #142737
+ "${FILESDIR}"/${PN}-0.1_p16-ppc64.patch
+ "${FILESDIR}"/${PN}-amd64.patch
+
+ ### Patch for large (>550GB disks)
+ ### Note that >=2TB disks may not work due to limitations of the Mac
+ ### Partition Table structure, this needs to be investigated
+ "${FILESDIR}"/${PN}-large-disk-support.patch
+ "${FILESDIR}"/${PN}-non-glibc-support.patch
+ )
+
+src_prepare() {
+ epatch
+ epatch_user
+}
+
+src_install() {
+ into /
+ newsbin pdisk mac-fdisk
+ newsbin fdisk pmac-fdisk
+
+ into /usr
+ newman mac-fdisk.8.in mac-fdisk.8
+ newman pmac-fdisk.8.in pmac-fdisk.8
+ dodoc README HISTORY
+}
diff --git a/sys-fs/mac-fdisk/metadata.xml b/sys-fs/mac-fdisk/metadata.xml
new file mode 100644
index 000000000..097975e3a
--- /dev/null
+++ b/sys-fs/mac-fdisk/metadata.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+</pkgmetadata>