// SPDX-License-Identifier: GPL-2.0 /* * fs/partitions/msdos.c * * Code extracted from drivers/block/genhd.c * Copyright (C) 1991-1998 Linus Torvalds * * Thanks to Branko Lankester, [email protected], who found a bug * in the early extended-partition checks and added DM partitions * * Support for DiskManager v6.0x added by Mark Lord, * with information provided by OnTrack. This now works for linux fdisk * and LILO, as well as loadlin and bootln. Note that disks other than * /dev/hda *must* have a "DOS" type 0x51 partition in the first slot (hda1). * * More flexible handling of extended partitions - aeb, 950831 * * Check partition table on IDE disks for common CHS translations * * Re-organised Feb 1998 Russell King * * BSD disklabel support by Yossi Gottlieb <[email protected]> * updated by Marc Espie <[email protected]> * * Unixware slices support by Andrzej Krzysztofowicz <[email protected]> * and Krzysztof G. Baranowski <[email protected]> */ #include <linux/msdos_fs.h> #include <linux/msdos_partition.h> #include "check.h" #include "efi.h" /* * Many architectures don't like unaligned accesses, while * the nr_sects and start_sect partition table entries are * at a 2 (mod 4) address. */ #include <asm/unaligned.h> static inline sector_t nr_sects(struct msdos_partition *p) { … } static inline sector_t start_sect(struct msdos_partition *p) { … } static inline int is_extended_partition(struct msdos_partition *p) { … } #define MSDOS_LABEL_MAGIC1 … #define MSDOS_LABEL_MAGIC2 … static inline int msdos_magic_present(unsigned char *p) { … } /* Value is EBCDIC 'IBMA' */ #define AIX_LABEL_MAGIC1 … #define AIX_LABEL_MAGIC2 … #define AIX_LABEL_MAGIC3 … #define AIX_LABEL_MAGIC4 … static int aix_magic_present(struct parsed_partitions *state, unsigned char *p) { … } static void set_info(struct parsed_partitions *state, int slot, u32 disksig) { … } /* * Create devices for each logical partition in an extended partition. * The logical partitions form a linked list, with each entry being * a partition table with two entries. The first entry * is the real data partition (with a start relative to the partition * table start). The second is a pointer to the next logical partition * (with a start relative to the entire extended partition). * We do not create a Linux partition for the partition tables, but * only for the actual data partitions. */ static void parse_extended(struct parsed_partitions *state, sector_t first_sector, sector_t first_size, u32 disksig) { … } #define SOLARIS_X86_NUMSLICE … #define SOLARIS_X86_VTOC_SANE … struct solaris_x86_slice { … }; struct solaris_x86_vtoc { … }; /* [email protected]: Solaris has a nasty indicator: 0x82 which also indicates linux swap. Be careful before believing this is Solaris. */ static void parse_solaris_x86(struct parsed_partitions *state, sector_t offset, sector_t size, int origin) { … } /* check against BSD src/sys/sys/disklabel.h for consistency */ #define BSD_DISKMAGIC … #define BSD_MAXPARTITIONS … #define OPENBSD_MAXPARTITIONS … #define BSD_FS_UNUSED … struct bsd_disklabel { … }; #if defined(CONFIG_BSD_DISKLABEL) /* * Create devices for BSD partitions listed in a disklabel, under a * dos-like partition. See parse_extended() for more information. */ static void parse_bsd(struct parsed_partitions *state, sector_t offset, sector_t size, int origin, char *flavour, int max_partitions) { … } #endif static void parse_freebsd(struct parsed_partitions *state, sector_t offset, sector_t size, int origin) { … } static void parse_netbsd(struct parsed_partitions *state, sector_t offset, sector_t size, int origin) { … } static void parse_openbsd(struct parsed_partitions *state, sector_t offset, sector_t size, int origin) { … } #define UNIXWARE_DISKMAGIC … #define UNIXWARE_DISKMAGIC2 … #define UNIXWARE_NUMSLICE … #define UNIXWARE_FS_UNUSED … struct unixware_slice { … }; struct unixware_disklabel { … }; /* 408 */ /* * Create devices for Unixware partitions listed in a disklabel, under a * dos-like partition. See parse_extended() for more information. */ static void parse_unixware(struct parsed_partitions *state, sector_t offset, sector_t size, int origin) { … } #define MINIX_NR_SUBPARTITIONS … /* * Minix 2.0.0/2.0.2 subpartition support. * Anand Krishnamurthy <[email protected]> * Rajeev V. Pillai <[email protected]> */ static void parse_minix(struct parsed_partitions *state, sector_t offset, sector_t size, int origin) { … } static struct { … } subtypes[] = …; int msdos_partition(struct parsed_partitions *state) { … }