From 3c052ea7dd09c7a9feaaecc7424896ea84200565 Mon Sep 17 00:00:00 2001 From: q66 Date: Fri, 1 Nov 2019 12:05:35 +0100 Subject: [PATCH] mac-fdisk: sync patches from adelie This should also fix it on musl. --- .../06-mac-fdisk-0.1_p16-ppc-inline.patch | 21 - .../07-mac-fdisk-0.1_p18-lseek64.patch | 43 - ....1-18.patch => mac-fdisk-0.1-debian.patch} | 1493 ++++++++--------- ...ders.patch => mac-fdisk-0.1-headers.patch} | 28 +- .../patches/mac-fdisk-0.1-more-arches.patch | 67 + ...64.patch => mac-fdisk-0.1_p16-ppc64.patch} | 36 +- .../mac-fdisk-0.1_p16-proper-inline.patch | 65 + ...disk-amd64.patch => mac-fdisk-amd64.patch} | 37 +- .../patches/mac-fdisk-fdisk-header-musl.patch | 10 + ...tch => mac-fdisk-large-disk-support.patch} | 4 +- ...gb.patch => mac-fdisk-largerthan2gb.patch} | 4 +- .../patches/mac-fdisk-non-glibc-support.patch | 14 + .../patches/mac-fdisk-stdout-flush.patch | 59 + srcpkgs/mac-fdisk/template | 14 +- 14 files changed, 1004 insertions(+), 891 deletions(-) delete mode 100644 srcpkgs/mac-fdisk/patches/06-mac-fdisk-0.1_p16-ppc-inline.patch delete mode 100644 srcpkgs/mac-fdisk/patches/07-mac-fdisk-0.1_p18-lseek64.patch rename srcpkgs/mac-fdisk/patches/{00-mac-fdisk_0.1-18.patch => mac-fdisk-0.1-debian.patch} (98%) rename srcpkgs/mac-fdisk/patches/{02-mac-fdisk-0.1-headers.patch => mac-fdisk-0.1-headers.patch} (89%) create mode 100644 srcpkgs/mac-fdisk/patches/mac-fdisk-0.1-more-arches.patch rename srcpkgs/mac-fdisk/patches/{03-mac-fdisk-0.1_p16-ppc64.patch => mac-fdisk-0.1_p16-ppc64.patch} (97%) create mode 100644 srcpkgs/mac-fdisk/patches/mac-fdisk-0.1_p16-proper-inline.patch rename srcpkgs/mac-fdisk/patches/{04-mac-fdisk-amd64.patch => mac-fdisk-amd64.patch} (80%) create mode 100644 srcpkgs/mac-fdisk/patches/mac-fdisk-fdisk-header-musl.patch rename srcpkgs/mac-fdisk/patches/{05-big_pt.patch => mac-fdisk-large-disk-support.patch} (96%) rename srcpkgs/mac-fdisk/patches/{01-largerthan2gb.patch => mac-fdisk-largerthan2gb.patch} (89%) create mode 100644 srcpkgs/mac-fdisk/patches/mac-fdisk-non-glibc-support.patch create mode 100644 srcpkgs/mac-fdisk/patches/mac-fdisk-stdout-flush.patch diff --git a/srcpkgs/mac-fdisk/patches/06-mac-fdisk-0.1_p16-ppc-inline.patch b/srcpkgs/mac-fdisk/patches/06-mac-fdisk-0.1_p16-ppc-inline.patch deleted file mode 100644 index 10cfab5b912..00000000000 --- a/srcpkgs/mac-fdisk/patches/06-mac-fdisk-0.1_p16-ppc-inline.patch +++ /dev/null @@ -1,21 +0,0 @@ -on gcc-7.3.0 build failed as: - # CFLAGS="-mcpu=powerpc -Os -pipe" emerge -v1 sys-fs/mac-fdisk - cc fdisk.o fdisklabel.o -o fdisk - fdisk.o: In function `check_consistency': - fdisk.c:(.text+0x64): undefined reference to `__swap32' - fdisk.c:(.text+0x70): undefined reference to `__swap32' - -Avoid exporting inline symbols and workaround build failure. ---- fdisk.c -+++ fdisk.c -@@ -247,8 +247,8 @@ char read_char(char *mesg); - jmp_buf listingbuf; - --inline unsigned short __swap16(unsigned short x) { -+static inline unsigned short __swap16(unsigned short x) { - return (((__u16)(x) & 0xFF) << 8) | (((__u16)(x) & 0xFF00) >> 8); - } --inline __u32 __swap32(__u32 x) { -+static inline __u32 __swap32(__u32 x) { - return (((__u32)(x) & 0xFF) << 24) | (((__u32)(x) & 0xFF00) << 8) | (((__u32)(x) & 0xFF0000) >> 8) | (((__u32)(x) & 0xFF000000) >> 24); - } diff --git a/srcpkgs/mac-fdisk/patches/07-mac-fdisk-0.1_p18-lseek64.patch b/srcpkgs/mac-fdisk/patches/07-mac-fdisk-0.1_p18-lseek64.patch deleted file mode 100644 index cff1a8d63a8..00000000000 --- a/srcpkgs/mac-fdisk/patches/07-mac-fdisk-0.1_p18-lseek64.patch +++ /dev/null @@ -1,43 +0,0 @@ ---- fdisk.c -+++ fdisk.c -@@ -59,6 +59,10 @@ - */ - - -+#ifndef _LARGEFILE64_SOURCE -+#define _LARGEFILE64_SOURCE -+#endif -+#include - #include - #include - #include ---- fdisklabel.c -+++ fdisklabel.c -@@ -35,6 +35,9 @@ - SUCH DAMAGE. - */ - -+#ifndef _LARGEFILE64_SOURCE -+#define _LARGEFILE64_SOURCE -+#endif - #include - #include - #include ---- io.c -+++ io.c -@@ -25,6 +25,7 @@ - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -+#define _LARGEFILE64_SOURCE - #include - #include - #include -@@ -37,6 +38,7 @@ - #endif - #endif - #include -+#include - #include - #include - #include diff --git a/srcpkgs/mac-fdisk/patches/00-mac-fdisk_0.1-18.patch b/srcpkgs/mac-fdisk/patches/mac-fdisk-0.1-debian.patch similarity index 98% rename from srcpkgs/mac-fdisk/patches/00-mac-fdisk_0.1-18.patch rename to srcpkgs/mac-fdisk/patches/mac-fdisk-0.1-debian.patch index dede0b75445..617dd8e703d 100644 --- a/srcpkgs/mac-fdisk/patches/00-mac-fdisk_0.1-18.patch +++ b/srcpkgs/mac-fdisk/patches/mac-fdisk-0.1-debian.patch @@ -1,23 +1,5 @@ ---- Makefile -+++ Makefile -@@ -5,7 +5,14 @@ - fdisk: fdisk.o fdisklabel.o - - clean: -- rm -f *.o pdisk fdisk -+ rm -f *.o pdisk fdisk mac-fdisk pmac-fdisk -+ -+install: pdisk fdisk -+ -rm -f pmac-fdisk mac-fdisk -+ ln pdisk mac-fdisk -+ ln fdisk pmac-fdisk -+ install -o root -g root -m 0755 mac-fdisk ${DESTDIR}/sbin -+ install -o root -g root -m 0755 pmac-fdisk ${DESTDIR}/sbin - - distribution: - cd ..; tar cvf pdisk.src.tar.`date +%y%m%d` --files-from pdisk/list.src ---- dpme.h -+++ dpme.h +--- mac-fdisk-0.1.orig/dpme.h ++++ mac-fdisk-0.1/dpme.h @@ -61,7 +61,7 @@ // typedef unsigned char u8; @@ -61,8 +43,565 @@ #define dpme_os_specific_1_get(p) bitfield_get(p->dpme_flags, 8, 1) #define dpme_os_specific_2_get(p) bitfield_get(p->dpme_flags, 7, 1) #define dpme_os_pic_code_get(p) bitfield_get(p->dpme_flags, 6, 1) ---- dump.c -+++ dump.c +--- mac-fdisk-0.1.orig/pdisk.c ++++ mac-fdisk-0.1/pdisk.c +@@ -30,18 +30,17 @@ + #include + #ifdef __linux__ + #include ++#include + #else + #include + #include + #include + #endif +-#include + #include + + #ifdef __linux__ + #include +-#include +-#include ++#include "kernel-defs.h" + #endif + + #include "pdisk.h" +@@ -94,6 +93,7 @@ + void do_add_intel_partition(partition_map_header *map); + void do_change_map_size(partition_map_header *map); + void do_create_partition(partition_map_header *map, int get_type); ++void do_create_bootstrap_partition(partition_map_header *map); + void do_delete_partition(partition_map_header *map); + int do_expert(partition_map_header *map); + void do_reorder(partition_map_header *map); +@@ -114,6 +114,7 @@ + main(int argc, char **argv) + { + int name_index; ++ int err=0; + + if (sizeof(DPME) != PBLOCK_SIZE) { + fatal(-1, "Size of partion map entry (%d) " +@@ -150,7 +151,9 @@ + } else if (!vflag) { + usage("no device argument"); + do_help(); ++ err=-EINVAL; // debatable + } ++ exit(err); + } + #else + main() +@@ -351,7 +354,8 @@ + printf(" P (print ordered by base address)\n"); + printf(" i initialize partition map\n"); + printf(" s change size of partition map\n"); +- printf(" c create new partition\n"); ++ printf(" b create new 800K bootstrap partition\n"); ++ printf(" c create new Linux partition\n"); + printf(" C (create with type also specified)\n"); + printf(" d delete a partition\n"); + printf(" r reorder partition entry in map\n"); +@@ -378,6 +382,10 @@ + case 'i': + map = init_partition_map(name, map); + break; ++ case 'B': ++ case 'b': ++ do_create_bootstrap_partition(map); ++ break; + case 'C': + get_type = 1; + // fall through +@@ -471,6 +479,30 @@ + } + + ++void ++do_create_bootstrap_partition(partition_map_header *map) ++{ ++ long base; ++ ++ if (map == NULL) { ++ bad_input("No partition map exists"); ++ return; ++ } ++ ++ if (!rflag && map->writeable == 0) { ++ printf("The map is not writeable.\n"); ++ } ++ ++ // XXX add help feature (i.e. '?' in any argument routine prints help string) ++ if (get_base_argument(&base, map) == 0) { ++ return; ++ } ++ ++ // create 800K type Apple_Bootstrap partition named `bootstrap' ++ add_partition_to_map(kBootstrapName, kBootstrapType, base, 1600, map); ++} ++ ++ + int + get_base_argument(long *number, partition_map_header *map) + { +@@ -508,7 +540,7 @@ + int result = 0; + long multiple; + +- if (get_number_argument("Length in blocks: ", number, kDefault) == 0) { ++ if (get_number_argument("Length (in blocks, kB (k), MB (M) or GB (G)): ", number, kDefault) == 0) { + bad_input("Bad length"); + } else { + result = 1; +@@ -605,13 +637,22 @@ + bad_input("The map is not writeable."); + return; + } +- printf("Writing the map destroys what was there before. "); +- if (get_okay("Is that okay? [n/y]: ", 0) != 1) { ++// printf("Writing the map destroys what was there before. "); ++ printf("IMPORTANT: You are about to write a changed partition map to disk. \n"); ++ printf("For any partition you changed the start or size of, writing out \n"); ++ printf("the map causes all data on that partition to be LOST FOREVER. \n"); ++ printf("Make sure you have a backup of any data on such partitions you \n"); ++ printf("want to keep before answering 'yes' to the question below! \n\n"); ++ if (get_okay("Write partition map? [n/y]: ", 0) != 1) { + return; + } + + write_partition_map(map); + ++ printf("\nPartition map written to disk. If any partitions on this disk \n"); ++ printf("were still in use by the system (see messages above), you will need \n"); ++ printf("to reboot in order to utilize the new partition map.\n\n"); ++ + // exit(0); + } + +--- mac-fdisk-0.1.orig/pmac-fdisk.8.in ++++ mac-fdisk-0.1/pmac-fdisk.8.in +@@ -0,0 +1,222 @@ ++.\" Copyright 1992, 1993 Rickard E. Faith (faith@cs.unc.edu) ++.\" Copyright 1998 Andries E. Brouwer (aeb@cwi.nl) ++.\" Copyright 2000 Michael Schmitz (schmitz@biophys.uni-duesseldorf.de) ++.\" May be distributed under the GNU General Public License ++.TH PMAC-FDISK 8 "11 June 1998" "Linux 2.0" "Linux Programmer's Manual" ++.SH NAME ++pmac-fdisk \- Partition table manipulator for Linux ++.SH SYNOPSIS ++.BI "pmac-fdisk [\-u] " device ++.sp ++.BI "pmac-fdisk \-l [\-u] " "device ..." ++.sp ++.BI "pmac-fdisk \-s " "partition ..." ++.sp ++.BI "pmac-fdisk \-v ++.SH DESCRIPTION ++Hard disks can be divided into one or more logical disks called ++.IR partitions . ++This division is described in the ++.I "partition table" ++found in sector 0 of the disk. ++ ++In the BSD world one talks about `disk slices' and a `disklabel'. ++ ++Linux needs at least one partition, namely for its root file system. ++It can use swap files and/or swap partitions, but the latter are more ++efficient. So, usually one will want a second Linux partition ++dedicated as swap partition. ++On Intel compatible hardware, the BIOS that boots the system ++can often only access the first 1024 cylinders of the disk. ++For this reason people with large disks often create a third partition, ++just a few MB large, typically mounted on ++.IR /boot , ++to store the kernel image and a few auxiliary files needed at boot time, ++so as to make sure that this stuff is accessible to the BIOS. ++There may be reasons of security, ease of administration and backup, ++or testing, to use more than the minimum number of partitions. ++ ++.B pmac-fdisk ++(in the first form of invocation) ++is a menu driven program for creation and manipulation of ++partition tables. ++It understands DOS type partition tables and BSD or SUN type disklabels. ++ ++The ++.I device ++is usually one of the following: ++.br ++.nf ++.RS ++/dev/hda ++/dev/hdb ++/dev/sda ++/dev/sdb ++.RE ++.fi ++(/dev/hd[a-h] for IDE disks, /dev/sd[a-p] for SCSI disks). ++A device name refers to the entire disk. ++ ++The ++.I partition ++is a ++.I device ++name followed by a partition number. For example, ++.B /dev/hda1 ++is the first partition on the first IDE hard disk in the system. ++IDE disks can have up to 63 partitions, SCSI disks up to 15. ++See also ++.IR /usr/src/linux/Documentation/devices.txt . ++ ++A BSD/SUN type disklabel can describe 8 partitions, ++the third of which should be a `whole disk' partition. ++Do not start a partition that actually uses its first sector ++(like a swap partition) at cylinder 0, since that will ++destroy the disklabel. ++ ++An IRIX/SGI type disklabel can describe 16 partitions, ++the eleventh of which should be an entire `volume' partition, ++while the ninth should be labeled `volume header'. ++The volume header will also cover the partition table, i.e., ++it starts at block zero and extends by default over five cylinders. ++The remaining space in the volume header may be used by header ++directory entries. No partitions may overlap with the volume header. ++Also do not change its type and make some file system on it, since ++you will lose the partition table. Use this type of label only when ++working with Linux on IRIX/SGI machines or IRIX/SGI disks under Linux. ++ ++A DOS type partition table can describe an unlimited number ++of partitions. In sector 0 there is room for the description ++of 4 partitions (called `primary'). One of these may be an ++extended partition; this is a box holding logical partitions, ++with descriptors found in a linked list of sectors, each ++preceding the corresponding logical partitions. ++The four primary partitions, present or not, get numbers 1-4. ++Logical partitions start numbering from 5. ++ ++In a DOS type partition table the starting offset and the size ++of each partition is stored in two ways: as an absolute number ++of sectors (given in 32 bits) and as a Cylinders/Heads/Sectors ++triple (given in 10+8+6 bits). The former is OK - with 512-byte ++sectors this will work up to 2 TB. The latter has two different ++problems. First of all, these C/H/S fields can be filled only ++when the number of heads and the number of sectors per track ++are known. Secondly, even if we know what these numbers should be, ++the 24 bits that are available do not suffice. ++DOS uses C/H/S only, Windows uses both, Linux never uses C/H/S. ++ ++If possible, ++.B pmac-fdisk ++will obtain the disk geometry automatically. This is not ++necessarily the physical disk geometry (indeed, modern disks do not ++really have anything like a physical geometry, certainly not something ++that can be described in simplistic Cylinders/Heads/Sectors form), ++but is the disk geometry that MS-DOS uses for the partition table. ++ ++Usually all goes well by default, and there are no problems if ++Linux is the only system on the disk. However, if the disk has ++to be shared with other operating systems, it is often a good idea ++to let an fdisk from another operating system make at least one ++partition. When Linux boots it looks at the partition table, and ++tries to deduce what (fake) geometry is required for good ++cooperation with other systems. ++ ++Whenever a partition table is printed out, a consistency check is performed ++on the partition table entries. This check verifies that the physical and ++logical start and end points are identical, and that the partition starts ++and ends on a cylinder boundary (except for the first partition). ++ ++Some versions of MS-DOS create a first partition which does not begin ++on a cylinder boundary, but on sector 2 of the first cylinder. ++Partitions beginning in cylinder 1 cannot begin on a cylinder boundary, but ++this is unlikely to cause difficulty unless you have OS/2 on your machine. ++ ++A sync() and a BLKRRPART ioctl() (reread partition table from disk) ++are performed before exiting when the partition table has been updated. ++Long ago it used to be necessary to reboot after the use of pmac-fdisk. ++I do not think this is the case anymore - indeed, rebooting too quickly ++might cause loss of not-yet-written data. Note that both the kernel ++and the disk hardware may buffer data. ++ ++.SH "DOS 6.x WARNING" ++ ++The DOS 6.x FORMAT command looks for some information in the first ++sector of the data area of the partition, and treats this information ++as more reliable than the information in the partition table. DOS ++FORMAT expects DOS FDISK to clear the first 512 bytes of the data area ++of a partition whenever a size change occurs. DOS FORMAT will look at ++this extra information even if the /U flag is given -- we consider ++this a bug in DOS FORMAT and DOS FDISK. ++ ++The bottom line is that if you use pmac-fdisk to change the size of a ++DOS partition table entry, then you must also use ++.B dd ++to zero the first 512 bytes of that partition before using DOS FORMAT to ++format the partition. For example, if you were using pmac-fdisk to make a ++DOS partition table entry for /dev/hda1, then (after exiting pmac-fdisk ++and rebooting Linux so that the partition table information is valid) you ++would use the command "dd if=/dev/zero of=/dev/hda1 bs=512 count=1" to zero ++the first 512 bytes of the partition. ++ ++.B BE EXTREMELY CAREFUL ++if you use the ++.B dd ++command, since a small typo can make all of the data on your disk useless. ++ ++For best results, you should always use an OS-specific partition table ++program. For example, you should make DOS partitions with the DOS FDISK ++program and Linux partitions with the Linux pmac-fdisk program. ++ ++.SH OPTIONS ++.TP ++.B \-v ++Print version number of ++.B pmac-fdisk ++program and exit. ++.TP ++.B \-l ++List the partition tables for ++.BR /dev/hd[a-d] , ++.BR /dev/sd[a-h] , ++and then exit. ++.TP ++.B \-u ++When listing partition tables, give sizes in sectors instead ++of cylinders. ++.TP ++.BI "\-s " partition ++The ++.I size ++of the partition (in blocks) is printed on the standard output. ++.SH BUGS ++There are several *fdisk programs around. ++Each has its problems and strengths. ++Try them in the order ++.BR cfdisk , ++.BR pmac-fdisk , ++.BR sfdisk . ++(Indeed, ++.B cfdisk ++is a beautiful program that has strict requirements on ++the partition tables it accepts, and produces high quality partition ++tables. Use it if you can. ++.B pmac-fdisk ++is a buggy program that does fuzzy things - usually it happens to ++produce reasonable results. Its single advantage is that it has ++some support for BSD disk labels and other non-DOS partition tables. ++Avoid it if you can. ++.B sfdisk ++is for hackers only - the user interface is terrible, but it is ++more correct than pmac-fdisk and more powerful than both pmac-fdisk and cfdisk. ++Moreover, it can be used noninteractively.) ++.PP ++The IRIX/SGI type disklabel is currently not supported by the kernel. ++Moreover, IRIX/SGI header directories are not fully supported yet. ++.PP ++The option `dump partition table to file' is missing. ++.\" .SH AUTHORS ++.\" A. V. Le Blanc (LeBlanc@mcc.ac.uk) ++.\" Bernhard Fastenrath (fasten@informatik.uni-bonn.de) ++.\" Jakub Jelinek (jj@sunsite.mff.cuni.cz) ++.\" Andreas Neuper (ANeuper@GUUG.de) ++.\" and many others. +--- mac-fdisk-0.1.orig/fdisk.c ++++ mac-fdisk-0.1/fdisk.c +@@ -62,7 +62,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -71,9 +70,9 @@ + + #include + +-#include +-#include +-#include ++typedef unsigned short kdev_t; /* BAD hack; kdev_t is not exported */ ++ ++#include "kernel-defs.h" + + #include "fdisk.h" + +@@ -428,7 +427,7 @@ + offsets[partitions] = extended_offset + SWAP32(p->start_sect); + if (!extended_offset) + extended_offset = SWAP32(p->start_sect); +- if (llseek(fd, (loff_t)offsets[partitions] ++ if (lseek64(fd, (loff_t)offsets[partitions] + * SECTOR_SIZE, SEEK_SET) < 0) + fatal(unable_to_seek); + if (!(buffers[partitions] = (char *) malloc(SECTOR_SIZE))) +@@ -438,14 +437,14 @@ + part_table[partitions] = ext_pointers[partitions] = NULL; + q = p = offset(buffers[partitions], 0); + for (i = 0; i < 4; i++, p++) { +- if (p->sys_ind == EXTENDED) ++ if (p->sys_ind == EXTENDED) { + if (ext_pointers[partitions]) + fprintf(stderr, "Warning: extra link " + "pointer in partition table " + "%d\n", partitions + 1); + else + ext_pointers[partitions] = p; +- else if (p->sys_ind) ++ } else if (p->sys_ind) { + if (part_table[partitions]) + fprintf(stderr, + "Warning: ignoring extra data " +@@ -453,15 +452,18 @@ + partitions + 1); + else + part_table[partitions] = p; ++ } + } +- if (!part_table[partitions]) ++ if (!part_table[partitions]) { + if (q != ext_pointers[partitions]) + part_table[partitions] = q; + else part_table[partitions] = q + 1; +- if (!ext_pointers[partitions]) ++ } ++ if (!ext_pointers[partitions]) { + if (q != part_table[partitions]) + ext_pointers[partitions] = q; + else ext_pointers[partitions] = q + 1; ++ } + p = ext_pointers[partitions++]; + } + } +@@ -497,11 +499,12 @@ + warn_geometry(); + + for (i = 0; i < 4; i++) +- if(part_table[i]->sys_ind == EXTENDED) ++ if(part_table[i]->sys_ind == EXTENDED) { + if (partitions != 4) + fprintf(stderr, "Ignoring extra extended " + "partition %d\n", i + 1); + else read_extended(part_table[ext_index = i]); ++ } + + for (i = 3; i < partitions; i++) + if (SWAP16(*table_check(buffers[i])) != PART_TABLE_FLAG) { +@@ -621,6 +624,7 @@ + case lower: i += low; break; + case upper: i += high; break; + case deflt: i += dflt; break; ++ default: break; + } + } + else +@@ -844,12 +848,12 @@ + return; /* do not check extended partitions */ + + /* physical beginning c, h, s */ +- pbc = p->cyl & 0xff | (p->sector << 2) & 0x300; ++ pbc = (p->cyl & 0xff) | ((p->sector << 2) & 0x300); + pbh = p->head; + pbs = p->sector & 0x3f; + + /* physical ending c, h, s */ +- pec = p->end_cyl & 0xff | (p->end_sector << 2) & 0x300; ++ pec = (p->end_cyl & 0xff) | ((p->end_sector << 2) & 0x300); + peh = p->end_head; + pes = p->end_sector & 0x3f; + +@@ -941,7 +945,7 @@ + disk_device, heads, sectors, cylinders); + printf("Nr AF Hd Sec Cyl Hd Sec Cyl Start Size ID\n"); + for (i = 0 ; i < partitions; i++) +- if (p = q[i]) { ++ if ((p = q[i])) { + printf("%2d %02x%4d%4d%5d%4d%4d%5d%8d%8d %02x\n", + i + 1, p->boot_ind, p->head, + sector(p->sector), +@@ -1026,7 +1030,7 @@ + last[i]); + total += last[i] + 1 - first[i]; + for (j = 0; j < i; j++) +- if (first[i] >= first[j] && first[i] <= last[j] ++ if ((first[i] >= first[j] && first[i] <= last[j]) + || (last[i] <= last[j] && + last[i] >= first[j])) { + printf("Warning: partition %d overlaps " +@@ -1060,11 +1064,11 @@ + if (total > heads * sectors * cylinders) + printf("Total allocated sectors %d greater than the maximum " + "%d\n", total, heads * sectors * cylinders); +- else if (total = heads * sectors * cylinders - total) ++ else if ((total = heads * sectors * cylinders - total)) + printf("%d unallocated sectors\n", total); + } + +-void add_partition(int n, int sys) ++static void add_partition(int n, int sys) + { + char mesg[48]; + int i, read = 0; +@@ -1100,11 +1104,12 @@ + for (i = 0; i < partitions; i++) { + if (start == offsets[i]) + start += sector_offset; +- if (start >= first[i] && start <= last[i]) ++ if (start >= first[i] && start <= last[i]) { + if (n < 4) + start = last[i] + 1; + else + start = last[i] + sector_offset; ++ } + } + if (start > limit) + break; +@@ -1249,7 +1254,7 @@ + for (i = 3; i < partitions; i++) + if (changed[i]) { + *table_check(buffers[i]) = SWAP16(PART_TABLE_FLAG); +- if (llseek(fd, (loff_t)offsets[i] ++ if (lseek64(fd, (loff_t)offsets[i] + * SECTOR_SIZE, SEEK_SET) < 0) + fatal(unable_to_seek); + if (write(fd, buffers[i], SECTOR_SIZE) != SECTOR_SIZE) +@@ -1262,7 +1267,7 @@ + "(Reboot to ensure the partition table has been updated.)\n"); + sync(); + sleep(2); +- if (i = ioctl(fd, BLKRRPART)) { ++ if ((i = ioctl(fd, BLKRRPART))) { + error = errno; + } else { + /* some kernel versions (1.2.x) seem to have trouble +@@ -1270,7 +1275,7 @@ + twice, the second time works. - biro@yggdrasil.com */ + sync(); + sleep(2); +- if(i = ioctl(fd, BLKRRPART)) ++ if((i = ioctl(fd, BLKRRPART))) + error = errno; + } + +@@ -1391,7 +1396,7 @@ + void try(char *device) + { + disk_device = device; +- if (!setjmp(listingbuf)) ++ if (!setjmp(listingbuf)) { + if ((fd = open(disk_device, type_open)) >= 0) { + close(fd); + get_boot(); +@@ -1407,6 +1412,7 @@ + exit(1); + } + } ++ } + } + + void main(int argc, char **argv) +--- mac-fdisk-0.1.orig/dump.c ++++ mac-fdisk-0.1/dump.c @@ -3,7 +3,11 @@ // // Written by Eryk Vershen (eryk@apple.com) @@ -356,383 +895,8 @@ if (p->dpme_lblock_start != 0 || p->dpme_pblocks != p->dpme_lblocks) { printf("(%u @ %u)", p->dpme_lblocks, p->dpme_lblock_start); } ---- fdisk.c -+++ fdisk.c -@@ -62,7 +62,6 @@ - #include - #include - #include --#include - #include - #include - #include -@@ -71,9 +70,9 @@ - - #include - --#include --#include --#include -+typedef unsigned short kdev_t; /* BAD hack; kdev_t is not exported */ -+ -+#include "kernel-defs.h" - - #include "fdisk.h" - -@@ -428,7 +427,7 @@ - offsets[partitions] = extended_offset + SWAP32(p->start_sect); - if (!extended_offset) - extended_offset = SWAP32(p->start_sect); -- if (llseek(fd, (loff_t)offsets[partitions] -+ if (lseek64(fd, (loff_t)offsets[partitions] - * SECTOR_SIZE, SEEK_SET) < 0) - fatal(unable_to_seek); - if (!(buffers[partitions] = (char *) malloc(SECTOR_SIZE))) -@@ -438,14 +437,14 @@ - part_table[partitions] = ext_pointers[partitions] = NULL; - q = p = offset(buffers[partitions], 0); - for (i = 0; i < 4; i++, p++) { -- if (p->sys_ind == EXTENDED) -+ if (p->sys_ind == EXTENDED) { - if (ext_pointers[partitions]) - fprintf(stderr, "Warning: extra link " - "pointer in partition table " - "%d\n", partitions + 1); - else - ext_pointers[partitions] = p; -- else if (p->sys_ind) -+ } else if (p->sys_ind) { - if (part_table[partitions]) - fprintf(stderr, - "Warning: ignoring extra data " -@@ -453,15 +452,18 @@ - partitions + 1); - else - part_table[partitions] = p; -+ } - } -- if (!part_table[partitions]) -+ if (!part_table[partitions]) { - if (q != ext_pointers[partitions]) - part_table[partitions] = q; - else part_table[partitions] = q + 1; -- if (!ext_pointers[partitions]) -+ } -+ if (!ext_pointers[partitions]) { - if (q != part_table[partitions]) - ext_pointers[partitions] = q; - else ext_pointers[partitions] = q + 1; -+ } - p = ext_pointers[partitions++]; - } - } -@@ -497,11 +499,12 @@ - warn_geometry(); - - for (i = 0; i < 4; i++) -- if(part_table[i]->sys_ind == EXTENDED) -+ if(part_table[i]->sys_ind == EXTENDED) { - if (partitions != 4) - fprintf(stderr, "Ignoring extra extended " - "partition %d\n", i + 1); - else read_extended(part_table[ext_index = i]); -+ } - - for (i = 3; i < partitions; i++) - if (SWAP16(*table_check(buffers[i])) != PART_TABLE_FLAG) { -@@ -621,6 +624,7 @@ - case lower: i += low; break; - case upper: i += high; break; - case deflt: i += dflt; break; -+ default: break; - } - } - else -@@ -844,12 +848,12 @@ - return; /* do not check extended partitions */ - - /* physical beginning c, h, s */ -- pbc = p->cyl & 0xff | (p->sector << 2) & 0x300; -+ pbc = (p->cyl & 0xff) | ((p->sector << 2) & 0x300); - pbh = p->head; - pbs = p->sector & 0x3f; - - /* physical ending c, h, s */ -- pec = p->end_cyl & 0xff | (p->end_sector << 2) & 0x300; -+ pec = (p->end_cyl & 0xff) | ((p->end_sector << 2) & 0x300); - peh = p->end_head; - pes = p->end_sector & 0x3f; - -@@ -941,7 +945,7 @@ - disk_device, heads, sectors, cylinders); - printf("Nr AF Hd Sec Cyl Hd Sec Cyl Start Size ID\n"); - for (i = 0 ; i < partitions; i++) -- if (p = q[i]) { -+ if ((p = q[i])) { - printf("%2d %02x%4d%4d%5d%4d%4d%5d%8d%8d %02x\n", - i + 1, p->boot_ind, p->head, - sector(p->sector), -@@ -1026,7 +1030,7 @@ - last[i]); - total += last[i] + 1 - first[i]; - for (j = 0; j < i; j++) -- if (first[i] >= first[j] && first[i] <= last[j] -+ if ((first[i] >= first[j] && first[i] <= last[j]) - || (last[i] <= last[j] && - last[i] >= first[j])) { - printf("Warning: partition %d overlaps " -@@ -1060,11 +1064,11 @@ - if (total > heads * sectors * cylinders) - printf("Total allocated sectors %d greater than the maximum " - "%d\n", total, heads * sectors * cylinders); -- else if (total = heads * sectors * cylinders - total) -+ else if ((total = heads * sectors * cylinders - total)) - printf("%d unallocated sectors\n", total); - } - --void add_partition(int n, int sys) -+static void add_partition(int n, int sys) - { - char mesg[48]; - int i, read = 0; -@@ -1100,11 +1104,12 @@ - for (i = 0; i < partitions; i++) { - if (start == offsets[i]) - start += sector_offset; -- if (start >= first[i] && start <= last[i]) -+ if (start >= first[i] && start <= last[i]) { - if (n < 4) - start = last[i] + 1; - else - start = last[i] + sector_offset; -+ } - } - if (start > limit) - break; -@@ -1249,7 +1254,7 @@ - for (i = 3; i < partitions; i++) - if (changed[i]) { - *table_check(buffers[i]) = SWAP16(PART_TABLE_FLAG); -- if (llseek(fd, (loff_t)offsets[i] -+ if (lseek64(fd, (loff_t)offsets[i] - * SECTOR_SIZE, SEEK_SET) < 0) - fatal(unable_to_seek); - if (write(fd, buffers[i], SECTOR_SIZE) != SECTOR_SIZE) -@@ -1262,7 +1267,7 @@ - "(Reboot to ensure the partition table has been updated.)\n"); - sync(); - sleep(2); -- if (i = ioctl(fd, BLKRRPART)) { -+ if ((i = ioctl(fd, BLKRRPART))) { - error = errno; - } else { - /* some kernel versions (1.2.x) seem to have trouble -@@ -1270,7 +1275,7 @@ - twice, the second time works. - biro@yggdrasil.com */ - sync(); - sleep(2); -- if(i = ioctl(fd, BLKRRPART)) -+ if((i = ioctl(fd, BLKRRPART))) - error = errno; - } - -@@ -1391,7 +1396,7 @@ - void try(char *device) - { - disk_device = device; -- if (!setjmp(listingbuf)) -+ if (!setjmp(listingbuf)) { - if ((fd = open(disk_device, type_open)) >= 0) { - close(fd); - get_boot(); -@@ -1407,6 +1412,7 @@ - exit(1); - } - } -+ } - } - - void main(int argc, char **argv) ---- fdisklabel.c -+++ fdisklabel.c -@@ -38,7 +38,6 @@ - #include - #include - #include --#include - #include - #include - #include -@@ -47,9 +46,7 @@ - #include - #include - --#include --#include --#include -+#include "kernel-defs.h" - - #include "fdisk.h" - #define DKTYPENAMES -@@ -377,7 +374,7 @@ - { - #if defined (i386) - if (bsd_initlabel (bsd_part, &bsd_dlabel, bsd_part_index) == 1) --#elif defined (__alpha__) || defined (__powerpc__) -+#elif defined (__alpha__) || defined (__powerpc__) || defined (__mc68000__) - if (bsd_initlabel (NULL, &bsd_dlabel, 0) == 1) - #endif - { -@@ -515,7 +512,7 @@ - alpha_bootblock_checksum (buffer); - #endif - -- if (llseek (fd, sector * SECTOR_SIZE, SEEK_SET) == -1) -+ if (lseek64 (fd, sector * SECTOR_SIZE, SEEK_SET) == -1) - fatal (unable_to_seek); - if (BSD_BBSIZE != write (fd, buffer, BSD_BBSIZE)) - fatal (unable_to_write); -@@ -679,7 +676,7 @@ - sector = 0; - #endif - -- if (llseek (fd, sector * SECTOR_SIZE, SEEK_SET) == -1) -+ if (lseek64 (fd, sector * SECTOR_SIZE, SEEK_SET) == -1) - fatal (unable_to_seek); - if (BSD_BBSIZE != read (fd, buffer, BSD_BBSIZE)) - fatal (unable_to_read); -@@ -724,12 +721,12 @@ - - #if defined (__alpha__) && BSD_LABELSECTOR == 0 - alpha_bootblock_checksum (buffer); -- if (llseek (fd, 0, SEEK_SET) == -1) -+ if (lseek64 (fd, 0, SEEK_SET) == -1) - fatal (unable_to_seek); - if (BSD_BBSIZE != write (fd, buffer, BSD_BBSIZE)) - fatal (unable_to_write); - #else -- if (llseek (fd, sector * SECTOR_SIZE + BSD_LABELOFFSET, SEEK_SET) == -1) -+ if (lseek64 (fd, sector * SECTOR_SIZE + BSD_LABELOFFSET, SEEK_SET) == -1) - fatal (unable_to_seek); - if (sizeof (struct disklabel) != write (fd, d, sizeof (struct disklabel))) - fatal (unable_to_write); ---- fdisklabel.h -+++ fdisklabel.h -@@ -52,6 +52,12 @@ - #define BSD_LABELOFFSET 0 - #define BSD_BBSIZE 0 - #define BSD_SBSIZE 0 -+#elif defined (__mc68000__) -+/* LABELSECTOR, LABELOFFSET, BBSIZE & SBSIZE are undefined for __powerpc__ */ -+#define BSD_LABELSECTOR 0 -+#define BSD_LABELOFFSET 0 -+#define BSD_BBSIZE 0 -+#define BSD_SBSIZE 0 - #else - #error unknown architecture - #endif ---- io.c -+++ io.c -@@ -30,6 +30,10 @@ - #include - #include - #include -+#else -+#ifdef __GLIBC__ -+#include -+#endif - #endif - #include - #include -@@ -51,6 +55,8 @@ - #define SCSI_FD 8 - #define loff_t long - #define llseek lseek -+#else -+#define llseek lseek64 - #endif - - -@@ -435,8 +441,8 @@ - #else - { - #endif -- x = num * PBLOCK_SIZE; -- if ((x = llseek(fd, x, 0)) < 0) { -+ x = ((long long) num * PBLOCK_SIZE); /* cast to ll to work around compiler bug */ -+ if ((x = lseek64(fd, x, 0)) < 0) { - if (quiet == 0) { - error(errno, "Can't seek on file"); - } ---- kernel-defs.h -+++ kernel-defs.h -@@ -0,0 +1,64 @@ -+/* from asm/types.h */ -+typedef unsigned short __u16; -+typedef unsigned int __u32; -+ -+/* from linux/hdreg.h */ -+#define HDIO_GETGEO 0x0301 /* get device geometry */ -+ -+struct hd_geometry { -+ unsigned char heads; -+ unsigned char sectors; -+ unsigned short cylinders; -+ unsigned long start; -+}; -+ -+/* from asm/ioctl.h */ -+#define _IOC_NRBITS 8 -+#define _IOC_TYPEBITS 8 -+#define _IOC_SIZEBITS 13 -+#define _IOC_DIRBITS 3 -+ -+#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) -+#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) -+#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) -+#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) -+ -+#define _IOC_NRSHIFT 0 -+#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) -+#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) -+#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) -+ -+#ifdef __powerpc__ -+#define _IOC_NONE 1U -+#define _IOC_READ 2U -+#define _IOC_WRITE 4U -+#else -+#define _IOC_NONE 0U -+#define _IOC_READ 2U -+#define _IOC_WRITE 1U -+#endif -+ -+#define _IOC(dir,type,nr,size) \ -+ (((dir) << _IOC_DIRSHIFT) | \ -+ ((type) << _IOC_TYPESHIFT) | \ -+ ((nr) << _IOC_NRSHIFT) | \ -+ ((size) << _IOC_SIZESHIFT)) -+#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) -+ -+/* from linux/fs.h */ -+#define BLKRRPART _IO(0x12,95) /* re-read partition table */ -+#define BLKFLSBUF _IO(0x12,97) /* flush buffer cache */ -+ -+/* from linux/genhd.h */ -+struct partition { -+ unsigned char boot_ind; /* 0x80 - active */ -+ unsigned char head; /* starting head */ -+ unsigned char sector; /* starting sector */ -+ unsigned char cyl; /* starting cylinder */ -+ unsigned char sys_ind; /* What partition type */ -+ unsigned char end_head; /* end head */ -+ unsigned char end_sector; /* end sector */ -+ unsigned char end_cyl; /* end cylinder */ -+ unsigned int start_sect; /* starting sector counting from 0 */ -+ unsigned int nr_sects; /* nr of sectors in partition */ -+} __attribute__((packed)); ---- mac-fdisk.8 -+++ mac-fdisk.8 +--- mac-fdisk-0.1.orig/mac-fdisk.8.in ++++ mac-fdisk-0.1/mac-fdisk.8.in @@ -0,0 +1,262 @@ +.TH MAC-FDISK 8 "1 December 2001" "Debian" "Apple Disk Partitioning Manual" +.SH NAME @@ -996,8 +1160,41 @@ +.BR mkfs (8) +.SH AUTHOR +Eryk Vershen (eryk@apple.com), man page revised by Chris Tillman (tillman@azstarnet.com) ---- partition_map.c -+++ partition_map.c +--- mac-fdisk-0.1.orig/io.c ++++ mac-fdisk-0.1/io.c +@@ -30,6 +30,10 @@ + #include + #include + #include ++#else ++#ifdef __GLIBC__ ++#include ++#endif + #endif + #include + #include +@@ -51,6 +55,8 @@ + #define SCSI_FD 8 + #define loff_t long + #define llseek lseek ++#else ++#define llseek lseek64 + #endif + + +@@ -435,8 +441,8 @@ + #else + { + #endif +- x = num * PBLOCK_SIZE; +- if ((x = llseek(fd, x, 0)) < 0) { ++ x = ((long long) num * PBLOCK_SIZE); /* cast to ll to work around compiler bug */ ++ if ((x = lseek64(fd, x, 0)) < 0) { + if (quiet == 0) { + error(errno, "Can't seek on file"); + } +--- mac-fdisk-0.1.orig/partition_map.c ++++ mac-fdisk-0.1/partition_map.c @@ -30,14 +30,12 @@ #include #include @@ -1097,8 +1294,8 @@ cur->disk_address = index; insert_in_disk_order(cur); renumber_disk_addresses(map); ---- partition_map.h -+++ partition_map.h +--- mac-fdisk-0.1.orig/partition_map.h ++++ mac-fdisk-0.1/partition_map.h @@ -69,6 +69,8 @@ extern const char * kFreeType; extern const char * kMapType; @@ -1108,363 +1305,151 @@ extern const char * kFreeName; ---- pdisk.c -+++ pdisk.c -@@ -30,18 +30,17 @@ - #include - #ifdef __linux__ - #include -+#include - #else - #include +--- mac-fdisk-0.1.orig/kernel-defs.h ++++ mac-fdisk-0.1/kernel-defs.h +@@ -0,0 +1,64 @@ ++/* from asm/types.h */ ++typedef unsigned short __u16; ++typedef unsigned int __u32; ++ ++/* from linux/hdreg.h */ ++#define HDIO_GETGEO 0x0301 /* get device geometry */ ++ ++struct hd_geometry { ++ unsigned char heads; ++ unsigned char sectors; ++ unsigned short cylinders; ++ unsigned long start; ++}; ++ ++/* from asm/ioctl.h */ ++#define _IOC_NRBITS 8 ++#define _IOC_TYPEBITS 8 ++#define _IOC_SIZEBITS 13 ++#define _IOC_DIRBITS 3 ++ ++#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) ++#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) ++#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) ++#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) ++ ++#define _IOC_NRSHIFT 0 ++#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) ++#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) ++#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) ++ ++#ifdef __powerpc__ ++#define _IOC_NONE 1U ++#define _IOC_READ 2U ++#define _IOC_WRITE 4U ++#else ++#define _IOC_NONE 0U ++#define _IOC_READ 2U ++#define _IOC_WRITE 1U ++#endif ++ ++#define _IOC(dir,type,nr,size) \ ++ (((dir) << _IOC_DIRSHIFT) | \ ++ ((type) << _IOC_TYPESHIFT) | \ ++ ((nr) << _IOC_NRSHIFT) | \ ++ ((size) << _IOC_SIZESHIFT)) ++#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) ++ ++/* from linux/fs.h */ ++#define BLKRRPART _IO(0x12,95) /* re-read partition table */ ++#define BLKFLSBUF _IO(0x12,97) /* flush buffer cache */ ++ ++/* from linux/genhd.h */ ++struct partition { ++ unsigned char boot_ind; /* 0x80 - active */ ++ unsigned char head; /* starting head */ ++ unsigned char sector; /* starting sector */ ++ unsigned char cyl; /* starting cylinder */ ++ unsigned char sys_ind; /* What partition type */ ++ unsigned char end_head; /* end head */ ++ unsigned char end_sector; /* end sector */ ++ unsigned char end_cyl; /* end cylinder */ ++ unsigned int start_sect; /* starting sector counting from 0 */ ++ unsigned int nr_sects; /* nr of sectors in partition */ ++} __attribute__((packed)); +--- mac-fdisk-0.1.orig/Makefile ++++ mac-fdisk-0.1/Makefile +@@ -5,7 +5,14 @@ + fdisk: fdisk.o fdisklabel.o + + clean: +- rm -f *.o pdisk fdisk ++ rm -f *.o pdisk fdisk mac-fdisk pmac-fdisk ++ ++install: pdisk fdisk ++ -rm -f pmac-fdisk mac-fdisk ++ ln pdisk mac-fdisk ++ ln fdisk pmac-fdisk ++ install -o root -g root -m 0755 mac-fdisk ${DESTDIR}/sbin ++ install -o root -g root -m 0755 pmac-fdisk ${DESTDIR}/sbin + + distribution: + cd ..; tar cvf pdisk.src.tar.`date +%y%m%d` --files-from pdisk/list.src +--- mac-fdisk-0.1.orig/fdisklabel.c ++++ mac-fdisk-0.1/fdisklabel.c +@@ -38,7 +38,6 @@ #include - #include - #endif + #include + #include -#include - #include - - #ifdef __linux__ + #include + #include + #include +@@ -47,9 +46,7 @@ #include --#include + #include + +-#include -#include +-#include +#include "kernel-defs.h" + + #include "fdisk.h" + #define DKTYPENAMES +@@ -377,7 +374,7 @@ + { + #if defined (i386) + if (bsd_initlabel (bsd_part, &bsd_dlabel, bsd_part_index) == 1) +-#elif defined (__alpha__) || defined (__powerpc__) ++#elif defined (__alpha__) || defined (__powerpc__) || defined (__mc68000__) + if (bsd_initlabel (NULL, &bsd_dlabel, 0) == 1) + #endif + { +@@ -515,7 +512,7 @@ + alpha_bootblock_checksum (buffer); #endif - #include "pdisk.h" -@@ -94,6 +93,7 @@ - void do_add_intel_partition(partition_map_header *map); - void do_change_map_size(partition_map_header *map); - void do_create_partition(partition_map_header *map, int get_type); -+void do_create_bootstrap_partition(partition_map_header *map); - void do_delete_partition(partition_map_header *map); - int do_expert(partition_map_header *map); - void do_reorder(partition_map_header *map); -@@ -114,6 +114,7 @@ - main(int argc, char **argv) - { - int name_index; -+ int err=0; +- if (llseek (fd, sector * SECTOR_SIZE, SEEK_SET) == -1) ++ if (lseek64 (fd, sector * SECTOR_SIZE, SEEK_SET) == -1) + fatal (unable_to_seek); + if (BSD_BBSIZE != write (fd, buffer, BSD_BBSIZE)) + fatal (unable_to_write); +@@ -679,7 +676,7 @@ + sector = 0; + #endif - if (sizeof(DPME) != PBLOCK_SIZE) { - fatal(-1, "Size of partion map entry (%d) " -@@ -150,7 +151,9 @@ - } else if (!vflag) { - usage("no device argument"); - do_help(); -+ err=-EINVAL; // debatable - } -+ exit(err); - } +- if (llseek (fd, sector * SECTOR_SIZE, SEEK_SET) == -1) ++ if (lseek64 (fd, sector * SECTOR_SIZE, SEEK_SET) == -1) + fatal (unable_to_seek); + if (BSD_BBSIZE != read (fd, buffer, BSD_BBSIZE)) + fatal (unable_to_read); +@@ -724,12 +721,12 @@ + + #if defined (__alpha__) && BSD_LABELSECTOR == 0 + alpha_bootblock_checksum (buffer); +- if (llseek (fd, 0, SEEK_SET) == -1) ++ if (lseek64 (fd, 0, SEEK_SET) == -1) + fatal (unable_to_seek); + if (BSD_BBSIZE != write (fd, buffer, BSD_BBSIZE)) + fatal (unable_to_write); #else - main() -@@ -351,7 +354,8 @@ - printf(" P (print ordered by base address)\n"); - printf(" i initialize partition map\n"); - printf(" s change size of partition map\n"); -- printf(" c create new partition\n"); -+ printf(" b create new 800K bootstrap partition\n"); -+ printf(" c create new Linux partition\n"); - printf(" C (create with type also specified)\n"); - printf(" d delete a partition\n"); - printf(" r reorder partition entry in map\n"); -@@ -378,6 +382,10 @@ - case 'i': - map = init_partition_map(name, map); - break; -+ case 'B': -+ case 'b': -+ do_create_bootstrap_partition(map); -+ break; - case 'C': - get_type = 1; - // fall through -@@ -471,6 +479,30 @@ - } - - -+void -+do_create_bootstrap_partition(partition_map_header *map) -+{ -+ long base; -+ -+ if (map == NULL) { -+ bad_input("No partition map exists"); -+ return; -+ } -+ -+ if (!rflag && map->writeable == 0) { -+ printf("The map is not writeable.\n"); -+ } -+ -+ // XXX add help feature (i.e. '?' in any argument routine prints help string) -+ if (get_base_argument(&base, map) == 0) { -+ return; -+ } -+ -+ // create 800K type Apple_Bootstrap partition named `bootstrap' -+ add_partition_to_map(kBootstrapName, kBootstrapType, base, 1600, map); -+} -+ -+ - int - get_base_argument(long *number, partition_map_header *map) - { -@@ -508,7 +540,7 @@ - int result = 0; - long multiple; - -- if (get_number_argument("Length in blocks: ", number, kDefault) == 0) { -+ if (get_number_argument("Length (in blocks, kB (k), MB (M) or GB (G)): ", number, kDefault) == 0) { - bad_input("Bad length"); - } else { - result = 1; -@@ -605,13 +637,22 @@ - bad_input("The map is not writeable."); - return; - } -- printf("Writing the map destroys what was there before. "); -- if (get_okay("Is that okay? [n/y]: ", 0) != 1) { -+// printf("Writing the map destroys what was there before. "); -+ printf("IMPORTANT: You are about to write a changed partition map to disk. \n"); -+ printf("For any partition you changed the start or size of, writing out \n"); -+ printf("the map causes all data on that partition to be LOST FOREVER. \n"); -+ printf("Make sure you have a backup of any data on such partitions you \n"); -+ printf("want to keep before answering 'yes' to the question below! \n\n"); -+ if (get_okay("Write partition map? [n/y]: ", 0) != 1) { - return; - } - - write_partition_map(map); - -+ printf("\nPartition map written to disk. If any partitions on this disk \n"); -+ printf("were still in use by the system (see messages above), you will need \n"); -+ printf("to reboot in order to utilize the new partition map.\n\n"); -+ - // exit(0); - } - ---- pmac-fdisk.8 -+++ pmac-fdisk.8 -@@ -0,0 +1,222 @@ -+.\" Copyright 1992, 1993 Rickard E. Faith (faith@cs.unc.edu) -+.\" Copyright 1998 Andries E. Brouwer (aeb@cwi.nl) -+.\" Copyright 2000 Michael Schmitz (schmitz@biophys.uni-duesseldorf.de) -+.\" May be distributed under the GNU General Public License -+.TH PMAC-FDISK 8 "11 June 1998" "Linux 2.0" "Linux Programmer's Manual" -+.SH NAME -+pmac-fdisk \- Partition table manipulator for Linux -+.SH SYNOPSIS -+.BI "pmac-fdisk [\-u] " device -+.sp -+.BI "pmac-fdisk \-l [\-u] " "device ..." -+.sp -+.BI "pmac-fdisk \-s " "partition ..." -+.sp -+.BI "pmac-fdisk \-v -+.SH DESCRIPTION -+Hard disks can be divided into one or more logical disks called -+.IR partitions . -+This division is described in the -+.I "partition table" -+found in sector 0 of the disk. -+ -+In the BSD world one talks about `disk slices' and a `disklabel'. -+ -+Linux needs at least one partition, namely for its root file system. -+It can use swap files and/or swap partitions, but the latter are more -+efficient. So, usually one will want a second Linux partition -+dedicated as swap partition. -+On Intel compatible hardware, the BIOS that boots the system -+can often only access the first 1024 cylinders of the disk. -+For this reason people with large disks often create a third partition, -+just a few MB large, typically mounted on -+.IR /boot , -+to store the kernel image and a few auxiliary files needed at boot time, -+so as to make sure that this stuff is accessible to the BIOS. -+There may be reasons of security, ease of administration and backup, -+or testing, to use more than the minimum number of partitions. -+ -+.B pmac-fdisk -+(in the first form of invocation) -+is a menu driven program for creation and manipulation of -+partition tables. -+It understands DOS type partition tables and BSD or SUN type disklabels. -+ -+The -+.I device -+is usually one of the following: -+.br -+.nf -+.RS -+/dev/hda -+/dev/hdb -+/dev/sda -+/dev/sdb -+.RE -+.fi -+(/dev/hd[a-h] for IDE disks, /dev/sd[a-p] for SCSI disks). -+A device name refers to the entire disk. -+ -+The -+.I partition -+is a -+.I device -+name followed by a partition number. For example, -+.B /dev/hda1 -+is the first partition on the first IDE hard disk in the system. -+IDE disks can have up to 63 partitions, SCSI disks up to 15. -+See also -+.IR /usr/src/linux/Documentation/devices.txt . -+ -+A BSD/SUN type disklabel can describe 8 partitions, -+the third of which should be a `whole disk' partition. -+Do not start a partition that actually uses its first sector -+(like a swap partition) at cylinder 0, since that will -+destroy the disklabel. -+ -+An IRIX/SGI type disklabel can describe 16 partitions, -+the eleventh of which should be an entire `volume' partition, -+while the ninth should be labeled `volume header'. -+The volume header will also cover the partition table, i.e., -+it starts at block zero and extends by default over five cylinders. -+The remaining space in the volume header may be used by header -+directory entries. No partitions may overlap with the volume header. -+Also do not change its type and make some file system on it, since -+you will lose the partition table. Use this type of label only when -+working with Linux on IRIX/SGI machines or IRIX/SGI disks under Linux. -+ -+A DOS type partition table can describe an unlimited number -+of partitions. In sector 0 there is room for the description -+of 4 partitions (called `primary'). One of these may be an -+extended partition; this is a box holding logical partitions, -+with descriptors found in a linked list of sectors, each -+preceding the corresponding logical partitions. -+The four primary partitions, present or not, get numbers 1-4. -+Logical partitions start numbering from 5. -+ -+In a DOS type partition table the starting offset and the size -+of each partition is stored in two ways: as an absolute number -+of sectors (given in 32 bits) and as a Cylinders/Heads/Sectors -+triple (given in 10+8+6 bits). The former is OK - with 512-byte -+sectors this will work up to 2 TB. The latter has two different -+problems. First of all, these C/H/S fields can be filled only -+when the number of heads and the number of sectors per track -+are known. Secondly, even if we know what these numbers should be, -+the 24 bits that are available do not suffice. -+DOS uses C/H/S only, Windows uses both, Linux never uses C/H/S. -+ -+If possible, -+.B pmac-fdisk -+will obtain the disk geometry automatically. This is not -+necessarily the physical disk geometry (indeed, modern disks do not -+really have anything like a physical geometry, certainly not something -+that can be described in simplistic Cylinders/Heads/Sectors form), -+but is the disk geometry that MS-DOS uses for the partition table. -+ -+Usually all goes well by default, and there are no problems if -+Linux is the only system on the disk. However, if the disk has -+to be shared with other operating systems, it is often a good idea -+to let an fdisk from another operating system make at least one -+partition. When Linux boots it looks at the partition table, and -+tries to deduce what (fake) geometry is required for good -+cooperation with other systems. -+ -+Whenever a partition table is printed out, a consistency check is performed -+on the partition table entries. This check verifies that the physical and -+logical start and end points are identical, and that the partition starts -+and ends on a cylinder boundary (except for the first partition). -+ -+Some versions of MS-DOS create a first partition which does not begin -+on a cylinder boundary, but on sector 2 of the first cylinder. -+Partitions beginning in cylinder 1 cannot begin on a cylinder boundary, but -+this is unlikely to cause difficulty unless you have OS/2 on your machine. -+ -+A sync() and a BLKRRPART ioctl() (reread partition table from disk) -+are performed before exiting when the partition table has been updated. -+Long ago it used to be necessary to reboot after the use of pmac-fdisk. -+I do not think this is the case anymore - indeed, rebooting too quickly -+might cause loss of not-yet-written data. Note that both the kernel -+and the disk hardware may buffer data. -+ -+.SH "DOS 6.x WARNING" -+ -+The DOS 6.x FORMAT command looks for some information in the first -+sector of the data area of the partition, and treats this information -+as more reliable than the information in the partition table. DOS -+FORMAT expects DOS FDISK to clear the first 512 bytes of the data area -+of a partition whenever a size change occurs. DOS FORMAT will look at -+this extra information even if the /U flag is given -- we consider -+this a bug in DOS FORMAT and DOS FDISK. -+ -+The bottom line is that if you use pmac-fdisk to change the size of a -+DOS partition table entry, then you must also use -+.B dd -+to zero the first 512 bytes of that partition before using DOS FORMAT to -+format the partition. For example, if you were using pmac-fdisk to make a -+DOS partition table entry for /dev/hda1, then (after exiting pmac-fdisk -+and rebooting Linux so that the partition table information is valid) you -+would use the command "dd if=/dev/zero of=/dev/hda1 bs=512 count=1" to zero -+the first 512 bytes of the partition. -+ -+.B BE EXTREMELY CAREFUL -+if you use the -+.B dd -+command, since a small typo can make all of the data on your disk useless. -+ -+For best results, you should always use an OS-specific partition table -+program. For example, you should make DOS partitions with the DOS FDISK -+program and Linux partitions with the Linux pmac-fdisk program. -+ -+.SH OPTIONS -+.TP -+.B \-v -+Print version number of -+.B pmac-fdisk -+program and exit. -+.TP -+.B \-l -+List the partition tables for -+.BR /dev/hd[a-d] , -+.BR /dev/sd[a-h] , -+and then exit. -+.TP -+.B \-u -+When listing partition tables, give sizes in sectors instead -+of cylinders. -+.TP -+.BI "\-s " partition -+The -+.I size -+of the partition (in blocks) is printed on the standard output. -+.SH BUGS -+There are several *fdisk programs around. -+Each has its problems and strengths. -+Try them in the order -+.BR cfdisk , -+.BR pmac-fdisk , -+.BR sfdisk . -+(Indeed, -+.B cfdisk -+is a beautiful program that has strict requirements on -+the partition tables it accepts, and produces high quality partition -+tables. Use it if you can. -+.B pmac-fdisk -+is a buggy program that does fuzzy things - usually it happens to -+produce reasonable results. Its single advantage is that it has -+some support for BSD disk labels and other non-DOS partition tables. -+Avoid it if you can. -+.B sfdisk -+is for hackers only - the user interface is terrible, but it is -+more correct than pmac-fdisk and more powerful than both pmac-fdisk and cfdisk. -+Moreover, it can be used noninteractively.) -+.PP -+The IRIX/SGI type disklabel is currently not supported by the kernel. -+Moreover, IRIX/SGI header directories are not fully supported yet. -+.PP -+The option `dump partition table to file' is missing. -+.\" .SH AUTHORS -+.\" A. V. Le Blanc (LeBlanc@mcc.ac.uk) -+.\" Bernhard Fastenrath (fasten@informatik.uni-bonn.de) -+.\" Jakub Jelinek (jj@sunsite.mff.cuni.cz) -+.\" Andreas Neuper (ANeuper@GUUG.de) -+.\" and many others. +- if (llseek (fd, sector * SECTOR_SIZE + BSD_LABELOFFSET, SEEK_SET) == -1) ++ if (lseek64 (fd, sector * SECTOR_SIZE + BSD_LABELOFFSET, SEEK_SET) == -1) + fatal (unable_to_seek); + if (sizeof (struct disklabel) != write (fd, d, sizeof (struct disklabel))) + fatal (unable_to_write); diff --git a/srcpkgs/mac-fdisk/patches/02-mac-fdisk-0.1-headers.patch b/srcpkgs/mac-fdisk/patches/mac-fdisk-0.1-headers.patch similarity index 89% rename from srcpkgs/mac-fdisk/patches/02-mac-fdisk-0.1-headers.patch rename to srcpkgs/mac-fdisk/patches/mac-fdisk-0.1-headers.patch index 079db450c1e..2ac7eaf4153 100644 --- a/srcpkgs/mac-fdisk/patches/02-mac-fdisk-0.1-headers.patch +++ b/srcpkgs/mac-fdisk/patches/mac-fdisk-0.1-headers.patch @@ -1,7 +1,7 @@ Include a lot more headers and remove a bunch of braindead __linux__ checks ---- dump.c -+++ dump.c +--- a/dump.c ++++ b/dump.c @@ -30,10 +30,8 @@ */ @@ -13,8 +13,8 @@ Include a lot more headers and remove a bunch of braindead __linux__ checks #include #include #include ---- errors.c -+++ errors.c +--- a/errors.c ++++ b/errors.c @@ -26,9 +26,7 @@ */ @@ -47,8 +47,8 @@ Include a lot more headers and remove a bunch of braindead __linux__ checks } else { fprintf(stderr, "\n"); } ---- fdisk.c -+++ fdisk.c +--- a/fdisk.c ++++ b/fdisk.c @@ -62,6 +62,7 @@ #include #include @@ -57,8 +57,8 @@ Include a lot more headers and remove a bunch of braindead __linux__ checks #include #include #include ---- fdisklabel.c -+++ fdisklabel.c +--- a/fdisklabel.c ++++ b/fdisklabel.c @@ -38,6 +38,7 @@ #include #include @@ -67,8 +67,8 @@ Include a lot more headers and remove a bunch of braindead __linux__ checks #include #include #include ---- io.c -+++ io.c +--- a/io.c ++++ b/io.c @@ -26,9 +26,9 @@ */ @@ -80,8 +80,8 @@ Include a lot more headers and remove a bunch of braindead __linux__ checks #include #else #ifdef __GLIBC__ ---- partition_map.c -+++ partition_map.c +--- a/partition_map.c ++++ b/partition_map.c @@ -26,10 +26,9 @@ */ @@ -94,8 +94,8 @@ Include a lot more headers and remove a bunch of braindead __linux__ checks #include #include ---- pdisk.c -+++ pdisk.c +--- a/pdisk.c ++++ b/pdisk.c @@ -32,10 +32,11 @@ #include #include diff --git a/srcpkgs/mac-fdisk/patches/mac-fdisk-0.1-more-arches.patch b/srcpkgs/mac-fdisk/patches/mac-fdisk-0.1-more-arches.patch new file mode 100644 index 00000000000..086362844b8 --- /dev/null +++ b/srcpkgs/mac-fdisk/patches/mac-fdisk-0.1-more-arches.patch @@ -0,0 +1,67 @@ +--- mac-fdisk-0.1.orig/fdisklabel.h.old 1997-01-14 20:34:13.000000000 +0000 ++++ mac-fdisk-0.1.orig/fdisklabel.h 2018-06-01 06:13:09.065722112 +0000 +@@ -35,27 +35,23 @@ + #define BSD_MAXPARTITIONS 8 + #define BSD_LINUX_BOOTDIR "/usr/ucb/mdec" + +-#if defined (i386) ++/* Thanks, util-linux! */ ++#if defined (i386) || defined (__sparc__) || defined (__arm__) || defined (__mips__) || defined (__s390__) || defined (__sh__) || defined(__x86_64__) + #define BSD_LABELSECTOR 1 + #define BSD_LABELOFFSET 0 +-#define BSD_BBSIZE 8192 /* size of boot area, with label */ +-#define BSD_SBSIZE 8192 /* max size of fs superblock */ +-#elif defined (__alpha__) +-#error LABELSECTOR, LABELOFFSET, BBSIZE & SBSIZE are undefined for __alpha__ +-#define BSD_LABELSECTOR 0 +-#define BSD_LABELOFFSET 0 +-#define BSD_BBSIZE 0 +-#define BSD_SBSIZE 0 +-#elif defined (__powerpc__) +-/* LABELSECTOR, LABELOFFSET, BBSIZE & SBSIZE are undefined for __powerpc__ */ ++#elif defined (__alpha__) || defined (__powerpc__) || defined (__ia64__) || defined (__hppa__) + #define BSD_LABELSECTOR 0 ++#define BSD_LABELOFFSET 64 ++#elif defined (__s390__) || defined (__s390x__) ++#define BSD_LABELSECTOR 1 + #define BSD_LABELOFFSET 0 +-#define BSD_BBSIZE 0 +-#define BSD_SBSIZE 0 + #else + #error unknown architecture + #endif + ++#define BSD_BBSIZE 8192 /* size of boot area, with label */ ++#define BSD_SBSIZE 8192 /* max size of fs superblock */ ++ + struct disklabel { + u_long d_magic; /* the magic number */ + short d_type; /* drive type */ +--- mac-fdisk-0.1.orig/fdisklabel.c.old 2018-06-01 06:19:35.113347714 +0000 ++++ mac-fdisk-0.1.orig/fdisklabel.c 2018-06-01 06:20:36.734576024 +0000 +@@ -82,10 +82,8 @@ + + static struct disklabel bsd_dlabel; + static char buffer[BSD_BBSIZE]; +-#if defined (i386) + static struct partition *bsd_part; + static int bsd_part_index; +-#endif + + void + bmenu (void) +@@ -373,10 +371,11 @@ + while (1) + if ((c = tolower (read_char ("Do you want to create a disklabel? (y/n) "))) == 'y') + { +-#if defined (i386) +- if (bsd_initlabel (bsd_part, &bsd_dlabel, bsd_part_index) == 1) +-#elif defined (__alpha__) || defined (__powerpc__) || defined (__mc68000__) ++#if defined (__alpha__) || defined (__powerpc__) || defined (__hppa__) || \ ++ defined (__s390__) || defined (__s390x__) || defined(__mc68000__) + if (bsd_initlabel (NULL, &bsd_dlabel, 0) == 1) ++#else ++ if (bsd_initlabel (bsd_part, &bsd_dlabel, bsd_part_index) == 1) + #endif + { + bsd_print_disklabel (1); diff --git a/srcpkgs/mac-fdisk/patches/03-mac-fdisk-0.1_p16-ppc64.patch b/srcpkgs/mac-fdisk/patches/mac-fdisk-0.1_p16-ppc64.patch similarity index 97% rename from srcpkgs/mac-fdisk/patches/03-mac-fdisk-0.1_p16-ppc64.patch rename to srcpkgs/mac-fdisk/patches/mac-fdisk-0.1_p16-ppc64.patch index a7ac724af34..616adc5b811 100644 --- a/srcpkgs/mac-fdisk/patches/03-mac-fdisk-0.1_p16-ppc64.patch +++ b/srcpkgs/mac-fdisk/patches/mac-fdisk-0.1_p16-ppc64.patch @@ -1,5 +1,5 @@ ---- bitfield.c -+++ bitfield.c +--- a/bitfield.c ++++ b/bitfield.c @@ -67,13 +67,12 @@ // // Routines @@ -34,8 +34,8 @@ // compute shift & mask // return the correct number of bits (shifted to low end) ---- bitfield.h -+++ bitfield.h +--- a/bitfield.h ++++ b/bitfield.h @@ -63,5 +63,5 @@ // // Forward declarations @@ -44,8 +44,8 @@ -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); ---- dump.c -+++ dump.c +--- a/dump.c ++++ b/dump.c @@ -61,16 +61,16 @@ // Global Constants // @@ -155,8 +155,8 @@ bp = (BZB *) (p->dpme_bzb); j = -1; ---- errors.c -+++ errors.c +--- a/errors.c ++++ b/errors.c @@ -30,6 +30,7 @@ #include #include @@ -183,8 +183,8 @@ fprintf(stderr, " (%s)\n", strerror(value)); } else { fprintf(stderr, "\n"); ---- fdisk.c -+++ fdisk.c +--- a/fdisk.c ++++ b/fdisk.c @@ -71,12 +71,65 @@ #include @@ -262,8 +262,8 @@ { if (argc > 3) fatal(usage); ---- fdisklabel.c -+++ fdisklabel.c +--- a/fdisklabel.c ++++ b/fdisklabel.c @@ -35,6 +35,7 @@ SUCH DAMAGE. */ @@ -377,8 +377,8 @@ #endif if (pp->p_size % lp->d_secpercyl) putc('*', f); ---- io.c -+++ io.c +--- a/io.c ++++ b/io.c @@ -33,8 +33,10 @@ #else #ifdef __GLIBC__ @@ -399,8 +399,8 @@ return 0; } #ifndef __linux__ ---- partition_map.c -+++ partition_map.c +--- a/partition_map.c ++++ b/partition_map.c @@ -105,7 +105,6 @@ int fd; partition_map_header * map; @@ -435,8 +435,8 @@ map->media_size = number; #ifdef __linux__ ---- pdisk.c -+++ pdisk.c +--- a/pdisk.c ++++ b/pdisk.c @@ -437,7 +437,6 @@ { long base; diff --git a/srcpkgs/mac-fdisk/patches/mac-fdisk-0.1_p16-proper-inline.patch b/srcpkgs/mac-fdisk/patches/mac-fdisk-0.1_p16-proper-inline.patch new file mode 100644 index 00000000000..943827ffcb0 --- /dev/null +++ b/srcpkgs/mac-fdisk/patches/mac-fdisk-0.1_p16-proper-inline.patch @@ -0,0 +1,65 @@ +diff --git a/fdisk.c b/fdisk.c +index d77619b..540879a 100644 +--- a/fdisk.c ++++ b/fdisk.c +@@ -192,13 +192,21 @@ char read_char(char *mesg); + + jmp_buf listingbuf; + +-inline unsigned short __swap16(unsigned short x) { ++static inline unsigned short __swap16(unsigned short x) { + return (((__u16)(x) & 0xFF) << 8) | (((__u16)(x) & 0xFF00) >> 8); + } +-inline __u32 __swap32(__u32 x) { ++static inline __u32 __swap32(__u32 x) { + return (((__u32)(x) & 0xFF) << 24) | (((__u32)(x) & 0xFF00) << 8) | (((__u32)(x) & 0xFF0000) >> 8) | (((__u32)(x) & 0xFF000000) >> 24); + } + ++#if BYTE_ORDER == BIG_ENDIAN ++#define SWAP16(x) __swap16(x) ++#define SWAP32(x) __swap32(x) ++#else ++#define SWAP16(x) ((__u16)x) ++#define SWAP32(x) ((__u32)x) ++#endif ++ + void fatal(enum failure why) + { + char error[LINE_LENGTH], +@@ -1242,7 +1250,7 @@ void new_partition(void) + else + printf("Invalid partition number " + "for type `%c'\n", c); +- ++ + } + } + +@@ -1339,7 +1347,7 @@ void move_begin(int i) + } + first = rounded(calculate(p->head, p->sector, p->cyl), SWAP32(p->start_sect) + + offsets[i]); +- new = read_int(first, first, ++ new = read_int(first, first, + SWAP32(p->start_sect) + SWAP32(p->nr_sects) + offsets[i] - 1, + lower, "New beginning of data") - offsets[i]; + +diff --git a/fdisk.h b/fdisk.h +index 2b6ddc8..9d3ab25 100644 +--- a/fdisk.h ++++ b/fdisk.h +@@ -12,14 +12,6 @@ typedef long long ext2_loff_t; + typedef long ext2_loff_t; + #endif + +-#if BYTE_ORDER == BIG_ENDIAN +-#define SWAP16(x) __swap16(x) +-#define SWAP32(x) __swap32(x) +-#else +-#define SWAP16(x) ((__u16)x) +-#define SWAP32(x) ((__u32)x) +-#endif +- + enum failure {usage, unable_to_open, unable_to_read, unable_to_seek, + unable_to_write, out_of_memory}; + diff --git a/srcpkgs/mac-fdisk/patches/04-mac-fdisk-amd64.patch b/srcpkgs/mac-fdisk/patches/mac-fdisk-amd64.patch similarity index 80% rename from srcpkgs/mac-fdisk/patches/04-mac-fdisk-amd64.patch rename to srcpkgs/mac-fdisk/patches/mac-fdisk-amd64.patch index c48b13d19b4..236b037d977 100644 --- a/srcpkgs/mac-fdisk/patches/04-mac-fdisk-amd64.patch +++ b/srcpkgs/mac-fdisk/patches/mac-fdisk-amd64.patch @@ -1,5 +1,5 @@ ---- fdisklabel.c -+++ fdisklabel.c +--- 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); @@ -9,15 +9,6 @@ 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" @@ -88,15 +79,6 @@ 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)); @@ -160,19 +142,8 @@ static int bsd_translate_fstype (int linux_type) { ---- fdisklabel.h -+++ 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 */ ---- kernel-defs.h -+++ kernel-defs.h +--- a/kernel-defs.h ++++ b/kernel-defs.h @@ -15,8 +15,14 @@ /* from asm/ioctl.h */ #define _IOC_NRBITS 8 diff --git a/srcpkgs/mac-fdisk/patches/mac-fdisk-fdisk-header-musl.patch b/srcpkgs/mac-fdisk/patches/mac-fdisk-fdisk-header-musl.patch new file mode 100644 index 00000000000..380a2b46d9f --- /dev/null +++ b/srcpkgs/mac-fdisk/patches/mac-fdisk-fdisk-header-musl.patch @@ -0,0 +1,10 @@ +--- a/fdisk.c 2016-01-24 03:39:51.647734970 -0600 ++++ b/fdisk.c 2016-01-26 00:55:18.478415913 -0600 +@@ -70,6 +70,7 @@ + #include + + #include ++#include + + #include "kernel-defs.h" + diff --git a/srcpkgs/mac-fdisk/patches/05-big_pt.patch b/srcpkgs/mac-fdisk/patches/mac-fdisk-large-disk-support.patch similarity index 96% rename from srcpkgs/mac-fdisk/patches/05-big_pt.patch rename to srcpkgs/mac-fdisk/patches/mac-fdisk-large-disk-support.patch index 41ebda20652..fe9e78ec73d 100644 --- a/srcpkgs/mac-fdisk/patches/05-big_pt.patch +++ b/srcpkgs/mac-fdisk/patches/mac-fdisk-large-disk-support.patch @@ -1,5 +1,5 @@ ---- partition_map.c -+++ partition_map.c +--- a/partition_map.c ++++ b/partition_map.c @@ -25,6 +25,11 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ diff --git a/srcpkgs/mac-fdisk/patches/01-largerthan2gb.patch b/srcpkgs/mac-fdisk/patches/mac-fdisk-largerthan2gb.patch similarity index 89% rename from srcpkgs/mac-fdisk/patches/01-largerthan2gb.patch rename to srcpkgs/mac-fdisk/patches/mac-fdisk-largerthan2gb.patch index 3fef2bdde50..b33487ca9e9 100644 --- a/srcpkgs/mac-fdisk/patches/01-largerthan2gb.patch +++ b/srcpkgs/mac-fdisk/patches/mac-fdisk-largerthan2gb.patch @@ -1,5 +1,5 @@ ---- fdisk.h -+++ fdisk.h +--- a/fdisk.h ++++ b/fdisk.h @@ -2,6 +2,11 @@ fdisk.h */ diff --git a/srcpkgs/mac-fdisk/patches/mac-fdisk-non-glibc-support.patch b/srcpkgs/mac-fdisk/patches/mac-fdisk-non-glibc-support.patch new file mode 100644 index 00000000000..ae54822b2b1 --- /dev/null +++ b/srcpkgs/mac-fdisk/patches/mac-fdisk-non-glibc-support.patch @@ -0,0 +1,14 @@ +--- a/io.c 2016-01-24 03:19:51.647734970 -0600 ++++ b/io.c 2016-01-24 03:27:08.952825190 -0600 +@@ -31,11 +31,9 @@ + #ifndef __linux__ + #include + #else +-#ifdef __GLIBC__ + #include + #include + #endif +-#endif + #include + #include + #include diff --git a/srcpkgs/mac-fdisk/patches/mac-fdisk-stdout-flush.patch b/srcpkgs/mac-fdisk/patches/mac-fdisk-stdout-flush.patch new file mode 100644 index 00000000000..a4a1c69ba1b --- /dev/null +++ b/srcpkgs/mac-fdisk/patches/mac-fdisk-stdout-flush.patch @@ -0,0 +1,59 @@ +--- mac-fdisk-0.1.orig/io.c.old 2017-12-17 20:36:23.277115889 -0600 ++++ mac-fdisk-0.1.orig/io.c 2017-12-17 20:46:59.295011785 -0600 +@@ -148,6 +148,7 @@ + + flush_to_newline(0); + printf(prompt); ++ fflush(stdout); + + for (;;) { + c = getch(); +@@ -166,6 +167,7 @@ + } else { + flush_to_newline(0); + printf(prompt); ++ fflush(stdout); + } + } + return -1; +@@ -179,6 +181,7 @@ + + if (promptBeforeGet) { + printf(prompt); ++ fflush(stdout); + } + for (;;) { + c = getch(); +@@ -189,6 +192,7 @@ + // skip blanks and tabs + } else if (c == '\n') { + printf(prompt); ++ fflush(stdout); + } else { + *command = c; + return 1; +@@ -214,6 +218,7 @@ + } else if (c == '\n') { + if (default_value < 0) { + printf(prompt); ++ fflush(stdout); + } else { + ungetch(c); + *number = default_value; +@@ -292,6 +297,7 @@ + } else if (c == '\n') { + if (reprompt) { + printf(prompt); ++ fflush(stdout); + } else { + ungetch(c); + *string = NULL; +@@ -466,7 +472,7 @@ + long t; + + if (rflag) { +- printf("Can't write block %u to file", (unsigned int)num); ++ printf("Can't write block %u to file\n", (unsigned int)num); + return 0; + } + #ifndef __linux__ diff --git a/srcpkgs/mac-fdisk/template b/srcpkgs/mac-fdisk/template index 3f4a8831c69..e49accf70f0 100644 --- a/srcpkgs/mac-fdisk/template +++ b/srcpkgs/mac-fdisk/template @@ -1,7 +1,7 @@ # Template file for 'mac-fdisk' pkgname=mac-fdisk version=0.1 -revision=1 +revision=2 wrksrc=${pkgname}-${version}.orig build_style=gnu-makefile short_desc="Format and edit Apple Partition Map drives" @@ -10,19 +10,25 @@ license="GPL-2.0-or-later" homepage="https://packages.debian.org/sid/mac-fdisk" distfiles="http://deb.debian.org/debian/pool/main/m/mac-fdisk/mac-fdisk_${version}.orig.tar.gz" checksum=7059fc4ba41ca2ef857e1092e9c56e910f27693d407b5c3d78f7102ad0c56a66 +patch_args="-Np1" + +CFLAGS="-D_GNU_SOURCE" case "$XBPS_TARGET_MACHINE" in arm*|aarch64*|mips*) broken=yes;; esac -case "$XBPS_TARGET_MACHINE" in - *-musl) CFLAGS+=" -Dloff_t=off_t" -esac +do_check() { + : +} do_install() { vbin fdisk mac-fdisk vbin pdisk pmac-fdisk + cp -pf mac-fdisk.8.in mac-fdisk.8 + cp -pf pmac-fdisk.8.in pmac-fdisk.8 + vman mac-fdisk.8 vman pmac-fdisk.8 }