This patch is based on the old Suse util-linux-2.11q-fs_mac.diff patch.
Signed-off-by: Karel Zak <kzak@redhat.com>
sbin_PROGRAMS = fdisk
man_MANS = fdisk.8
fdisk_SOURCES = fdisk.c fdiskbsdlabel.c fdisksgilabel.c \
- fdisksunlabel.c fdiskaixlabel.c partname.c \
+ fdisksunlabel.c fdiskaixlabel.c fdiskmaclabel.c partname.c \
fdisk.h fdisksunlabel.h fdisksgilabel.h fdiskaixlabel.h \
- fdiskbsdlabel.h $(fdisk_common)
+ fdiskbsdlabel.h fdiskmaclabel.h $(fdisk_common)
if !SPARC
#include "fdisksunlabel.h"
#include "fdisksgilabel.h"
#include "fdiskaixlabel.h"
+#include "fdiskmaclabel.h"
#ifdef HAVE_LINUX_COMPILER_H
#include <linux/compiler.h>
unsigned long long total_number_of_sectors;
-#define dos_label (!sun_label && !sgi_label && !aix_label && !osf_label)
-int sun_label = 0; /* looking at sun disklabel */
+#define dos_label (!sun_label && !sgi_label && !aix_label && !mac_label && !osf_label)
+int sun_label = 0; /* looking at sun disklabel */
int sgi_label = 0; /* looking at sgi disklabel */
int aix_label = 0; /* looking at aix disklabel */
int osf_label = 0; /* looking at OSF/1 disklabel */
+int mac_label = 0; /* looking at mac disklabel */
int possibly_osf_label = 0;
jmp_buf listingbuf;
puts(_(" v verify the partition table"));
puts(_(" w write table to disk and exit"));
}
- else if (aix_label) {
+ else if (aix_label || mac_label) {
puts(_("Command action"));
puts(_(" m print this menu"));
puts(_(" o create a new empty DOS partition table"));
puts(_(" v verify the partition table"));
puts(_(" w write table to disk and exit"));
}
- else if (aix_label) {
+ else if (aix_label || mac_label) {
puts(_("Command action"));
puts(_(" b move beginning of data in a partition")); /* !sun */
puts(_(" c change number of cylinders"));
"content won't be recoverable.\n\n"));
sun_nolabel(); /* otherwise always recognised as sun */
sgi_nolabel(); /* otherwise always recognised as sgi */
- aix_label = osf_label = possibly_osf_label = 0;
+ mac_label = aix_label = osf_label = possibly_osf_label = 0;
partitions = 4;
for (i = 510-64; i < 510; i++)
if (check_aix_label())
return 0;
+ if (check_mac_label())
+ return 0;
+
if (check_osf_label()) {
possibly_osf_label = 1;
if (!valid_part_table_flag(MBRbuffer)) {
return;
}
+ if (mac_label) {
+ printf(_("\tSorry - this fdisk cannot handle Mac disk labels."
+ "\n\tIf you want to add DOS-type partitions, create"
+ "\n\ta new empty DOS partition table first. (Use o.)"
+ "\n\tWARNING: "
+ "This will destroy the present disk contents.\n"));
+ return;
+ }
+
for (i = 0; i < 4; i++)
free_primary += !ptes[i].part_table->sys_ind;
if (gb > 0) { /* I/O error */
} else if (gb < 0) { /* no DOS signature */
list_disk_geometry();
- if (!aix_label && btrydev(device) < 0)
+ if (!aix_label && !mac_label && btrydev(device) < 0)
fprintf(stderr,
_("Disk %s doesn't contain a valid "
"partition table\n"), device);
extern int sun_label;
extern int sgi_label;
extern int aix_label;
+extern int mac_label;
/* prototypes for fdiskbsdlabel.c */
extern void bselect(void);
--- /dev/null
+/*
+ Changes:
+ Sat Mar 20 09:51:38 EST 1999 Arnaldo Carvalho de Melo <acme@conectiva.com.br>
+ Internationalization
+*/
+#include <stdio.h> /* stderr */
+#include <string.h> /* strstr */
+#include <unistd.h> /* write */
+
+#include <endian.h>
+
+#include "common.h"
+#include "fdisk.h"
+#include "fdiskmaclabel.h"
+#include "nls.h"
+
+#define MAC_BITMASK 0xffff0000
+
+
+static int other_endian = 0;
+static short volumes=1;
+
+/*
+ * only dealing with free blocks here
+ */
+
+static void
+mac_info( void ) {
+ puts(
+ _("\n\tThere is a valid Mac label on this disk.\n"
+ "\tUnfortunately fdisk(1) cannot handle these disks.\n"
+ "\tUse either pdisk or parted to modify the partition table.\n"
+ "\tNevertheless some advice:\n"
+ "\t1. fdisk will destroy its contents on write.\n"
+ "\t2. Be sure that this disk is NOT a still vital\n"
+ "\t part of a volume group. (Otherwise you may\n"
+ "\t erase the other disks as well, if unmirrored.)\n")
+ );
+}
+
+void
+mac_nolabel( void )
+{
+ maclabel->magic = 0;
+ mac_label = 0;
+ partitions = 4;
+ memset( MBRbuffer, 0, sizeof(MBRbuffer) ); /* avoid fdisk cores */
+ return;
+}
+
+int
+check_mac_label( void )
+{
+ /*
+ Conversion: only 16 bit should compared
+ e.g.: HFS Label is only 16bit long
+ */
+ int magic_masked = 0 ;
+ magic_masked = maclabel->magic & MAC_BITMASK ;
+
+ switch (magic_masked) {
+ case MAC_LABEL_MAGIC :
+ case MAC_LABEL_MAGIC_2:
+ case MAC_LABEL_MAGIC_3:
+ goto IS_MAC;
+ break;
+ default:
+ mac_label = 0;
+ other_endian = 0;
+ return 0;
+
+
+ }
+
+IS_MAC:
+ other_endian = (maclabel->magic == MAC_LABEL_MAGIC_SWAPPED); // =?
+ update_units();
+ mac_label = 1;
+ partitions= 1016; // =?
+ volumes = 15; // =?
+ mac_info();
+ mac_nolabel(); /* %% */
+ mac_label = 1; /* %% */
+ return 1;
+}
+
--- /dev/null
+#ifndef FDISK_MAC_LABEL_H
+#define FDISK_MAC_LABEL_H
+
+#include <linux/types.h> /* for __u32 etc */
+/*
+ * Copyright (C) Andreas Neuper, Sep 1998.
+ * This file may be redistributed under
+ * the terms of the GNU Public License.
+ */
+
+typedef struct {
+ unsigned int magic; /* expect MAC_LABEL_MAGIC */
+ unsigned int fillbytes1[124];
+ unsigned int physical_volume_id;
+ unsigned int fillbytes2[124];
+} mac_partition;
+
+/* MAC magic number only 16bits, do I always know that there are 0200
+ * following? Problem, after magic the uint16_t res1; follows, I donnno know
+ * about the 200k */
+#define MAC_LABEL_MAGIC 0x45520000
+#define MAC_LABEL_MAGIC_2 0x50530000
+#define MAC_LABEL_MAGIC_3 0x504d0000
+
+#define MAC_LABEL_MAGIC_SWAPPED 0x00002554
+
+#define MAC_LABEL_MAGIC_2_SWAPPED 0x00003505
+#define MAC_LABEL_MAGIC_3_SWAPPED 0x0000d405
+
+/* fdisk.c */
+#define maclabel ((mac_partition *)MBRbuffer)
+
+/* fdiskmaclabel.c */
+extern struct systypes mac_sys_types[];
+extern void mac_nolabel( void );
+extern int check_mac_label( void );
+
+#endif /* FDISK_MAC_LABEL_H */
+