From 3c08cb2df0f43acc353ec157c775605ffd885af5 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 11 Jun 2013 10:17:57 +0200 Subject: [PATCH] fdisk: remove Mac code The code has been used only to detect magic strings, nothing else. Signed-off-by: Karel Zak --- fdisks/Makemodule.am | 2 - fdisks/fdisk.c | 1 - fdisks/fdiskmaclabel.c | 133 ---------------------------------------- fdisks/fdiskmaclabel.h | 33 ---------- libfdisk/src/ask.c | 2 - libfdisk/src/context.c | 1 - libfdisk/src/fdiskP.h | 1 - libfdisk/src/libfdisk.h | 1 - libfdisk/src/utils.c | 3 - 9 files changed, 177 deletions(-) delete mode 100644 fdisks/fdiskmaclabel.c delete mode 100644 fdisks/fdiskmaclabel.h diff --git a/fdisks/Makemodule.am b/fdisks/Makemodule.am index 99cf93fbfa..3c07461583 100644 --- a/fdisks/Makemodule.am +++ b/fdisks/Makemodule.am @@ -13,8 +13,6 @@ fdisk_SOURCES = \ fdisks/fdiskbsdlabel.h \ fdisks/fdiskdoslabel.c \ fdisks/fdiskdoslabel.h \ - fdisks/fdiskmaclabel.c \ - fdisks/fdiskmaclabel.h \ fdisks/fdisk-menu.c \ fdisks/partname.c \ fdisks/common.h diff --git a/fdisks/fdisk.c b/fdisks/fdisk.c index 7a40f7a037..cf6db69f3f 100644 --- a/fdisks/fdisk.c +++ b/fdisks/fdisk.c @@ -36,7 +36,6 @@ #include "closestream.h" #include "pt-sun.h" /* to toggle flags */ -#include "fdiskmaclabel.h" #include "fdiskdoslabel.h" #include "fdiskbsdlabel.h" diff --git a/fdisks/fdiskmaclabel.c b/fdisks/fdiskmaclabel.c deleted file mode 100644 index a91cabc094..0000000000 --- a/fdisks/fdiskmaclabel.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - Changes: - Sat Mar 20 09:51:38 EST 1999 Arnaldo Carvalho de Melo - Internationalization -*/ -#include /* stderr */ -#include /* strstr */ -#include /* write */ - -#include - -#include "common.h" -#include "fdisk.h" -#include "fdiskmaclabel.h" -#include "nls.h" - -#define MAC_BITMASK 0xffff0000 - -/* - * in-memory fdisk mac stuff - */ -struct fdisk_mac_label { - struct fdisk_label head; /* generic part */ -}; - - -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(struct fdisk_context *cxt) -{ - struct mac_partition *maclabel = (struct mac_partition *) cxt->firstsector; - - maclabel->magic = 0; - fdisk_zeroize_firstsector(cxt); - return; -} - -static int -mac_probe_label(struct fdisk_context *cxt) -{ - struct mac_partition *maclabel = (struct mac_partition *) cxt->firstsector; - - /* - 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: - other_endian = 0; - return 0; - - - } - -IS_MAC: - other_endian = (maclabel->magic == MAC_LABEL_MAGIC_SWAPPED); // =? - volumes = 15; // =? - mac_info(); - mac_nolabel(cxt); /* %% */ - return 1; -} - -static int mac_add_partition( - struct fdisk_context *cxt __attribute__ ((__unused__)), - size_t partnum __attribute__ ((__unused__)), - struct fdisk_parttype *t __attribute__ ((__unused__))) -{ - 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 -ENOSYS; -} - -static const struct fdisk_label_operations mac_operations = -{ - .probe = mac_probe_label, - .part_add = mac_add_partition -}; - - -/* - * allocates MAC label driver - */ -struct fdisk_label *fdisk_new_mac_label(struct fdisk_context *cxt) -{ - struct fdisk_label *lb; - struct fdisk_mac_label *mac; - - assert(cxt); - - mac = calloc(1, sizeof(*mac)); - if (!mac) - return NULL; - - /* initialize generic part of the driver */ - lb = (struct fdisk_label *) mac; - lb->name = "mac"; - lb->id = FDISK_DISKLABEL_MAC; - lb->op = &mac_operations; - - return lb; -} diff --git a/fdisks/fdiskmaclabel.h b/fdisks/fdiskmaclabel.h deleted file mode 100644 index 4e6fef1303..0000000000 --- a/fdisks/fdiskmaclabel.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef FDISK_MAC_LABEL_H -#define FDISK_MAC_LABEL_H - -#include -/* - * Copyright (C) Andreas Neuper, Sep 1998. - * This file may be redistributed under - * the terms of the GNU Public License. - */ - -struct mac_partition { - unsigned int magic; /* expect MAC_LABEL_MAGIC */ - unsigned int fillbytes1[124]; - unsigned int physical_volume_id; - unsigned int fillbytes2[124]; -}; - -/* 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 - -/* fdiskmaclabel.c */ -extern void mac_nolabel(struct fdisk_context *cxt); - -#endif /* FDISK_MAC_LABEL_H */ diff --git a/libfdisk/src/ask.c b/libfdisk/src/ask.c index 4cd9b53463..c0d52e8882 100644 --- a/libfdisk/src/ask.c +++ b/libfdisk/src/ask.c @@ -596,8 +596,6 @@ int fdisk_info_new_partition( #ifdef TEST_PROGRAM struct fdisk_label *fdisk_new_dos_label(struct fdisk_context *cxt) { return NULL; } struct fdisk_label *fdisk_new_bsd_label(struct fdisk_context *cxt) { return NULL; } -struct fdisk_label *fdisk_new_mac_label(struct fdisk_context *cxt) { return NULL; } -struct fdisk_label *fdisk_new_sgi_label(struct fdisk_context *cxt) { return NULL; } int test_ranges(struct fdisk_test *ts, int argc, char *argv[]) { diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c index f2b0f78710..4c8bfdc1cd 100644 --- a/libfdisk/src/context.c +++ b/libfdisk/src/context.c @@ -21,7 +21,6 @@ struct fdisk_context *fdisk_new_context(void) cxt->labels[ cxt->nlabels++ ] = fdisk_new_gpt_label(cxt); cxt->labels[ cxt->nlabels++ ] = fdisk_new_dos_label(cxt); cxt->labels[ cxt->nlabels++ ] = fdisk_new_bsd_label(cxt); - cxt->labels[ cxt->nlabels++ ] = fdisk_new_mac_label(cxt); cxt->labels[ cxt->nlabels++ ] = fdisk_new_sgi_label(cxt); cxt->labels[ cxt->nlabels++ ] = fdisk_new_sun_label(cxt); diff --git a/libfdisk/src/fdiskP.h b/libfdisk/src/fdiskP.h index 9434f3213e..adaa7c0e74 100644 --- a/libfdisk/src/fdiskP.h +++ b/libfdisk/src/fdiskP.h @@ -209,7 +209,6 @@ enum { extern struct fdisk_label *fdisk_new_gpt_label(struct fdisk_context *cxt); extern struct fdisk_label *fdisk_new_dos_label(struct fdisk_context *cxt); extern struct fdisk_label *fdisk_new_bsd_label(struct fdisk_context *cxt); -extern struct fdisk_label *fdisk_new_mac_label(struct fdisk_context *cxt); extern struct fdisk_label *fdisk_new_sgi_label(struct fdisk_context *cxt); extern struct fdisk_label *fdisk_new_sun_label(struct fdisk_context *cxt); diff --git a/libfdisk/src/libfdisk.h b/libfdisk/src/libfdisk.h index b5bd245e49..cfcc62b812 100644 --- a/libfdisk/src/libfdisk.h +++ b/libfdisk/src/libfdisk.h @@ -42,7 +42,6 @@ enum fdisk_labeltype { FDISK_DISKLABEL_SUN = 2, FDISK_DISKLABEL_SGI = 4, FDISK_DISKLABEL_OSF = 8, - FDISK_DISKLABEL_MAC = 16, FDISK_DISKLABEL_GPT = 32, FDISK_DISKLABEL_ANY = -1 }; diff --git a/libfdisk/src/utils.c b/libfdisk/src/utils.c index 9a95ba24c9..20b8cf7bb2 100644 --- a/libfdisk/src/utils.c +++ b/libfdisk/src/utils.c @@ -88,9 +88,6 @@ char *fdisk_partname(const char *dev, size_t partno) #ifdef TEST_PROGRAM struct fdisk_label *fdisk_new_dos_label(struct fdisk_context *cxt) { return NULL; } struct fdisk_label *fdisk_new_bsd_label(struct fdisk_context *cxt) { return NULL; } -struct fdisk_label *fdisk_new_mac_label(struct fdisk_context *cxt) { return NULL; } -struct fdisk_label *fdisk_new_sgi_label(struct fdisk_context *cxt) { return NULL; } -struct fdisk_label *fdisk_new_sun_label(struct fdisk_context *cxt) { return NULL; } int test_partnames(struct fdisk_test *ts, int argc, char *argv[]) { -- 2.47.2