mac-fdisk: sync patches from adelie

This should also fix it on musl.
This commit is contained in:
q66 2019-11-01 12:05:35 +01:00 committed by Helmut Pozimski
parent 2ff92442a6
commit 3c052ea7dd
14 changed files with 1004 additions and 891 deletions

View file

@ -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);
}

View file

@ -1,43 +0,0 @@
--- fdisk.c
+++ fdisk.c
@@ -59,6 +59,10 @@
*/
+#ifndef _LARGEFILE64_SOURCE
+#define _LARGEFILE64_SOURCE
+#endif
+#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
--- fdisklabel.c
+++ fdisklabel.c
@@ -35,6 +35,9 @@
SUCH DAMAGE.
*/
+#ifndef _LARGEFILE64_SOURCE
+#define _LARGEFILE64_SOURCE
+#endif
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
--- io.c
+++ io.c
@@ -25,6 +25,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#define _LARGEFILE64_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
@@ -37,6 +38,7 @@
#endif
#endif
#include <linux/unistd.h>
+#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#include <stdarg.h>

View file

@ -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 <string.h>
#include <errno.h>
#include <fcntl.h>
--- 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 <unistd.h>
#include <stdio.h>
@ -57,8 +57,8 @@ Include a lot more headers and remove a bunch of braindead __linux__ checks
#include <fcntl.h>
#include <ctype.h>
#include <setjmp.h>
--- fdisklabel.c
+++ fdisklabel.c
--- a/fdisklabel.c
+++ b/fdisklabel.c
@@ -38,6 +38,7 @@
#include <unistd.h>
#include <stdio.h>
@ -67,8 +67,8 @@ Include a lot more headers and remove a bunch of braindead __linux__ checks
#include <fcntl.h>
#include <ctype.h>
#include <setjmp.h>
--- 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 <SCSI.h>
#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 <errno.h>
#include <fcntl.h>
--- pdisk.c
+++ pdisk.c
--- a/pdisk.c
+++ b/pdisk.c
@@ -32,10 +32,11 @@
#include <getopt.h>
#include <stddef.h>

View file

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

View file

@ -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 <string.h>
#include <stdarg.h>
@ -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 <sys/ioctl.h>
@ -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;

View file

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

View file

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

View file

@ -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 <endian.h>
#include <sys/ioctl.h>
+#include <sys/types.h>
#include "kernel-defs.h"

View file

@ -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.
*/

View file

@ -1,5 +1,5 @@
--- fdisk.h
+++ fdisk.h
--- a/fdisk.h
+++ b/fdisk.h
@@ -2,6 +2,11 @@
fdisk.h
*/

View file

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

View file

@ -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__

View file

@ -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
}