summaryrefslogtreecommitdiffstats
path: root/shlibs/blkid/src/partitions
diff options
context:
space:
mode:
authorKarel Zak2011-06-09 22:04:24 +0200
committerKarel Zak2011-06-09 22:04:24 +0200
commit8fb4efae6f5fabbe889bebbda60e9f7dce930f1f (patch)
tree0f06756ea1ba620c7209ce265b21dddbb2ce6778 /shlibs/blkid/src/partitions
parentbuild-sys: use top-level directory for libmount rather than shlibs/mount (diff)
downloadkernel-qcow2-util-linux-8fb4efae6f5fabbe889bebbda60e9f7dce930f1f.tar.gz
kernel-qcow2-util-linux-8fb4efae6f5fabbe889bebbda60e9f7dce930f1f.tar.xz
kernel-qcow2-util-linux-8fb4efae6f5fabbe889bebbda60e9f7dce930f1f.zip
build-sys: use top-level directory for libblkid rather than shlibs/blkid
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/blkid/src/partitions')
-rw-r--r--shlibs/blkid/src/partitions/Makefile.am22
-rw-r--r--shlibs/blkid/src/partitions/aix.c58
-rw-r--r--shlibs/blkid/src/partitions/aix.h7
-rw-r--r--shlibs/blkid/src/partitions/blkid_parttypes.h121
-rw-r--r--shlibs/blkid/src/partitions/bsd.c243
-rw-r--r--shlibs/blkid/src/partitions/dos.c287
-rw-r--r--shlibs/blkid/src/partitions/dos.h36
-rw-r--r--shlibs/blkid/src/partitions/gpt.c401
-rw-r--r--shlibs/blkid/src/partitions/mac.c181
-rw-r--r--shlibs/blkid/src/partitions/minix.c103
-rw-r--r--shlibs/blkid/src/partitions/partitions.c1336
-rw-r--r--shlibs/blkid/src/partitions/partitions.h62
-rw-r--r--shlibs/blkid/src/partitions/sgi.c158
-rw-r--r--shlibs/blkid/src/partitions/solaris_x86.c150
-rw-r--r--shlibs/blkid/src/partitions/sun.c187
-rw-r--r--shlibs/blkid/src/partitions/ultrix.c88
-rw-r--r--shlibs/blkid/src/partitions/unixware.c193
17 files changed, 0 insertions, 3633 deletions
diff --git a/shlibs/blkid/src/partitions/Makefile.am b/shlibs/blkid/src/partitions/Makefile.am
deleted file mode 100644
index f617389d8..000000000
--- a/shlibs/blkid/src/partitions/Makefile.am
+++ /dev/null
@@ -1,22 +0,0 @@
-include $(top_srcdir)/config/include-Makefile.am
-
-AM_CPPFLAGS += -I$(ul_libblkid_incdir) -I$(ul_libblkid_srcdir)
-libblkid_partitions_la_LIBADD =
-
-noinst_LTLIBRARIES = libblkid_partitions.la
-libblkid_partitions_la_SOURCES = partitions.c \
- partitions.h \
- blkid_parttypes.h \
- aix.c \
- aix.h \
- bsd.c \
- unixware.c \
- solaris_x86.c \
- sun.c \
- sgi.c \
- mac.c \
- dos.c \
- dos.h \
- minix.c \
- ultrix.c \
- gpt.c
diff --git a/shlibs/blkid/src/partitions/aix.c b/shlibs/blkid/src/partitions/aix.c
deleted file mode 100644
index be0ad2b46..000000000
--- a/shlibs/blkid/src/partitions/aix.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * aix partitions
- *
- * Copyright (C) 2009 Karel Zak <kzak@redhat.com>
- *
- * This file may be redistributed under the terms of the
- * GNU Lesser General Public License.
- */
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdint.h>
-
-#include "partitions.h"
-#include "aix.h"
-
-static int probe_aix_pt(blkid_probe pr, const struct blkid_idmag *mag)
-{
- blkid_partlist ls;
- blkid_parttable tab;
-
- if (blkid_partitions_need_typeonly(pr))
- /* caller does not ask for details about partitions */
- return 0;
-
- ls = blkid_probe_get_partlist(pr);
- if (!ls)
- goto err;
-
- tab = blkid_partlist_new_parttable(ls, "aix", 0);
- if (!tab)
- goto err;
-
- return 0;
-err:
- return -1;
-}
-
-/*
- * We know nothing about AIX on-disk structures. Everything what we know is the
- * magic number at begin of the disk.
- *
- * Note, Linux kernel is tring to be smart and AIX signature is ignored when
- * there is a valid DOS partitions table. We don't support such behaviour. All
- * fdisk-like programs has to properly wipe the fist sector. Everything other
- * is a bug.
- */
-const struct blkid_idinfo aix_pt_idinfo =
-{
- .name = "aix",
- .probefunc = probe_aix_pt,
- .magics =
- {
- { .magic = BLKID_AIX_MAGIC_STRING, .len = BLKID_AIX_MAGIC_STRLEN },
- { NULL }
- }
-};
-
diff --git a/shlibs/blkid/src/partitions/aix.h b/shlibs/blkid/src/partitions/aix.h
deleted file mode 100644
index f767c5a37..000000000
--- a/shlibs/blkid/src/partitions/aix.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef BLKID_PARTITIONS_AIX_H
-#define BLKID_PARTITIONS_AIX_H
-
-#define BLKID_AIX_MAGIC_STRING "\xC9\xC2\xD4\xC1"
-#define BLKID_AIX_MAGIC_STRLEN (sizeof(BLKID_AIX_MAGIC_STRING) - 1)
-
-#endif
diff --git a/shlibs/blkid/src/partitions/blkid_parttypes.h b/shlibs/blkid/src/partitions/blkid_parttypes.h
deleted file mode 100644
index 707e53d93..000000000
--- a/shlibs/blkid/src/partitions/blkid_parttypes.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Partition types
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/* Note, _L32M means <32M (less), for example FAT16_L32M */
-
-enum {
- BLKID_EMPTY_PARTITION = 0x00,
- BLKID_FAT12_PARTITION = 0x01,
- BLKID_XENIX_ROOT_PARTITION = 0x02,
- BLKID_XENIX_USR_PARTITION = 0x03,
- BLKID_FAT16_LESS32M_PARTITION = 0x04,
- BLKID_DOS_EXTENDED_PARTITION = 0x05,
- BLKID_FAT16_PARTITION = 0x06, /* DOS 16-bit >=32M */
- BLKID_HPFS_NTFS_PARTITION = 0x07, /* OS/2 IFS, eg, HPFS or NTFS or QNX */
- BLKID_AIX_PARTITION = 0x08, /* AIX boot (AIX -- PS/2 port) or SplitDrive */
- BLKID_AIX_BOOTABLE_PARTITION = 0x09, /* AIX data or Coherent */
- BLKID_OS2_BOOTMNGR_PARTITION = 0x0a, /* OS/2 Boot Manager */
- BLKID_W95_FAT32_PARTITION = 0x0b,
- BLKID_W95_FAT32_LBA_PARTITION = 0x0c, /* LBA really is `Extended Int 13h' */
- BLKID_W95_FAT16_LBA_PARTITION = 0x0e,
- BLKID_W95_EXTENDED_PARTITION = 0x0f,
- BLKID_OPUS_PARTITION = 0x10,
- BLKID_HIDDEN_FAT12_PARTITION = 0x11,
- BLKID_COMPAQ_DIAGNOSTICS_PARTITION = 0x12,
- BLKID_HIDDEN_FAT16_L32M_PARTITION = 0x14,
- BLKID_HIDDEN_FAT16_PARTITION = 0x16,
- BLKID_HIDDEN_HPFS_NTFS_PARTITION = 0x17,
- BLKID_AST_SMARTSLEEP_PARTITION = 0x18,
- BLKID_HIDDEN_W95_FAT32_PARTITION = 0x1b,
- BLKID_HIDDEN_W95_FAT32LBA_PARTITION = 0x1c,
- BLKID_HIDDEN_W95_FAT16LBA_PARTITION = 0x1e,
- BLKID_NEC_DOS_PARTITION = 0x24,
- BLKID_PLAN9_PARTITION = 0x39,
- BLKID_PARTITIONMAGIC_PARTITION = 0x3c,
- BLKID_VENIX80286_PARTITION = 0x40,
- BLKID_PPC_PREP_BOOT_PARTITION = 0x41,
- BLKID_SFS_PARTITION = 0x42,
- BLKID_QNX_4X_PARTITION = 0x4d,
- BLKID_QNX_4X_2ND_PARTITION = 0x4e,
- BLKID_QNX_4X_3RD_PARTITION = 0x4f,
- BLKID_DM_PARTITION = 0x50,
- BLKID_DM6_AUX1_PARTITION = 0x51, /* (or Novell) */
- BLKID_CPM_PARTITION = 0x52, /* CP/M or Microport SysV/AT */
- BLKID_DM6_AUX3_PARTITION = 0x53,
- BLKID_DM6_PARTITION = 0x54,
- BLKID_EZ_DRIVE_PARTITION = 0x55,
- BLKID_GOLDEN_BOW_PARTITION = 0x56,
- BLKID_PRIAM_EDISK_PARTITION = 0x5c,
- BLKID_SPEEDSTOR_PARTITION = 0x61,
- BLKID_GNU_HURD_PARTITION = 0x63, /* GNU HURD or Mach or Sys V/386 (such as ISC UNIX) */
- BLKID_UNIXWARE_PARTITION = BLKID_GNU_HURD_PARTITION,
- BLKID_NETWARE_286_PARTITION = 0x64,
- BLKID_NETWARE_386_PARTITION = 0x65,
- BLKID_DISKSECURE_MULTIBOOT_PARTITION = 0x70,
- BLKID_PC_IX_PARTITION = 0x75,
- BLKID_OLD_MINIX_PARTITION = 0x80, /* Minix 1.4a and earlier */
- BLKID_MINIX_PARTITION = 0x81, /* Minix 1.4b and later */
- BLKID_LINUX_SWAP_PARTITION = 0x82,
- BLKID_SOLARIS_X86_PARTITION = BLKID_LINUX_SWAP_PARTITION,
- BLKID_LINUX_DATA_PARTITION = 0x83,
- BLKID_OS2_HIDDEN_DRIVE_PARTITION = 0x84,
- BLKID_LINUX_EXTENDED_PARTITION = 0x85,
- BLKID_NTFS_VOL_SET1_PARTITION = 0x86,
- BLKID_NTFS_VOL_SET2_PARTITION = 0x87,
- BLKID_LINUX_PLAINTEXT_PARTITION = 0x88,
- BLKID_LINUX_LVM_PARTITION = 0x8e,
- BLKID_AMOEBA_PARTITION = 0x93,
- BLKID_AMOEBA_BBT_PARTITION = 0x94, /* (bad block table) */
- BLKID_BSD_OS_PARTITION = 0x9f, /* BSDI */
- BLKID_THINKPAD_HIBERNATION_PARTITION = 0xa0,
- BLKID_FREEBSD_PARTITION = 0xa5, /* various BSD flavours */
- BLKID_OPENBSD_PARTITION = 0xa6,
- BLKID_NEXTSTEP_PARTITION = 0xa7,
- BLKID_DARWIN_UFS_PARTITION = 0xa8,
- BLKID_NETBSD_PARTITION = 0xa9,
- BLKID_DARWIN_BOOT_PARTITION = 0xab,
- BLKID_HFS_HFS_PARTITION = 0xaf,
- BLKID_BSDI_FS_PARTITION = 0xb7,
- BLKID_BSDI_SWAP_PARTITION = 0xb8,
- BLKID_BOOTWIZARD_HIDDEN_PARTITION = 0xbb,
- BLKID_SOLARIS_BOOT_PARTITION = 0xbe,
- BLKID_SOLARIS_PARTITION = 0xbf,
- BLKID_DRDOS_FAT12_PARTITION = 0xc1,
- BLKID_DRDOS_FAT16_L32M_PARTITION = 0xc4,
- BLKID_DRDOS_FAT16_PARTITION = 0xc6,
- BLKID_SYRINX_PARTITION = 0xc7,
- BLKID_NONFS_DATA_PARTITION = 0xda,
- BLKID_CPM_CTOS_PARTITION = 0xdb, /* CP/M or Concurrent CP/M or Concurrent DOS or CTOS */
- BLKID_DELL_UTILITY_PARTITION = 0xde, /* Dell PowerEdge Server utilities */
- BLKID_BOOTIT_PARTITION = 0xdf, /* BootIt EMBRM */
- BLKID_DOS_ACCESS_PARTITION = 0xe1, /* DOS access or SpeedStor 12-bit FAT extended partition */
- BLKID_DOS_RO_PARTITION = 0xe3, /* DOS R/O or SpeedStor */
- BLKID_SPEEDSTOR_EXTENDED_PARTITION = 0xe4, /* SpeedStor 16-bit FAT extended partition < 1024 cyl. */
- BLKID_BEOS_FS_PARTITION = 0xeb,
- BLKID_GPT_PARTITION = 0xee, /* Intel EFI GUID Partition Table */
- BLKID_EFI_SYSTEM_PARTITION = 0xef, /* Intel EFI System Partition */
- BLKID_LINUX_PARISC_BOOT_PARTITION = 0xf0, /* Linux/PA-RISC boot loader */
- BLKID_SPEEDSTOR1_PARTITION = 0xf1,
- BLKID_SPEEDSTOR2_PARTITION = 0xf4, /* SpeedStor large partition */
- BLKID_DOS_SECONDARY_PARTITION = 0xf2, /* DOS 3.3+ secondary */
- BLKID_VMWARE_VMFS_PARTITION = 0xfb,
- BLKID_VMWARE_VMKCORE_PARTITION = 0xfc, /* VMware kernel dump partition */
- BLKID_LINUX_RAID_PARTITION = 0xfd, /* New (2.2.x) raid partition with autodetect using persistent superblock */
- BLKID_LANSTEP_PARTITION = 0xfe, /* SpeedStor >1024 cyl. or LANstep */
- BLKID_XENIX_BBT_PARTITION = 0xff, /* Xenix Bad Block Table */
-};
diff --git a/shlibs/blkid/src/partitions/bsd.c b/shlibs/blkid/src/partitions/bsd.c
deleted file mode 100644
index ee15ad2fe..000000000
--- a/shlibs/blkid/src/partitions/bsd.c
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * BSD/OSF partition parsing code
- *
- * Copyright (C) 2009 Karel Zak <kzak@redhat.com>
- *
- * This file may be redistributed under the terms of the
- * GNU Lesser General Public License.
- *
- * Inspired by fdisk, partx, Linux kernel, libparted and openbsd header files.
- */
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdint.h>
-
-#include "partitions.h"
-
-#define BSD_MAXPARTITIONS 16
-#define BSD_FS_UNUSED 0
-
-struct bsd_disklabel {
- uint32_t d_magic; /* the magic number */
- int16_t d_type; /* drive type */
- int16_t d_subtype; /* controller/d_type specific */
- char d_typename[16]; /* type name, e.g. "eagle" */
- char d_packname[16]; /* pack identifier */
-
- /* disk geometry: */
- uint32_t d_secsize; /* # of bytes per sector */
- uint32_t d_nsectors; /* # of data sectors per track */
- uint32_t d_ntracks; /* # of tracks per cylinder */
- uint32_t d_ncylinders; /* # of data cylinders per unit */
- uint32_t d_secpercyl; /* # of data sectors per cylinder */
- uint32_t d_secperunit; /* # of data sectors per unit */
-
- /*
- * Spares (bad sector replacements) below
- * are not counted in d_nsectors or d_secpercyl.
- * Spare sectors are assumed to be physical sectors
- * which occupy space at the end of each track and/or cylinder.
- */
- uint16_t d_sparespertrack; /* # of spare sectors per track */
- uint16_t d_sparespercyl; /* # of spare sectors per cylinder */
-
- /*
- * Alternate cylinders include maintenance, replacement,
- * configuration description areas, etc.
- */
- uint32_t d_acylinders; /* # of alt. cylinders per unit */
-
- /* hardware characteristics: */
- /*
- * d_interleave, d_trackskew and d_cylskew describe perturbations
- * in the media format used to compensate for a slow controller.
- * Interleave is physical sector interleave, set up by the formatter
- * or controller when formatting. When interleaving is in use,
- * logically adjacent sectors are not physically contiguous,
- * but instead are separated by some number of sectors.
- * It is specified as the ratio of physical sectors traversed
- * per logical sector. Thus an interleave of 1:1 implies contiguous
- * layout, while 2:1 implies that logical sector 0 is separated
- * by one sector from logical sector 1.
- * d_trackskew is the offset of sector 0 on track N
- * relative to sector 0 on track N-1 on the same cylinder.
- * Finally, d_cylskew is the offset of sector 0 on cylinder N
- * relative to sector 0 on cylinder N-1.
- */
- uint16_t d_rpm; /* rotational speed */
- uint16_t d_interleave; /* hardware sector interleave */
- uint16_t d_trackskew; /* sector 0 skew, per track */
- uint16_t d_cylskew; /* sector 0 skew, per cylinder */
- uint32_t d_headswitch; /* head switch time, usec */
- uint32_t d_trkseek; /* track-to-track seek, usec */
- uint32_t d_flags; /* generic flags */
- uint32_t d_drivedata[5]; /* drive-type specific information */
- uint32_t d_spare[5]; /* reserved for future use */
- uint32_t d_magic2; /* the magic number (again) */
- uint16_t d_checksum; /* xor of data incl. partitions */
-
- /* filesystem and partition information: */
- uint16_t d_npartitions; /* number of partitions in following */
- uint32_t d_bbsize; /* size of boot area at sn0, bytes */
- uint32_t d_sbsize; /* max size of fs superblock, bytes */
-
- struct bsd_partition { /* the partition table */
- uint32_t p_size; /* number of sectors in partition */
- uint32_t p_offset; /* starting sector */
- uint32_t p_fsize; /* filesystem basic fragment size */
- uint8_t p_fstype; /* filesystem type, see below */
- uint8_t p_frag; /* filesystem fragments per block */
- uint16_t p_cpg; /* filesystem cylinders per group */
- } __attribute__((packed)) d_partitions[BSD_MAXPARTITIONS]; /* actually may be more */
-} __attribute__((packed));
-
-
-/* Returns 'blkid_idmag' in 512-sectors */
-#define BLKID_MAG_SECTOR(_mag) (((_mag)->kboff * 2) + ((_mag)->sboff >> 9))
-
-/* Returns 'blkid_idmag' in bytes */
-#define BLKID_MAG_OFFSET(_mag) ((_mag)->kboff >> 10) + ((_mag)->sboff)
-
-/* Returns 'blkid_idmag' offset in bytes within the last sector */
-#define BLKID_MAG_LASTOFFSET(_mag) \
- (BLKID_MAG_OFFSET(_mag) - (BLKID_MAG_SECTOR(_mag) << 9))
-
-static int probe_bsd_pt(blkid_probe pr, const struct blkid_idmag *mag)
-{
- struct bsd_disklabel *l;
- struct bsd_partition *p;
- const char *name = "bsd" ;
- blkid_parttable tab = NULL;
- blkid_partition parent;
- blkid_partlist ls;
- int i, nparts = BSD_MAXPARTITIONS;
- unsigned char *data;
-
- if (blkid_partitions_need_typeonly(pr))
- /* caller does not ask for details about partitions */
- return 0;
-
- data = blkid_probe_get_sector(pr, BLKID_MAG_SECTOR(mag));
- if (!data)
- goto nothing;
-
- l = (struct bsd_disklabel *) data + BLKID_MAG_LASTOFFSET(mag);
-
- ls = blkid_probe_get_partlist(pr);
- if (!ls)
- goto err;
-
- /* try to determine the real type of BSD system according to
- * (parental) primary partition */
- parent = blkid_partlist_get_parent(ls);
- if (parent) {
- switch(blkid_partition_get_type(parent)) {
- case BLKID_FREEBSD_PARTITION:
- name = "freebsd";
- break;
- case BLKID_NETBSD_PARTITION:
- name = "netbsd";
- break;
- case BLKID_OPENBSD_PARTITION:
- name = "openbsd";
- break;
- default:
- DBG(DEBUG_LOWPROBE, printf(
- "WARNING: BSD label detected on unknown (0x%x) "
- "primary partition\n",
- blkid_partition_get_type(parent)));
- break;
- }
- }
-
- tab = blkid_partlist_new_parttable(ls, name, BLKID_MAG_OFFSET(mag));
- if (!tab)
- goto err;
-
- if (le16_to_cpu(l->d_npartitions) < BSD_MAXPARTITIONS)
- nparts = le16_to_cpu(l->d_npartitions);
-
- else if (le16_to_cpu(l->d_npartitions) > BSD_MAXPARTITIONS)
- DBG(DEBUG_LOWPROBE, printf(
- "WARNING: ignore %d more BSD partitions\n",
- le16_to_cpu(l->d_npartitions) - BSD_MAXPARTITIONS));
-
- for (i = 0, p = l->d_partitions; i < nparts; i++, p++) {
- blkid_partition par;
- uint32_t start, size;
-
- /* TODO: in fdisk-mode returns all non-zero (p_size) partitions */
- if (p->p_fstype == BSD_FS_UNUSED)
- continue;
-
- start = le32_to_cpu(p->p_offset);
- size = le32_to_cpu(p->p_size);
-
- if (parent && !blkid_is_nested_dimension(parent, start, size)) {
- DBG(DEBUG_LOWPROBE, printf(
- "WARNING: BSD partition (%d) overflow "
- "detected, ignore\n", i));
- continue;
- }
-
- par = blkid_partlist_add_partition(ls, tab, start, size);
- if (!par)
- goto err;
-
- blkid_partition_set_type(par, p->p_fstype);
- }
-
- return 0;
-
-nothing:
- return 1;
-err:
- return -1;
-}
-
-
-/*
- * All BSD variants use the same magic string (little-endian),
- * and the same disklabel.
- *
- * The difference between {Free,Open,...}BSD is in the (parental)
- * primary partition type.
- *
- * See also: http://en.wikipedia.org/wiki/BSD_disklabel
- *
- * The location of BSD disk label is architecture specific and in defined by
- * LABELSECTOR and LABELOFFSET macros in the disklabel.h file. The location
- * also depends on BSD variant, FreeBSD uses only one location, NetBSD and
- * OpenBSD are more creative...
- *
- * The basic overview:
- *
- * arch | LABELSECTOR | LABELOFFSET
- * ------------------------+-------------+------------
- * amd64 arm hppa hppa64 | |
- * i386, macppc, mvmeppc | 1 | 0
- * sgi, aviion, sh, socppc | |
- * ------------------------+-------------+------------
- * alpha luna88k mac68k | 0 | 64
- * sparc(OpenBSD) vax | |
- * ------------------------+-------------+------------
- * spark64 sparc(NetBSD) | 0 | 128
- * ------------------------+-------------+------------
- *
- * ...and more (see http://fxr.watson.org/fxr/ident?v=NETBSD;i=LABELSECTOR)
- *
- */
-const struct blkid_idinfo bsd_pt_idinfo =
-{
- .name = "bsd",
- .probefunc = probe_bsd_pt,
- .magics =
- {
- { .magic = "\x57\x45\x56\x82", .len = 4, .sboff = 512 },
- { .magic = "\x57\x45\x56\x82", .len = 4, .sboff = 64 },
- { .magic = "\x57\x45\x56\x82", .len = 4, .sboff = 128 },
- { NULL }
- }
-};
-
diff --git a/shlibs/blkid/src/partitions/dos.c b/shlibs/blkid/src/partitions/dos.c
deleted file mode 100644
index 72ac7788c..000000000
--- a/shlibs/blkid/src/partitions/dos.c
+++ /dev/null
@@ -1,287 +0,0 @@
-/*
- * MS-DOS partition parsing code
- *
- * Copyright (C) 2009 Karel Zak <kzak@redhat.com>
- *
- * This file may be redistributed under the terms of the
- * GNU Lesser General Public License.
- *
- * Inspired by fdisk, partx, Linux kernel and libparted.
- */
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdint.h>
-
-#include "partitions.h"
-#include "dos.h"
-#include "aix.h"
-
-/* see superblocks/vfat.c */
-extern int blkid_probe_is_vfat(blkid_probe pr);
-
-static const struct dos_subtypes {
- unsigned char type;
- const struct blkid_idinfo *id;
-} dos_nested[] = {
- { BLKID_FREEBSD_PARTITION, &bsd_pt_idinfo },
- { BLKID_NETBSD_PARTITION, &bsd_pt_idinfo },
- { BLKID_OPENBSD_PARTITION, &bsd_pt_idinfo },
- { BLKID_UNIXWARE_PARTITION, &unixware_pt_idinfo },
- { BLKID_SOLARIS_X86_PARTITION, &solaris_x86_pt_idinfo },
- { BLKID_MINIX_PARTITION, &minix_pt_idinfo }
-};
-
-static inline int is_extended(struct dos_partition *p)
-{
- return (p->sys_type == BLKID_DOS_EXTENDED_PARTITION ||
- p->sys_type == BLKID_W95_EXTENDED_PARTITION ||
- p->sys_type == BLKID_LINUX_EXTENDED_PARTITION);
-}
-
-static int parse_dos_extended(blkid_probe pr, blkid_parttable tab,
- uint32_t ex_start, uint32_t ex_size, int ssf)
-{
- blkid_partlist ls = blkid_probe_get_partlist(pr);
- uint32_t cur_start = ex_start, cur_size = ex_size;
- unsigned char *data;
- int ct_nodata = 0; /* count ext.partitions without data partitions */
- int i;
-
- while (1) {
- struct dos_partition *p, *p0;
- uint32_t start, size;
-
- if (++ct_nodata > 100)
- return 0;
- data = blkid_probe_get_sector(pr, cur_start);
- if (!data)
- goto leave; /* malformed partition? */
-
- if (!is_valid_mbr_signature(data))
- goto leave;
-
- p0 = (struct dos_partition *) (data + BLKID_MSDOS_PT_OFFSET);
-
- /* Usually, the first entry is the real data partition,
- * the 2nd entry is the next extended partition, or empty,
- * and the 3rd and 4th entries are unused.
- * However, DRDOS sometimes has the extended partition as
- * the first entry (when the data partition is empty),
- * and OS/2 seems to use all four entries.
- * -- Linux kernel fs/partitions/dos.c
- *
- * See also http://en.wikipedia.org/wiki/Extended_boot_record
- */
-
- /* Parse data partition */
- for (p = p0, i = 0; i < 4; i++, p++) {
- uint32_t abs_start;
- blkid_partition par;
-
- /* the start is relative to the parental ext.partition */
- start = dos_partition_start(p) * ssf;
- size = dos_partition_size(p) * ssf;
- abs_start = cur_start + start; /* absolute start */
-
- if (!size || is_extended(p))
- continue;
- if (i >= 2) {
- /* extra checks to detect real data on
- * 3rd and 4th entries */
- if (start + size > cur_size)
- continue;
- if (abs_start < ex_start)
- continue;
- if (abs_start + size > ex_start + ex_size)
- continue;
- }
-
- par = blkid_partlist_add_partition(ls, tab, abs_start, size);
- if (!par)
- goto err;
-
- blkid_partition_set_type(par, p->sys_type);
- blkid_partition_set_flags(par, p->boot_ind);
- ct_nodata = 0;
- }
- /* The first nested ext.partition should be a link to the next
- * logical partition. Everything other (recursive ext.partitions)
- * is junk.
- */
- for (p = p0, i = 0; i < 4; i++, p++) {
- start = dos_partition_start(p) * ssf;
- size = dos_partition_size(p) * ssf;
-
- if (size && is_extended(p))
- break;
- }
- if (i == 4)
- goto leave;
-
- cur_start = ex_start + start;
- cur_size = size;
- }
-leave:
- return 0;
-err:
- return -1;
-}
-
-static int probe_dos_pt(blkid_probe pr, const struct blkid_idmag *mag)
-{
- int i;
- int ssf;
- blkid_parttable tab = NULL;
- blkid_partlist ls;
- struct dos_partition *p0, *p;
- unsigned char *data;
- uint32_t start, size;
-
- data = blkid_probe_get_sector(pr, 0);
- if (!data)
- goto nothing;
-
- /* ignore disks with AIX magic number -- for more details see aix.c */
- if (memcmp(data, BLKID_AIX_MAGIC_STRING, BLKID_AIX_MAGIC_STRLEN) == 0)
- goto nothing;
-
- /*
- * Now that the 55aa signature is present, this is probably
- * either the boot sector of a FAT filesystem or a DOS-type
- * partition table.
- */
- if (blkid_probe_is_vfat(pr)) {
- DBG(DEBUG_LOWPROBE, printf("probably FAT -- ignore\n"));
- goto nothing;
- }
-
- p0 = (struct dos_partition *) (data + BLKID_MSDOS_PT_OFFSET);
-
- /*
- * Reject PT where boot indicator is not 0 or 0x80.
- */
- for (p = p0, i = 0; i < 4; i++, p++)
- if (p->boot_ind != 0 && p->boot_ind != 0x80) {
- DBG(DEBUG_LOWPROBE, printf("missing boot indicator -- ignore\n"));
- goto nothing;
- }
-
- /*
- * GPT uses valid MBR
- */
- for (p = p0, i = 0; i < 4; i++, p++) {
- if (p->sys_type == BLKID_GPT_PARTITION) {
- DBG(DEBUG_LOWPROBE, printf("probably GPT -- ignore\n"));
- goto nothing;
- }
- }
-
- blkid_probe_use_wiper(pr, BLKID_MSDOS_PT_OFFSET,
- 512 - BLKID_MSDOS_PT_OFFSET);
-
- /*
- * Well, all checks pass, it's MS-DOS partiton table
- */
- if (blkid_partitions_need_typeonly(pr))
- /* caller does not ask for details about partitions */
- return 0;
-
- ls = blkid_probe_get_partlist(pr);
-
- /* sector size factor (the start and size are in the real sectors, but
- * we need to convert all sizes to 512 logical sectors
- */
- ssf = blkid_probe_get_sectorsize(pr) / 512;
-
- /* allocate a new partition table */
- tab = blkid_partlist_new_parttable(ls, "dos", BLKID_MSDOS_PT_OFFSET);
- if (!tab)
- goto err;
-
- /* Parse primary partitions */
- for (p = p0, i = 0; i < 4; i++, p++) {
- blkid_partition par;
-
- start = dos_partition_start(p) * ssf;
- size = dos_partition_size(p) * ssf;
-
- if (!size) {
- /* Linux kernel ignores empty partitions, but partno for
- * the empty primary partitions is not reused */
- blkid_partlist_increment_partno(ls);
- continue;
- }
- par = blkid_partlist_add_partition(ls, tab, start, size);
- if (!par)
- goto err;
-
- blkid_partition_set_type(par, p->sys_type);
- blkid_partition_set_flags(par, p->boot_ind);
- }
-
- /* Linux uses partition numbers greater than 4
- * for all logical partition and all nested partition tables (bsd, ..)
- */
- blkid_partlist_set_partno(ls, 5);
-
- /* Parse logical partitions */
- for (p = p0, i = 0; i < 4; i++, p++) {
- start = dos_partition_start(p) * ssf;
- size = dos_partition_size(p) * ssf;
-
- if (!size)
- continue;
- if (is_extended(p) &&
- parse_dos_extended(pr, tab, start, size, ssf) == -1)
- goto err;
- }
-
- /* Parse subtypes (nested partitions) on large disks */
- if (!blkid_probe_is_tiny(pr)) {
- for (p = p0, i = 0; i < 4; i++, p++) {
- int n;
-
- if (!dos_partition_size(p) || is_extended(p))
- continue;
-
- for (n = 0; n < ARRAY_SIZE(dos_nested); n++) {
- if (dos_nested[n].type != p->sys_type)
- continue;
-
- if (blkid_partitions_do_subprobe(pr,
- blkid_partlist_get_partition(ls, i),
- dos_nested[n].id) == -1)
- goto err;
- break;
- }
- }
- }
- return 0;
-
-nothing:
- return 1;
-err:
- return -1;
-}
-
-
-const struct blkid_idinfo dos_pt_idinfo =
-{
- .name = "dos",
- .probefunc = probe_dos_pt,
- .magics =
- {
- /* DOS master boot sector:
- *
- * 0 | Code Area
- * 440 | Optional Disk signature
- * 446 | Partition table
- * 510 | 0x55
- * 511 | 0xAA
- */
- { .magic = "\x55\xAA", .len = 2, .sboff = 510 },
- { NULL }
- }
-};
-
diff --git a/shlibs/blkid/src/partitions/dos.h b/shlibs/blkid/src/partitions/dos.h
deleted file mode 100644
index 130aa0115..000000000
--- a/shlibs/blkid/src/partitions/dos.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef BLKID_PARTITIONS_DOS_H
-#define BLKID_PARTITIONS_DOS_H
-
-struct dos_partition {
- unsigned char boot_ind; /* 0x80 - active */
- unsigned char bh, bs, bc; /* begin CHS */
- unsigned char sys_type;
- unsigned char eh, es, ec; /* end CHS */
- unsigned char start_sect[4];
- unsigned char nr_sects[4];
-} __attribute__((packed));
-
-#define BLKID_MSDOS_PT_OFFSET 0x1be
-
-/* assemble badly aligned little endian integer */
-static inline unsigned int assemble4le(unsigned char *p)
-{
- return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
-}
-
-static inline unsigned int dos_partition_start(struct dos_partition *p)
-{
- return assemble4le(&(p->start_sect[0]));
-}
-
-static inline unsigned int dos_partition_size(struct dos_partition *p)
-{
- return assemble4le(&(p->nr_sects[0]));
-}
-
-static inline int is_valid_mbr_signature(const unsigned char *mbr)
-{
- return mbr[510] == 0x55 && mbr[511] == 0xaa ? 1 : 0;
-}
-
-#endif /* BLKID_PARTITIONS_DOS_H */
diff --git a/shlibs/blkid/src/partitions/gpt.c b/shlibs/blkid/src/partitions/gpt.c
deleted file mode 100644
index 9281a8943..000000000
--- a/shlibs/blkid/src/partitions/gpt.c
+++ /dev/null
@@ -1,401 +0,0 @@
-/*
- * EFI GPT partition parsing code
- *
- * Copyright (C) 2009 Karel Zak <kzak@redhat.com>
- *
- * This file may be redistributed under the terms of the
- * GNU Lesser General Public License.
- *
- * This code is not copy & past from any other implementation.
- *
- * For more information about GPT start your study at:
- * http://en.wikipedia.org/wiki/GUID_Partition_Table
- * http://technet.microsoft.com/en-us/library/cc739412(WS.10).aspx
- */
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <stddef.h>
-
-#include "partitions.h"
-#include "crc32.h"
-#include "dos.h"
-
-#define GPT_PRIMARY_LBA 1
-
-/* Signature - “EFI PART” */
-#define GPT_HEADER_SIGNATURE 0x5452415020494645ULL
-
-/* basic types */
-typedef uint16_t efi_char16_t;
-
-/* UUID */
-typedef struct {
- uint32_t time_low;
- uint16_t time_mid;
- uint16_t time_hi_and_version;
- uint8_t clock_seq_hi;
- uint8_t clock_seq_low;
- uint8_t node[6];
-} efi_guid_t;
-
-
-#define GPT_UNUSED_ENTRY_GUID \
- ((efi_guid_t) { 0x00000000, 0x0000, 0x0000, 0x00, 0x00, \
- { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }})
-struct gpt_header {
- uint64_t signature; /* "EFI PART" */
- uint32_t revision;
- uint32_t header_size; /* usualy 92 bytes */
- uint32_t header_crc32; /* checksum of header with this
- * field zeroed during calculation */
- uint32_t reserved1;
-
- uint64_t my_lba; /* location of this header copy */
- uint64_t alternate_lba; /* location of the other header copy */
- uint64_t first_usable_lba; /* lirst usable LBA for partitions */
- uint64_t last_usable_lba; /* last usable LBA for partitions */
-
- efi_guid_t disk_guid; /* disk UUID */
-
- uint64_t partition_entries_lba; /* always 2 in primary header copy */
- uint32_t num_partition_entries;
- uint32_t sizeof_partition_entry;
- uint32_t partition_entry_array_crc32;
-
- /*
- * The rest of the block is reserved by UEFI and must be zero. EFI
- * standard handles this by:
- *
- * uint8_t reserved2[ BLKSSZGET - 92 ];
- *
- * This definition is useless in practice. It is necessary to read
- * whole block from the device rather than sizeof(struct gpt_header)
- * only.
- */
-} __attribute__ ((packed));
-
-/*** not used
-struct gpt_entry_attributes {
- uint64_t required_to_function:1;
- uint64_t reserved:47;
- uint64_t type_guid_specific:16;
-} __attribute__ ((packed));
-***/
-
-struct gpt_entry {
- efi_guid_t partition_type_guid; /* type UUID */
- efi_guid_t unique_partition_guid; /* partition UUID */
- uint64_t starting_lba;
- uint64_t ending_lba;
-
- /*struct gpt_entry_attributes attributes;*/
-
- uint64_t attributes;
-
- efi_char16_t partition_name[72 / sizeof(efi_char16_t)]; /* UTF-16LE string*/
-} __attribute__ ((packed));
-
-
-/*
- * EFI uses crc32 with ~0 seed and xor's with ~0 at the end.
- */
-static inline uint32_t count_crc32(const unsigned char *buf, size_t len)
-{
- return (crc32(~0L, buf, len) ^ ~0L);
-}
-
-static inline unsigned char *get_lba_buffer(blkid_probe pr,
- uint64_t lba, size_t bytes)
-{
- return blkid_probe_get_buffer(pr,
- blkid_probe_get_sectorsize(pr) * lba, bytes);
-}
-
-static inline int guidcmp(efi_guid_t left, efi_guid_t right)
-{
- return memcmp(&left, &right, sizeof (efi_guid_t));
-}
-
-/*
- * UUID is traditionaly 16 byte big-endian array, except Intel EFI
- * specification where the UUID is a structure of little-endian fields.
- */
-static void swap_efi_guid(efi_guid_t *uid)
-{
- uid->time_low = swab32(uid->time_low);
- uid->time_mid = swab16(uid->time_mid);
- uid->time_hi_and_version = swab16(uid->time_hi_and_version);
-}
-
-static int last_lba(blkid_probe pr, uint64_t *lba)
-{
- blkid_loff_t sz = blkid_probe_get_size(pr);
- if (sz < blkid_probe_get_sectorsize(pr))
- return -1;
-
- *lba = (sz >> 9) - 1;
- return 0;
-}
-
-/*
- * Protective (legacy) MBR.
- *
- * This MBR contains standard DOS partition table with a single partition, type
- * of 0xEE. The partition usually encompassing the entire GPT drive - or 2TiB
- * for large disks.
- *
- * Note that Apple uses GPT/MBR hybrid disks, where the DOS partition table is
- * synchronized with GPT. This synchronization has many restriction of course
- * (due DOS PT limitations).
- *
- * Note that the PMBR detection is optional (enabled by default) and could be
- * disabled by BLKID_PARTS_FOPCE_GPT flag (see also blkid_paertitions_set_flags()).
- */
-static int is_pmbr_valid(blkid_probe pr)
-{
- int flags = blkid_partitions_get_flags(pr);
- unsigned char *data;
- struct dos_partition *p;
- int i;
-
- if (flags & BLKID_PARTS_FORCE_GPT)
- goto ok; /* skip PMBR check */
-
- data = blkid_probe_get_sector(pr, 0);
- if (!data)
- goto failed;
-
- if (!is_valid_mbr_signature(data))
- goto failed;
-
- p = (struct dos_partition *) (data + BLKID_MSDOS_PT_OFFSET);
-
- for (i = 0; i < 4; i++, p++) {
- if (p->sys_type == BLKID_GPT_PARTITION)
- goto ok;
- }
-failed:
- return 0;
-ok:
- return 1;
-}
-
-/*
- * Reads GPT header to @hdr and returns a pointer to @hdr or NULL in case of
- * error. The function also returns GPT entries in @ents.
- *
- * Note, this function does not allocate any memory. The GPT header has fixed
- * size so we use stack, and @ents returns memory from libblkid buffer (so the
- * next blkid_probe_get_buffer() will overwrite this buffer).
- *
- * This function checks validity of header and entries array. A corrupted
- * header is not returned.
- */
-static struct gpt_header *get_gpt_header(
- blkid_probe pr, struct gpt_header *hdr,
- struct gpt_entry **ents, uint64_t lba,
- uint64_t lastlba)
-{
- struct gpt_header *h;
- uint32_t crc, orgcrc;
- uint64_t lu, fu;
- size_t esz;
- uint32_t hsz, ssz;
-
- ssz = blkid_probe_get_sectorsize(pr);
-
- /* whole sector is allocated for GPT header */
- h = (struct gpt_header *) get_lba_buffer(pr, lba, ssz);
- if (!h)
- return NULL;
-
- if (le64_to_cpu(h->signature) != GPT_HEADER_SIGNATURE)
- return NULL;
-
- hsz = le32_to_cpu(h->header_size);
-
- /* EFI: The HeaderSize must be greater than 92 and must be less
- * than or equal to the logical block size.
- */
- if (hsz > ssz || hsz < sizeof(*h))
- return NULL;
-
- /* Header has to be verified when header_crc32 is zero */
- orgcrc = le32_to_cpu(h->header_crc32);
- h->header_crc32 = 0;
-
- crc = count_crc32((unsigned char *) h, hsz);
- if (crc != orgcrc) {
- DBG(DEBUG_LOWPROBE, printf("GPT header corrupted\n"));
- return NULL;
- }
- h->header_crc32 = cpu_to_le32(orgcrc);
-
- /* Valid header has to be at MyLBA */
- if (le64_to_cpu(h->my_lba) != lba) {
- DBG(DEBUG_LOWPROBE, printf(
- "GPT->MyLBA mismatch with real position\n"));
- return NULL;
- }
-
- fu = le64_to_cpu(h->first_usable_lba);
- lu = le64_to_cpu(h->last_usable_lba);
-
- /* Check if First and Last usable LBA makes sense */
- if (lu < fu || fu > lastlba || lu > lastlba) {
- DBG(DEBUG_LOWPROBE, printf(
- "GPT->{First,Last}UsableLBA out of range\n"));
- return NULL;
- }
-
- /* The header has to be outside usable range */
- if (fu < lba && lba < lu) {
- DBG(DEBUG_LOWPROBE, printf("GPT header is inside usable area\n"));
- return NULL;
- }
-
- /* Size of blocks with GPT entries */
- esz = le32_to_cpu(h->num_partition_entries) *
- le32_to_cpu(h->sizeof_partition_entry);
- if (!esz) {
- DBG(DEBUG_LOWPROBE, printf("GPT entries undefined\n"));
- return NULL;
- }
-
- /* The header seems valid, save it
- * (we don't care about zeros in hdr->reserved2 area) */
- memcpy(hdr, h, sizeof(*h));
- h = hdr;
-
- /* Read GPT entries */
- *ents = (struct gpt_entry *) get_lba_buffer(pr,
- le64_to_cpu(h->partition_entries_lba), esz);
- if (!*ents) {
- DBG(DEBUG_LOWPROBE, printf("GPT entries unreadable\n"));
- return NULL;
- }
-
- /* Validate entries */
- crc = count_crc32((unsigned char *) *ents, esz);
- if (crc != le32_to_cpu(h->partition_entry_array_crc32)) {
- DBG(DEBUG_LOWPROBE, printf("GPT entries corrupted\n"));
- return NULL;
- }
-
- return h;
-}
-
-static int probe_gpt_pt(blkid_probe pr, const struct blkid_idmag *mag)
-{
- uint64_t lastlba = 0, lba;
- struct gpt_header hdr, *h;
- struct gpt_entry *e;
- blkid_parttable tab = NULL;
- blkid_partlist ls;
- int i;
- uint64_t fu, lu;
- uint32_t ssf;
-
-
- if (last_lba(pr, &lastlba))
- goto nothing;
-
- if (!is_pmbr_valid(pr))
- goto nothing;
-
- h = get_gpt_header(pr, &hdr, &e, (lba = GPT_PRIMARY_LBA), lastlba);
- if (!h)
- h = get_gpt_header(pr, &hdr, &e, (lba = lastlba), lastlba);
-
- if (!h)
- goto nothing;
-
- blkid_probe_use_wiper(pr, lba * blkid_probe_get_size(pr), 8);
-
- if (blkid_partitions_need_typeonly(pr))
- /* caller does not ask for details about partitions */
- return 0;
-
- ls = blkid_probe_get_partlist(pr);
- if (!ls)
- goto err;
-
- tab = blkid_partlist_new_parttable(ls, "gpt", lba << 9);
- if (!tab)
- goto err;
-
- ssf = blkid_probe_get_sectorsize(pr) / 512;
-
- fu = le64_to_cpu(h->first_usable_lba);
- lu = le64_to_cpu(h->last_usable_lba);
-
- for (i = 0; i < le32_to_cpu(h->num_partition_entries); i++, e++) {
-
- blkid_partition par;
- uint64_t start = le64_to_cpu(e->starting_lba);
- uint64_t size = le64_to_cpu(e->ending_lba) -
- le64_to_cpu(e->starting_lba) + 1ULL;
-
- /* 00000000-0000-0000-0000-000000000000 entry */
- if (!guidcmp(e->partition_type_guid, GPT_UNUSED_ENTRY_GUID)) {
- blkid_partlist_increment_partno(ls);
- continue;
- }
- /* the partition has to inside usable range */
- if (start < fu || start + size - 1 > lu) {
- DBG(DEBUG_LOWPROBE, printf(
- "GPT entry[%d] overflows usable area - ignore\n",
- i));
- blkid_partlist_increment_partno(ls);
- continue;
- }
-
- par = blkid_partlist_add_partition(ls, tab,
- start * ssf, size * ssf);
- if (!par)
- goto err;
-
- blkid_partition_set_utf8name(par,
- (unsigned char *) e->partition_name,
- sizeof(e->partition_name), BLKID_ENC_UTF16LE);
-
- swap_efi_guid(&e->unique_partition_guid);
- swap_efi_guid(&e->partition_type_guid);
-
- blkid_partition_set_uuid(par,
- (const unsigned char *) &e->unique_partition_guid);
-
- blkid_partition_set_type_uuid(par,
- (const unsigned char *) &e->partition_type_guid);
-
- blkid_partition_set_flags(par, e->attributes);
- }
-
- return 0;
-
-nothing:
- return 1;
-err:
- return -1;
-}
-
-
-const struct blkid_idinfo gpt_pt_idinfo =
-{
- .name = "gpt",
- .probefunc = probe_gpt_pt,
- .minsz = 1024 * 1440 + 1, /* ignore floppies */
-
- /*
- * It would be possible to check for DOS signature (0xAA55), but
- * unfortunately almost all EFI GPT implemenations allow to optionaly
- * skip the legacy MBR. We follows this behavior and MBR is optional.
- * See is_valid_pmbr().
- *
- * It means we have to always call probe_gpt_pt().
- */
- .magics = BLKID_NONE_MAGIC
-};
-
diff --git a/shlibs/blkid/src/partitions/mac.c b/shlibs/blkid/src/partitions/mac.c
deleted file mode 100644
index 538b27270..000000000
--- a/shlibs/blkid/src/partitions/mac.c
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * mac partitions parsing code
- *
- * Copyright (C) 2009 Karel Zak <kzak@redhat.com>
- *
- * This file may be redistributed under the terms of the
- * GNU Lesser General Public License.
- *
- */
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdint.h>
-
-#include "partitions.h"
-
-#define MAC_PARTITION_MAGIC 0x504d
-#define MAC_PARTITION_MAGIC_OLD 0x5453
-
-/*
- * Mac partition entry
- * http://developer.apple.com/legacy/mac/library/documentation/mac/Devices/Devices-126.html
- */
-struct mac_partition {
- uint16_t signature; /* expected to be MAC_PARTITION_MAGIC */
- uint16_t reserved; /* reserved */
- uint32_t map_count; /* # blocks in partition map */
- uint32_t start_block; /* absolute starting block # of partition */
- uint32_t block_count; /* number of blocks in partition */
- char name[32]; /* partition name */
- char type[32]; /* string type description */
- uint32_t data_start; /* rel block # of first data block */
- uint32_t data_count; /* number of data blocks */
- uint32_t status; /* partition status bits */
- uint32_t boot_start; /* first logical block of boot code */
- uint32_t boot_size; /* size of boot code, in bytes */
- uint32_t boot_load; /* boot code load address */
- uint32_t boot_load2; /* reserved */
- uint32_t boot_entry; /* boot code entry point */
- uint32_t boot_entry2; /* reserved */
- uint32_t boot_cksum; /* boot code checksum */
- char processor[16]; /* identifies ISA of boot */
-
- /* there is more stuff after this that we don't need */
-} __attribute__((packed));
-
-/*
- * Driver descriptor structure, in block 0
- * http://developer.apple.com/legacy/mac/library/documentation/mac/Devices/Devices-121.html
- */
-struct mac_driver_desc {
- uint16_t signature; /* expected to be MAC_DRIVER_MAGIC */
- uint16_t block_size; /* block size of the device */
- uint32_t block_count; /* number of blocks on the device */
-
- /* there is more stuff after this that we don't need */
-} __attribute__((packed));
-
-static inline unsigned char *get_mac_block(
- blkid_probe pr,
- struct mac_driver_desc *md,
- uint32_t num)
-{
- return blkid_probe_get_buffer(pr,
- (blkid_loff_t) num * md->block_size, num);
-}
-
-static inline int has_part_signature(struct mac_partition *p)
-{
- return be16_to_cpu(p->signature) == MAC_PARTITION_MAGIC ||
- be16_to_cpu(p->signature) == MAC_PARTITION_MAGIC_OLD;
-}
-
-static int probe_mac_pt(blkid_probe pr, const struct blkid_idmag *mag)
-{
- struct mac_driver_desc *md;
- struct mac_partition *p;
- blkid_parttable tab = NULL;
- blkid_partlist ls;
- int i;
- uint16_t ssf; /* sector size fragment */
- uint32_t nblks;
-
-
- /* The driver descriptor record is always located at physical block 0,
- * the first block on the disk.
- */
- md = (struct mac_driver_desc *) blkid_probe_get_sector(pr, 0);
- if (!md)
- goto nothing;
-
-
- /* The partition map always begins at physical block 1,
- * the second block on the disk.
- */
- p = (struct mac_partition *) get_mac_block(pr, md, 1);
- if (!p)
- goto nothing;
-
- /* check the first partition signature */
- if (!has_part_signature(p))
- goto nothing;
-
- if (blkid_partitions_need_typeonly(pr))
- /* caller does not ask for details about partitions */
- return 0;
-
- ls = blkid_probe_get_partlist(pr);
- if (!ls)
- goto err;
-
- tab = blkid_partlist_new_parttable(ls, "mac", 0);
- if (!tab)
- goto err;
-
- ssf = md->block_size / 512;
- nblks = be32_to_cpu(p->map_count);
-
- for (i = 1; i <= nblks; ++i) {
- blkid_partition par;
- uint32_t start;
- uint32_t size;
-
- p = (struct mac_partition *) get_mac_block(pr, md, i);
- if (!p)
- goto nothing;
- if (!has_part_signature(p))
- goto nothing;
-
- if (be32_to_cpu(p->map_count) != nblks) {
- DBG(DEBUG_LOWPROBE, printf(
- "mac: inconsisten map_count in partition map, "
- "entry[0]: %d, entry[%d]: %d\n",
- nblks, i - 1,
- be32_to_cpu(p->map_count)));
- }
-
- /*
- * note that libparted ignores some mac partitions according to
- * the partition name (e.g. "Apple_Free" or "Apple_Void"). We
- * follows Linux kernel and all partitions are visible
- */
-
- start = be32_to_cpu(p->start_block) * ssf;
- size = be32_to_cpu(p->block_count) * ssf;
-
- par = blkid_partlist_add_partition(ls, tab, start, size);
- if (!par)
- goto err;
-
- blkid_partition_set_name(par, (unsigned char *) p->name,
- sizeof(p->name));
-
- blkid_partition_set_type_string(par, (unsigned char *) p->type,
- sizeof(p->type));
- }
-
- return 0;
-
-nothing:
- return 1;
-err:
- return -1;
-}
-
-/*
- * Mac disk always begin with "Driver Descriptor Record"
- * (struct mac_driver_desc) and magic 0x4552.
- */
-const struct blkid_idinfo mac_pt_idinfo =
-{
- .name = "mac",
- .probefunc = probe_mac_pt,
- .magics =
- {
- /* big-endian magic string */
- { .magic = "\x45\x52", .len = 2 },
- { NULL }
- }
-};
-
diff --git a/shlibs/blkid/src/partitions/minix.c b/shlibs/blkid/src/partitions/minix.c
deleted file mode 100644
index 0887d1a3b..000000000
--- a/shlibs/blkid/src/partitions/minix.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Minix partition parsing code
- *
- * Copyright (C) 2009 Karel Zak <kzak@redhat.com>
- *
- * This file may be redistributed under the terms of the
- * GNU Lesser General Public License.
- */
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdint.h>
-
-#include "partitions.h"
-#include "dos.h"
-
-/*
- * Minix subpartitions are always within primary dos partition.
- */
-#define MINIX_MAXPARTITIONS 4
-
-static int probe_minix_pt(blkid_probe pr, const struct blkid_idmag *mag)
-{
- struct dos_partition *p;
- blkid_parttable tab = NULL;
- blkid_partition parent;
- blkid_partlist ls;
- unsigned char *data;
- int i;
-
- data = blkid_probe_get_sector(pr, 0);
- if (!data)
- goto nothing;
-
- ls = blkid_probe_get_partlist(pr);
- if (!ls)
- goto err;
-
- /* Parent is required, because Minix uses the same PT as DOS and
- * difference is only in primary partition (parent) type.
- */
- parent = blkid_partlist_get_parent(ls);
- if (!parent)
- goto nothing;
-
- if (blkid_partition_get_type(parent) != BLKID_MINIX_PARTITION)
- goto nothing;
-
- if (blkid_partitions_need_typeonly(pr))
- /* caller does not ask for details about partitions */
- return 0;
-
- p = (struct dos_partition *) (data + BLKID_MSDOS_PT_OFFSET);
-
- tab = blkid_partlist_new_parttable(ls, "minix", BLKID_MSDOS_PT_OFFSET);
- if (!tab)
- goto err;
-
- for (i = 0; i < MINIX_MAXPARTITIONS; i++, p++) {
- uint32_t start, size;
- blkid_partition par;
-
- if (p->sys_type != BLKID_MINIX_PARTITION)
- continue;
-
- start = dos_partition_start(p);
- size = dos_partition_size(p);
-
- if (parent && !blkid_is_nested_dimension(parent, start, size)) {
- DBG(DEBUG_LOWPROBE, printf(
- "WARNING: minix partition (%d) overflow "
- "detected, ignore\n", i));
- continue;
- }
-
- par = blkid_partlist_add_partition(ls, tab, start, size);
- if (!par)
- goto err;
-
- blkid_partition_set_type(par, p->sys_type);
- blkid_partition_set_flags(par, p->boot_ind);
- }
-
- return 0;
-
-nothing:
- return 1;
-err:
- return -1;
-}
-
-/* same as DOS */
-const struct blkid_idinfo minix_pt_idinfo =
-{
- .name = "minix",
- .probefunc = probe_minix_pt,
- .magics =
- {
- { .magic = "\x55\xAA", .len = 2, .sboff = 510 },
- { NULL }
- }
-};
-
diff --git a/shlibs/blkid/src/partitions/partitions.c b/shlibs/blkid/src/partitions/partitions.c
deleted file mode 100644
index 89f058718..000000000
--- a/shlibs/blkid/src/partitions/partitions.c
+++ /dev/null
@@ -1,1336 +0,0 @@
-/*
- * partitions - partition tables parsing
- *
- * Copyright (C) 2008-2009 Karel Zak <kzak@redhat.com>
- *
- * This file may be redistributed under the terms of the
- * GNU Lesser General Public License.
- *
- */
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <stdint.h>
-#include <inttypes.h>
-#include <stdarg.h>
-
-#include "partitions.h"
-#include "sysfs.h"
-
-/**
- * SECTION:partitions
- * @title: Partitions probing
- * @short_description: partitions tables detection and parsing
- *
- * This chain supports binary and NAME=value interfaces, but complete PT
- * description is provided by binary interface only. The libblkid prober is
- * compatible with kernel partition tables parser. The parser does not return
- * empty (size=0) partitions or special hidden partitions.
- *
- * NAME=value interface, supported tags:
- *
- * @PTTYPE: partition table type (dos, gpt, etc.).
- *
- * @PART_ENTRY_SCHEME: partition table type
- *
- * @PART_ENTRY_NAME: partition name (gpt and mac only)
- *
- * @PART_ENTRY_UUID: partition UUID (gpt only)
- *
- * @PART_ENTRY_TYPE: partition type, 0xNN (e.g 0x82) or type UUID (gpt only) or type string (mac)
- *
- * @PART_ENTRY_FLAGS: partition flags (e.g. boot_ind) or attributes (e.g. gpt attributes)
- *
- * @PART_ENTRY_NUMBER: partition number
- *
- * Example:
- *
- * <informalexample>
- * <programlisting>
- * blkid_probe pr;
- * const char *ptname;
- *
- * pr = blkid_new_probe_from_filename(devname);
- * if (!pr)
- * err("%s: faild to open device", devname);
- *
- * blkid_probe_enable_partitions(pr, TRUE);
- * blkid_do_fullprobe(pr);
- *
- * blkid_probe_lookup_value(pr, "PTTYPE", &ptname, NULL);
- * printf("%s partition type detected\n", pttype);
- *
- * blkid_free_probe(pr);
- *
- * // don't forget to check return codes in your code!
- * </programlisting>
- * </informalexample>
- *
- * Binary interface:
- *
- * <informalexample>
- * <programlisting>
- * blkid_probe pr;
- * blkid_partlist ls;
- * int nparts, i;
- *
- * pr = blkid_new_probe_from_filename(devname);
- * if (!pr)
- * err("%s: faild to open device", devname);
- *
- * ls = blkid_probe_get_partitions(pr);
- * nparts = blkid_partlist_numof_partitions(ls);
- *
- * for (i = 0; i < nparts; i++) {
- * blkid_partition par = blkid_partlist_get_partition(ls, i);
- * printf("#%d: %llu %llu 0x%x",
- * blkid_partition_get_partno(par),
- * blkid_partition_get_start(par),
- * blkid_partition_get_size(par),
- * blkid_partition_get_type(par));
- * }
- *
- * blkid_free_probe(pr);
- *
- * // don't forget to check return codes in your code!
- * </programlisting>
- * </informalexample>
- */
-
-/*
- * Chain driver function
- */
-static int partitions_probe(blkid_probe pr, struct blkid_chain *chn);
-static void partitions_free_data(blkid_probe pr, void *data);
-
-/*
- * Partitions chain probing functions
- */
-static const struct blkid_idinfo *idinfos[] =
-{
- &aix_pt_idinfo,
- &sgi_pt_idinfo,
- &sun_pt_idinfo,
- &dos_pt_idinfo,
- &gpt_pt_idinfo,
- &mac_pt_idinfo,
- &ultrix_pt_idinfo,
- &bsd_pt_idinfo,
- &unixware_pt_idinfo,
- &solaris_x86_pt_idinfo,
- &minix_pt_idinfo
-};
-
-/*
- * Driver definition
- */
-const struct blkid_chaindrv partitions_drv = {
- .id = BLKID_CHAIN_PARTS,
- .name = "partitions",
- .dflt_enabled = FALSE,
- .idinfos = idinfos,
- .nidinfos = ARRAY_SIZE(idinfos),
- .has_fltr = TRUE,
- .probe = partitions_probe,
- .safeprobe = partitions_probe,
- .free_data = partitions_free_data
-};
-
-
-/*
- * For compatibility with the rest of libblkid API (with the old high-level
- * API) we use completely opaque typedefs for all structs. Don't forget that
- * the final blkid_* types are pointers! See blkid.h.
- *
- * [Just for the record, I hate typedef for pointers --kzak]
- */
-
-/* exported as opaque type "blkid_parttable" */
-struct blkid_struct_parttable {
- const char *type; /* partition table type */
- blkid_loff_t offset; /* begin of the partition table */
- int nparts; /* number of partitions */
- blkid_partition parent; /* parent of nested partition table */
-
- struct list_head t_tabs; /* all tables */
-};
-
-/* exported as opaque type "blkid_partition" */
-struct blkid_struct_partition {
- blkid_loff_t start; /* begin of the partition */
- blkid_loff_t size; /* size of the partitions */
-
- int type; /* partition type */
- char typestr[37]; /* partition type string (GPT and Mac) */
-
- unsigned long long flags; /* partition flags / attributes */
-
- int partno; /* partition number */
- char uuid[37]; /* UUID (when supported by PT), e.g GPT */
- unsigned char name[128]; /* Partition in UTF8 name (when supporte by PT), e.g. Mac */
-
- blkid_parttable tab; /* partition table */
-};
-
-/* exported as opaque type "blkid_partlist" */
-struct blkid_struct_partlist {
- int next_partno; /* next partition number */
- blkid_partition next_parent; /* next parent if parsing nested PT */
-
- int nparts; /* number of partitions */
- int nparts_max; /* max.number of partitions */
- blkid_partition parts; /* array of partitions */
-
- struct list_head l_tabs; /* list of partition tables */
-};
-
-static int blkid_partitions_probe_partition(blkid_probe pr);
-
-/**
- * blkid_probe_enable_partitions:
- * @pr: probe
- * @enable: TRUE/FALSE
- *
- * Enables/disables the partitions probing for non-binary interface.
- *
- * Returns: 0 on success, or -1 in case of error.
- */
-int blkid_probe_enable_partitions(blkid_probe pr, int enable)
-{
- if (!pr)
- return -1;
- pr->chains[BLKID_CHAIN_PARTS].enabled = enable;
- return 0;
-}
-
-/**
- * blkid_probe_set_partitions_flags:
- * @pr: prober
- * @flags: BLKID_PARTS_* flags
- *
- * Sets probing flags to the partitions prober. This function is optional.
- *
- * Returns: 0 on success, or -1 in case of error.
- */
-int blkid_probe_set_partitions_flags(blkid_probe pr, int flags)
-{
- if (!pr)
- return -1;
-
- pr->chains[BLKID_CHAIN_PARTS].flags = flags;
- return 0;
-}
-
-/**
- * blkid_probe_reset_partitions_filter:
- * @pr: prober
- *
- * Resets partitions probing filter
- *
- * Returns: 0 on success, or -1 in case of error.
- */
-int blkid_probe_reset_partitions_filter(blkid_probe pr)
-{
- return __blkid_probe_reset_filter(pr, BLKID_CHAIN_PARTS);
-}
-
-/**
- * blkid_probe_invert_partitions_filter:
- * @pr: prober
- *
- * Inverts partitions probing filter
- *
- * Returns: 0 on success, or -1 in case of error.
- */
-int blkid_probe_invert_partitions_filter(blkid_probe pr)
-{
- return __blkid_probe_invert_filter(pr, BLKID_CHAIN_PARTS);
-}
-
-/**
- * blkid_probe_filter_partitions_type:
- * @pr: prober
- * @flag: filter BLKID_FLTR_{NOTIN,ONLYIN} flag
- * @names: NULL terminated array of probing function names (e.g. "vfat").
- *
- * BLKID_FLTR_NOTIN - probe for all items which are NOT IN @names
- * BLKID_FLTR_ONLYIN - probe for items which are IN @names
- *
- * Returns: 0 on success, or -1 in case of error.
- */
-int blkid_probe_filter_partitions_type(blkid_probe pr, int flag, char *names[])
-{
- return __blkid_probe_filter_types(pr, BLKID_CHAIN_PARTS, flag, names);
-}
-
-/**
- * blkid_probe_get_partitions:
- * @pr: probe
- *
- * This is a binary interface for partitions. See also blkid_partlist_*
- * functions.
- *
- * This function is independent on blkid_do_[safe,full]probe() and
- * blkid_probe_enable_partitions() calls.
- *
- * WARNING: the returned object will be overwritten by the next
- * blkid_probe_get_partitions() call for the same @pr. If you want to
- * use more blkid_partlist objects in the same time you have to create
- * more blkid_probe handlers (see blkid_new_probe()).
- *
- * Returns: list of partitions, or NULL in case of error.
- */
-blkid_partlist blkid_probe_get_partitions(blkid_probe pr)
-{
- return (blkid_partlist) blkid_probe_get_binary_data(pr,
- &pr->chains[BLKID_CHAIN_PARTS]);
-}
-
-/* for internal usage only */
-blkid_partlist blkid_probe_get_partlist(blkid_probe pr)
-{
- return (blkid_partlist) pr->chains[BLKID_CHAIN_PARTS].data;
-}
-
-static void blkid_probe_set_partlist(blkid_probe pr, blkid_partlist ls)
-{
- pr->chains[BLKID_CHAIN_PARTS].data = ls;
-}
-
-static void ref_parttable(blkid_parttable tab)
-{
- tab->nparts++;
-}
-
-static void unref_parttable(blkid_parttable tab)
-{
- tab->nparts--;
-
- if (tab->nparts <= 0) {
- list_del(&tab->t_tabs);
- free(tab);
- }
-}
-
-/* free all allocated parttables */
-static void free_parttables(blkid_partlist ls)
-{
- if (!ls || !ls->l_tabs.next)
- return;
-
- /* remove unassigned partition tables */
- while (!list_empty(&ls->l_tabs)) {
- blkid_parttable tab = list_entry(ls->l_tabs.next,
- struct blkid_struct_parttable, t_tabs);
- unref_parttable(tab);
- }
-}
-
-static void reset_partlist(blkid_probe pr, blkid_partlist ls)
-{
- if (!ls)
- return;
-
- free_parttables(ls);
-
- if (ls->next_partno) {
- /* already initialized - reset */
- int tmp_nparts = ls->nparts_max;
- blkid_partition tmp_parts = ls->parts;
-
- memset(ls, 0, sizeof(struct blkid_struct_partlist));
-
- ls->nparts_max = tmp_nparts;
- ls->parts = tmp_parts;
- }
-
- ls->nparts = 0;
- ls->next_partno = 1;
- INIT_LIST_HEAD(&ls->l_tabs);
-
- DBG(DEBUG_LOWPROBE, printf("partlist reseted\n"));
-}
-
-static blkid_partlist partitions_init_data(blkid_probe pr, struct blkid_chain *chn)
-{
- blkid_partlist ls;
-
- if (chn->data)
- ls = (blkid_partlist) chn->data;
- else {
- /* allocate the new list of partitions */
- ls = calloc(1, sizeof(struct blkid_struct_partlist));
- if (!ls)
- return NULL;
- chn->data = (void *) ls;
- }
-
- reset_partlist(pr, ls);
-
- DBG(DEBUG_LOWPROBE,
- printf("parts: initialized partitions list (%p, size=%d)\n",
- ls, ls->nparts_max));
- return ls;
-}
-
-static void partitions_free_data(blkid_probe pr, void *data)
-{
- blkid_partlist ls = (blkid_partlist) data;
-
- if (!ls)
- return;
-
- free_parttables(ls);
-
- /* deallocate partitions and partlist */
- free(ls->parts);
- free(ls);
-}
-
-blkid_parttable blkid_partlist_new_parttable(blkid_partlist ls,
- const char *type, blkid_loff_t offset)
-{
- blkid_parttable tab;
-
- tab = calloc(1, sizeof(struct blkid_struct_parttable));
- if (!tab)
- return NULL;
- tab->type = type;
- tab->offset = offset;
- tab->parent = ls->next_parent;
-
- INIT_LIST_HEAD(&tab->t_tabs);
- list_add_tail(&tab->t_tabs, &ls->l_tabs);
-
- DBG(DEBUG_LOWPROBE,
- printf("parts: create a new partition table "
- "(%p, type=%s, offset=%"PRId64")\n", tab, type, offset));
- return tab;
-}
-
-static blkid_partition new_partition(blkid_partlist ls, blkid_parttable tab)
-{
- blkid_partition par;
-
- if (ls->nparts + 1 > ls->nparts_max) {
- /* Linux kernel has DISK_MAX_PARTS=256, but it's too much for
- * generic Linux machine -- let start with 32 partititions.
- */
- ls->parts = realloc(ls->parts, (ls->nparts_max + 32) *
- sizeof(struct blkid_struct_partition));
- if (!ls->parts)
- return NULL;
- ls->nparts_max += 32;
- }
-
- par = &ls->parts[ls->nparts++];
- memset(par, 0, sizeof(struct blkid_struct_partition));
-
- ref_parttable(tab);
- par->tab = tab;
- par->partno = blkid_partlist_increment_partno(ls);
-
- return par;
-}
-
-blkid_partition blkid_partlist_add_partition(blkid_partlist ls,
- blkid_parttable tab,
- blkid_loff_t start, blkid_loff_t size)
-{
- blkid_partition par = new_partition(ls, tab);
-
- if (!par)
- return NULL;
-
- par->start = start;
- par->size = size;
-
- DBG(DEBUG_LOWPROBE,
- printf("parts: add partition (%p start=%"
- PRId64 ", size=%" PRId64 ", table=%p)\n",
- par, par->start, par->size, tab));
- return par;
-}
-
-/* allows to modify used partitions numbers (for example for logical partitions) */
-int blkid_partlist_set_partno(blkid_partlist ls, int partno)
-{
- if (!ls)
- return -1;
- ls->next_partno = partno;
- return 0;
-}
-
-int blkid_partlist_increment_partno(blkid_partlist ls)
-{
- return ls ? ls->next_partno++ : -1;
-}
-
-/* allows to set "parent" for the next nested partition */
-int blkid_partlist_set_parent(blkid_partlist ls, blkid_partition par)
-{
- if (!ls)
- return -1;
- ls->next_parent = par;
- return 0;
-}
-
-blkid_partition blkid_partlist_get_parent(blkid_partlist ls)
-{
- if (!ls)
- return NULL;
- return ls->next_parent;
-}
-
-int blkid_partitions_need_typeonly(blkid_probe pr)
-{
- struct blkid_chain *chn = blkid_probe_get_chain(pr);
-
- return chn && chn->data && chn->binary ? FALSE : TRUE;
-}
-
-/* get private chain flags */
-int blkid_partitions_get_flags(blkid_probe pr)
-{
- struct blkid_chain *chn = blkid_probe_get_chain(pr);
-
- return chn ? chn->flags : 0;
-}
-
-/* check if @start and @size are within @par partition */
-int blkid_is_nested_dimension(blkid_partition par,
- blkid_loff_t start, blkid_loff_t size)
-{
- blkid_loff_t pstart;
- blkid_loff_t psize;
-
- if (!par)
- return 0;
-
- pstart = blkid_partition_get_start(par);
- psize = blkid_partition_get_size(par);
-
- if (start < pstart || start + size > pstart + psize)
- return 0;
-
- return 1;
-}
-
-static int idinfo_probe(blkid_probe pr, const struct blkid_idinfo *id)
-{
- const struct blkid_idmag *mag;
- int rc = 1; /* = nothing detected */
-
- if (pr->size <= 0 || (id->minsz && id->minsz > pr->size))
- goto nothing; /* the device is too small */
-
- if (blkid_probe_get_idmag(pr, id, NULL, &mag))
- goto nothing;
-
- /* final check by probing function */
- if (id->probefunc) {
- DBG(DEBUG_LOWPROBE, printf(
- "%s: ---> call probefunc()\n", id->name));
- rc = id->probefunc(pr, mag);
- if (rc == -1) {
- /* reset after error */
- reset_partlist(pr, blkid_probe_get_partlist(pr));
- DBG(DEBUG_LOWPROBE, printf(
- "%s probefunc failed\n", id->name));
- }
- DBG(DEBUG_LOWPROBE, printf(
- "%s: <--- (rc = %d)\n", id->name, rc));
- }
-
-nothing:
- return rc;
-}
-
-/*
- * The blkid_do_probe() backend.
- */
-static int partitions_probe(blkid_probe pr, struct blkid_chain *chn)
-{
- int i = 0, rc = 1;
-
- if (!pr || chn->idx < -1)
- return -1;
- blkid_probe_chain_reset_vals(pr, chn);
-
- if (chn->binary)
- partitions_init_data(pr, chn);
-
- if (!pr->wipe_size && (pr->prob_flags & BLKID_PROBE_FL_IGNORE_PT))
- goto details_only;
-
- DBG(DEBUG_LOWPROBE,
- printf("--> starting probing loop [PARTS idx=%d]\n",
- chn->idx));
-
- i = chn->idx + 1;
-
- for ( ; i < ARRAY_SIZE(idinfos); i++) {
- const char *name;
-
- chn->idx = i;
-
- /* apply filter */
- if (chn->fltr && blkid_bmp_get_item(chn->fltr, i))
- continue;
-
- /* apply checks from idinfo */
- if (idinfo_probe(pr, idinfos[i]) != 0)
- continue;
-
- name = idinfos[i]->name;
-
- /* all checks passed */
- if (!chn->binary)
- blkid_probe_set_value(pr, "PTTYPE",
- (unsigned char *) name,
- strlen(name) + 1);
- DBG(DEBUG_LOWPROBE,
- printf("<-- leaving probing loop (type=%s) [PARTS idx=%d]\n",
- name, chn->idx));
- rc = 0;
- break;
- }
-
- if (rc == 1) {
- DBG(DEBUG_LOWPROBE,
- printf("<-- leaving probing loop (failed) [PARTS idx=%d]\n",
- chn->idx));
- }
-
-details_only:
- /*
- * Gather PART_ENTRY_* values if the current device is a partition.
- */
- if (!chn->binary &&
- (blkid_partitions_get_flags(pr) & BLKID_PARTS_ENTRY_DETAILS)) {
-
- if (!blkid_partitions_probe_partition(pr))
- rc = 0;
- }
-
- return rc;
-}
-
-/* Probe for nested partition table within the parental partition */
-int blkid_partitions_do_subprobe(blkid_probe pr, blkid_partition parent,
- const struct blkid_idinfo *id)
-{
- blkid_probe prc;
- int rc = 1;
- blkid_partlist ls;
- blkid_loff_t sz, off;
-
- DBG(DEBUG_LOWPROBE, printf(
- "parts: ----> %s subprobe requested (parent=%p)\n",
- id->name, parent));
-
- if (!pr || !parent || !parent->size)
- return -1;
-
- /* range defined by parent */
- sz = ((blkid_loff_t) parent->size) << 9;
- off = ((blkid_loff_t) parent->start) << 9;
-
- if (off < pr->off || pr->off + pr->size < off + sz) {
- DBG(DEBUG_LOWPROBE, printf(
- "ERROR: parts: <---- '%s' subprobe: overflow detected.\n",
- id->name));
- return -1;
- }
-
- /* create private prober */
- prc = blkid_clone_probe(pr);
- if (!prc)
- return -1;
-
- blkid_probe_set_dimension(prc, off, sz);
-
- /* clone is always with reseted chain, fix it */
- prc->cur_chain = blkid_probe_get_chain(pr);
-
- /*
- * Set 'parent' to the current list of the partitions and use the list
- * in cloned prober (so the cloned prober will extend the current list
- * of partitions rather than create a new).
- */
- ls = blkid_probe_get_partlist(pr);
- blkid_partlist_set_parent(ls, parent);
-
- blkid_probe_set_partlist(prc, ls);
-
- rc = idinfo_probe(prc, id);
-
- blkid_probe_set_partlist(prc, NULL);
- blkid_partlist_set_parent(ls, NULL);
-
- blkid_free_probe(prc); /* free cloned prober */
-
- DBG(DEBUG_LOWPROBE, printf(
- "parts: <---- %s subprobe done (parent=%p, rc=%d)\n",
- id->name, parent, rc));
-
- return rc;
-}
-
-static int blkid_partitions_probe_partition(blkid_probe pr)
-{
- int rc = 1;
- blkid_probe disk_pr = NULL;
- blkid_partlist ls;
- blkid_partition par;
- dev_t devno;
-
- devno = blkid_probe_get_devno(pr);
- if (!devno)
- goto nothing;
-
- disk_pr = blkid_probe_get_wholedisk_probe(pr);
- if (!disk_pr)
- goto nothing;
-
- /* parse PT */
- ls = blkid_probe_get_partitions(disk_pr);
- if (!ls)
- goto nothing;
-
- par = blkid_partlist_devno_to_partition(ls, devno);
- if (par) {
- const char *v;
- blkid_parttable tab = blkid_partition_get_table(par);
- dev_t disk = blkid_probe_get_devno(disk_pr);
-
- if (tab) {
- v = blkid_parttable_get_type(tab);
- if (v)
- blkid_probe_set_value(pr, "PART_ENTRY_SCHEME",
- (unsigned char *) v, strlen(v) + 1);
- }
-
- v = blkid_partition_get_name(par);
- if (v)
- blkid_probe_set_value(pr, "PART_ENTRY_NAME",
- (unsigned char *) v, strlen(v) + 1);
-
- v = blkid_partition_get_uuid(par);
- if (v)
- blkid_probe_set_value(pr, "PART_ENTRY_UUID",
- (unsigned char *) v, strlen(v) + 1);
-
- /* type */
- v = blkid_partition_get_type_string(par);
- if (v)
- blkid_probe_set_value(pr, "PART_ENTRY_TYPE",
- (unsigned char *) v, strlen(v) + 1);
- else
- blkid_probe_sprintf_value(pr, "PART_ENTRY_TYPE",
- "0x%x", blkid_partition_get_type(par));
-
- if (blkid_partition_get_flags(par))
- blkid_probe_sprintf_value(pr, "PART_ENTRY_FLAGS",
- "0x%llx", blkid_partition_get_flags(par));
-
- blkid_probe_sprintf_value(pr, "PART_ENTRY_NUMBER",
- "%d", blkid_partition_get_partno(par));
-
- blkid_probe_sprintf_value(pr, "PART_ENTRY_OFFSET", "%jd",
- blkid_partition_get_start(par));
- blkid_probe_sprintf_value(pr, "PART_ENTRY_SIZE", "%jd",
- blkid_partition_get_size(par));
-
- blkid_probe_sprintf_value(pr, "PART_ENTRY_DISK", "%u:%u",
- major(disk), minor(disk));
- }
- rc = 0;
-nothing:
- return rc;
-}
-
-/*
- * Returns 1 if the device is whole-disk and the area specified by @offset and
- * @size is covered by any partition.
- */
-int blkid_probe_is_covered_by_pt(blkid_probe pr,
- blkid_loff_t offset, blkid_loff_t size)
-{
- blkid_probe prc;
- blkid_partlist ls = NULL;
- blkid_loff_t start, end;
- int nparts, i, rc = 0;
-
- DBG(DEBUG_LOWPROBE, printf(
- "=> checking if off=%jd size=%jd covered by PT\n",
- offset, size));
-
- prc = blkid_clone_probe(pr);
- if (!prc)
- goto done;
-
- ls = blkid_probe_get_partitions(prc);
- if (!ls)
- goto done;
-
- nparts = blkid_partlist_numof_partitions(ls);
- if (!nparts)
- goto done;
-
- end = (offset + size) >> 9;
- start = offset >> 9;
-
- /* check if the partition table fits into the device */
- for (i = 0; i < nparts; i++) {
- blkid_partition par = &ls->parts[i];
-
- if (par->start + par->size > (pr->size >> 9)) {
- DBG(DEBUG_LOWPROBE, printf("partition #%d overflows "
- "device (off=%" PRId64 " size=%" PRId64 ")\n",
- par->partno, par->start, par->size));
- goto done;
- }
- }
-
- /* check if the requested area is covered by PT */
- for (i = 0; i < nparts; i++) {
- blkid_partition par = &ls->parts[i];
-
- if (start >= par->start && end <= par->start + par->size) {
- rc = 1;
- break;
- }
- }
-done:
- blkid_free_probe(prc);
-
- DBG(DEBUG_LOWPROBE, printf("<= %s covered by PT\n", rc ? "IS" : "NOT"));
- return rc;
-}
-
-/**
- * blkid_known_pttype:
- * @pttype: partiton name
- *
- * Returns: 1 for known or 0 for unknown partition type.
- */
-int blkid_known_pttype(const char *pttype)
-{
- int i;
-
- if (!pttype)
- return 0;
-
- for (i = 0; i < ARRAY_SIZE(idinfos); i++) {
- const struct blkid_idinfo *id = idinfos[i];
- if (strcmp(id->name, pttype) == 0)
- return 1;
- }
- return 0;
-}
-
-/**
- * blkid_partlist_numof_partitions:
- * @ls: partitions list
- *
- * Returns: number of partitions in the list or -1 in case of error.
- */
-int blkid_partlist_numof_partitions(blkid_partlist ls)
-{
- return ls ? ls->nparts : -1;
-}
-
-/**
- * blkid_partlist_get_table:
- *
- * Returns top-level partition table or NULL of there is not a partition table
- * on the device.
- */
-blkid_parttable blkid_partlist_get_table(blkid_partlist ls)
-{
- if (!ls || list_empty(&ls->l_tabs))
- return NULL;
-
- return list_entry(ls->l_tabs.next,
- struct blkid_struct_parttable, t_tabs);
-}
-
-
-/**
- * blkid_partlist_get_partition:
- * @ls: partitions list
- * @n: partition number in range 0..N, where 'N' is blkid_partlist_numof_partitions().
- *
- * It's possible that the list of partitions is *empty*, but there is a valid
- * partition table on the disk. This happen when on-disk details about
- * partitions are unknown or the partition table is empty.
- *
- * See also blkid_partlist_get_table().
- *
- * Returns: partition object or NULL in case or error.
- */
-blkid_partition blkid_partlist_get_partition(blkid_partlist ls, int n)
-{
- if (!ls || n < 0 || n >= ls->nparts)
- return NULL;
-
- return &ls->parts[n];
-}
-
-/**
- * blkid_partlist_devno_to_partition:
- * @ls: partitions list
- * @devno: requested partition
- *
- * This function tries to get start and size for @devno from sysfs and
- * returns a partition from @ls which matches with the values from sysfs.
- *
- * This funtion is necessary when you want to make a relation between an entry
- * in the partition table (@ls) and block devices in your system.
- *
- * Returns: partition object or NULL in case or error.
- */
-blkid_partition blkid_partlist_devno_to_partition(blkid_partlist ls, dev_t devno)
-{
- struct sysfs_cxt sysfs;
- uint64_t start, size;
- int i, rc, partno = 0;
-
- DBG(DEBUG_LOWPROBE,
- printf("triyng to convert devno 0x%llx to partition\n",
- (long long) devno));
-
- if (sysfs_init(&sysfs, devno, NULL)) {
- DBG(DEBUG_LOWPROBE, printf("failed t init sysfs context\n"));
- return NULL;
- }
- rc = sysfs_read_u64(&sysfs, "size", &size);
- if (!rc) {
- rc = sysfs_read_u64(&sysfs, "start", &start);
- if (rc) {
- /* try to get partition number from DM uuid.
- */
- char *uuid = sysfs_strdup(&sysfs, "dm/uuid");
- char *tmp = uuid;
- char *prefix = uuid ? strsep(&tmp, "-") : NULL;
-
- if (prefix && strncasecmp(prefix, "part", 4) == 0) {
- char *end = NULL;
-
- partno = strtol(prefix + 4, &end, 10);
- if (prefix == end || (end && *end))
- partno = 0;
- else
- rc = 0; /* success */
- }
- free(uuid);
- }
- }
-
- sysfs_deinit(&sysfs);
-
- if (rc)
- return NULL;
-
- if (partno) {
- DBG(DEBUG_LOWPROBE, printf("mapped by DM, using partno %d\n", partno));
-
- /*
- * Partition mapped by kpartx does not provide "start" offset
- * in /sys, but if we know partno and size of the partition
- * that we can probably make the releation bettween the device
- * and an entry in partition table.
- */
- for (i = 0; i < ls->nparts; i++) {
- blkid_partition par = &ls->parts[i];
-
- if (partno != blkid_partition_get_partno(par))
- continue;
-
- if (size == blkid_partition_get_size(par) ||
- (blkid_partition_is_extended(par) && size <= 1024))
- return par;
-
- }
- return NULL;
- }
-
- DBG(DEBUG_LOWPROBE, printf("searching by offset/size\n"));
-
- for (i = 0; i < ls->nparts; i++) {
- blkid_partition par = &ls->parts[i];
-
- if (blkid_partition_get_start(par) == start &&
- blkid_partition_get_size(par) == size)
- return par;
-
- /* exception for extended dos partitions */
- if (blkid_partition_get_start(par) == start &&
- blkid_partition_is_extended(par) && size <= 1024)
- return par;
-
- }
-
- DBG(DEBUG_LOWPROBE, printf("not found partition for device\n"));
- return NULL;
-}
-
-int blkid_partition_set_type(blkid_partition par, int type)
-{
- if (!par)
- return -1;
- par->type = type;
- return 0;
-}
-
-/**
- * blkid_parttable_get_type:
- * @tab: partition table
- *
- * Returns: partition table type (type name, e.g. "dos", "gpt", ...)
- */
-const char *blkid_parttable_get_type(blkid_parttable tab)
-{
- return tab ? tab->type : NULL;
-}
-
-/**
- * blkid_parttable_get_parent:
- * @tab: partition table
- *
- * Returns: parent for nexted partitition tables or NULL.
- */
-blkid_partition blkid_parttable_get_parent(blkid_parttable tab)
-{
- return tab ? tab->parent : NULL;
-}
-
-/**
- * blkid_parttable_get_offset:
- * @tab: partition table
- *
- * Returns: position (in bytes) of the partition table or -1 in case of error.
- *
- * Note the position is relative to begin of the device as defined by
- * blkid_probe_set_device() for primary partition table, and relative
- * to parental partition for nested patition tables.
- *
- * <informalexample>
- * <programlisting>
- * off_t offset;
- * blkid_partition parent = blkid_parttable_get_parent(tab);
- *
- * offset = blkid_parttable_get_offset(tab);
- *
- * if (parent)
- * / * 'tab' is nested partition table * /
- * offset += blkid_partition_get_start(parent);
- * </programlisting>
- * </informalexample>
- */
-blkid_loff_t blkid_parttable_get_offset(blkid_parttable tab)
-{
- return tab ? tab->offset : -1;
-}
-
-/**
- * blkid_partition_get_table:
- * @par: partition
- *
- * The "parttable" describes partition table. The table is usually the same for
- * all partitions -- except nested partition tables.
- *
- * For example bsd, solaris, etc. use a nested partition table within
- * standard primary dos partition:
- *
- * <informalexample>
- * <programlisting>
- *
- * -- dos partition table
- * 0: sda1 dos primary partition
- * 1: sda2 dos primary partition
- * -- bsd partition table (with in sda2)
- * 2: sda5 bds partition
- * 3: sda6 bds partition
- *
- * </programlisting>
- * </informalexample>
- *
- * The library does not to use a separate partition table object for dos logical
- * partitions (partitions within extended partition). It's possible to
- * differentiate between logical, extended and primary partitions by
- *
- * blkid_partition_is_{extended,primary,logical}().
- *
- * Returns: partition table object or NULL in case of error.
- */
-blkid_parttable blkid_partition_get_table(blkid_partition par)
-{
- return par ? par->tab : NULL;
-}
-
-static int partition_get_logical_type(blkid_partition par)
-{
- blkid_parttable tab;
-
- if (!par)
- return -1;
-
- tab = blkid_partition_get_table(par);
- if (!tab || !tab->type)
- return -1;
-
- if (tab->parent)
- return 'L'; /* report nested partitions as logical */
-
- if (!strcmp(tab->type, "dos")) {
- if (par->partno > 4)
- return 'L'; /* logical */
-
- if(par->type == BLKID_DOS_EXTENDED_PARTITION ||
- par->type == BLKID_W95_EXTENDED_PARTITION ||
- par->type == BLKID_LINUX_EXTENDED_PARTITION)
- return 'E';
- }
- return 'P';
-}
-
-/**
- * blkid_partition_is_primary:
- * @par: partition
- *
- * Note, this function returns FALSE for DOS extended partitions and
- * all partitions in nested partition tables.
- *
- * Returns: 1 if the partitions is primary partition or 0 if not.
- */
-int blkid_partition_is_primary(blkid_partition par)
-{
- return partition_get_logical_type(par) == 'P' ? TRUE : FALSE;
-}
-
-/**
- * blkid_partition_is_extended:
- * @par: partition
- *
- * Returns: 1 if the partitions is extended (dos, windows or linux)
- * partition or 0 if not.
- */
-int blkid_partition_is_extended(blkid_partition par)
-{
- return partition_get_logical_type(par) == 'E' ? TRUE : FALSE;
-}
-
-/**
- * blkid_partition_is_logical:
- * @par: partition
- *
- * Note that this function returns TRUE for all partitions in all
- * nested partition tables (e.g. BSD labels).
- *
- * Returns: 1 if the partitions is logical partition or 0 if not.
- */
-int blkid_partition_is_logical(blkid_partition par)
-{
- return partition_get_logical_type(par) == 'L' ? TRUE : FALSE;
-}
-
-static void set_string(unsigned char *item, size_t max,
- const unsigned char *data, size_t len)
-{
- if (len >= max)
- len = max - 1;
-
- memcpy(item, data, len);
- item[len] = '\0';
-
- blkid_rtrim_whitespace(item);
-}
-
-int blkid_partition_set_name(blkid_partition par,
- const unsigned char *name, size_t len)
-{
- if (!par)
- return -1;
-
- set_string(par->name, sizeof(par->name), name, len);
- return 0;
-}
-
-int blkid_partition_set_utf8name(blkid_partition par, const unsigned char *name,
- size_t len, int enc)
-{
- if (!par)
- return -1;
-
- blkid_encode_to_utf8(enc, par->name, sizeof(par->name), name, len);
- blkid_rtrim_whitespace(par->name);
- return 0;
-}
-
-int blkid_partition_set_uuid(blkid_partition par, const unsigned char *uuid)
-{
- if (!par)
- return -1;
-
- blkid_unparse_uuid(uuid, par->uuid, sizeof(par->uuid));
- return 0;
-}
-
-/**
- * blkid_partition_get_name:
- * @par: partition
- *
- * Returns: partition name string if supported by PT (e.g. Mac) or NULL.
- */
-const char *blkid_partition_get_name(blkid_partition par)
-{
- return par && *par->name ? (char *) par->name : NULL;
-}
-
-/**
- * blkid_partition_get_uuid:
- * @par: partition
- *
- * Returns: partition UUID string if supported by PT (e.g. GPT) or NULL.
- */
-const char *blkid_partition_get_uuid(blkid_partition par)
-{
- return par && *par->uuid ? par->uuid : NULL;
-}
-
-/**
- * blkid_partition_get_partno:
- * @par: partition
- *
- * Returns: proposed partitin number (e.g. 'N' from sda'N') or -1 in case of
- * error. Note that the number is generate by library independenly on your OS.
- */
-int blkid_partition_get_partno(blkid_partition par)
-{
- return par ? par->partno : -1;
-}
-
-/**
- * blkid_partition_get_start:
- * @par: partition
- *
- * Be careful if you _not_ probe whole disk:
- *
- * 1) the offset is usully relative to begin of the disk -- but if you probe a
- * fragment of the disk only -- then the offset could be still relative to
- * the begin of the disk rather that relative to the fragment.
- *
- * 2) the offset for nested partitions could be releative to parent (e.g. Solaris)
- * _or_ relative to the begin of the whole disk (e.g. bsd).
- *
- * You don't have to care about such details if you proble whole disk. In such
- * a case libblkid always returns the offset relative to the begin of the disk.
- *
- * Returns: start of the partition (in 512-sectors).
- */
-blkid_loff_t blkid_partition_get_start(blkid_partition par)
-{
- return par ? par->start : -1;
-}
-
-/**
- * blkid_partition_get_size:
- * @par: partition
- *
- * WARNING: be very careful when you work with MS-DOS extended partitions. The
- * library always returns full size of the partition. If you want add
- * the partition to the Linux system (BLKPG_ADD_PARTITION ioctl) you
- * need to reduce the size of the partition to 1 or 2 blocks. The
- * rest of the partition has to be unaccessible for mkfs or mkswap
- * programs, we need a small space for boot loaders only.
- *
- * For some unknown reason this (safe) practice is not to used for
- * nested BSD, Solaris, ..., partition tables in Linux kernel.
- *
- * Returns: size of the partition (in 512-sectors).
- */
-blkid_loff_t blkid_partition_get_size(blkid_partition par)
-{
- return par ? par->size : -1;
-}
-
-/**
- * blkid_partition_get_type:
- * @par: partition
- *
- * Returns: partition type.
- */
-int blkid_partition_get_type(blkid_partition par)
-{
- return par ? par->type : 0;
-}
-
-/* Sets partition 'type' for PT where the type is defined by string rather
- * than by number
- */
-int blkid_partition_set_type_string(blkid_partition par,
- const unsigned char *type, size_t len)
-{
- if (!par)
- return -1;
-
- set_string((unsigned char *) par->typestr,
- sizeof(par->typestr), type, len);
- return 0;
-}
-
-/* Sets partition 'type' for PT where the type is defined by UUIDrather
- * than by number
- */
-int blkid_partition_set_type_uuid(blkid_partition par, const unsigned char *uuid)
-{
- if (!par)
- return -1;
-
- blkid_unparse_uuid(uuid, par->typestr, sizeof(par->typestr));
- return 0;
-}
-
-/**
- * blkid_partition_get_type_string:
- * @par: partition
- *
- * The type string is supported by a small subset of partition tables (e.g Mac
- * and EFI GPT). Note that GPT uses type UUID and this function returns this
- * UUID as string.
- *
- * Returns: partition type string or NULL.
- */
-const char *blkid_partition_get_type_string(blkid_partition par)
-{
- return par && *par->typestr ? par->typestr : NULL;
-}
-
-
-int blkid_partition_set_flags(blkid_partition par, unsigned long long flags)
-{
- if (!par)
- return -1;
- par->flags = flags;
- return 0;
-}
-
-/**
- * blkid_partition_get_flags
- * @par: partition
- *
- * Returns: partition flags (or attributes for gpt).
- */
-unsigned long long blkid_partition_get_flags(blkid_partition par)
-{
- return par ? par->flags : 0;
-}
-
diff --git a/shlibs/blkid/src/partitions/partitions.h b/shlibs/blkid/src/partitions/partitions.h
deleted file mode 100644
index c4ccd3b65..000000000
--- a/shlibs/blkid/src/partitions/partitions.h
+++ /dev/null
@@ -1,62 +0,0 @@
-#ifndef BLKID_PARTITIONS_H
-#define BLKID_PARTITIONS_H
-
-#include "blkidP.h"
-#include "blkid_parttypes.h"
-
-extern int blkid_partitions_get_flags(blkid_probe pr);
-
-extern blkid_parttable blkid_partlist_new_parttable(blkid_partlist ls,
- const char *type, blkid_loff_t offset);
-
-extern blkid_partition blkid_partlist_add_partition(blkid_partlist ls,
- blkid_parttable tab,
- blkid_loff_t start, blkid_loff_t size);
-
-extern int blkid_partlist_set_partno(blkid_partlist ls, int partno);
-extern int blkid_partlist_increment_partno(blkid_partlist ls);
-
-extern blkid_partition blkid_partlist_get_parent(blkid_partlist ls);
-
-extern int blkid_partitions_do_subprobe(blkid_probe pr,
- blkid_partition parent, const struct blkid_idinfo *id);
-
-extern int blkid_partitions_need_typeonly(blkid_probe pr);
-extern int blkid_is_nested_dimension(blkid_partition par,
- blkid_loff_t start, blkid_loff_t size);
-
-extern int blkid_partition_set_name(blkid_partition par,
- const unsigned char *name, size_t len);
-
-extern int blkid_partition_set_utf8name(blkid_partition par,
- const unsigned char *name, size_t len, int enc);
-
-extern int blkid_partition_set_uuid(blkid_partition par,
- const unsigned char *uuid);
-
-extern int blkid_partition_set_type(blkid_partition par, int type);
-
-extern int blkid_partition_set_type_string(blkid_partition par,
- const unsigned char *type, size_t len);
-
-extern int blkid_partition_set_type_uuid(blkid_partition par,
- const unsigned char *uuid);
-
-extern int blkid_partition_set_flags(blkid_partition par, unsigned long long flags);
-
-/*
- * partition probers
- */
-extern const struct blkid_idinfo aix_pt_idinfo;
-extern const struct blkid_idinfo bsd_pt_idinfo;
-extern const struct blkid_idinfo unixware_pt_idinfo;
-extern const struct blkid_idinfo solaris_x86_pt_idinfo;
-extern const struct blkid_idinfo sun_pt_idinfo;
-extern const struct blkid_idinfo sgi_pt_idinfo;
-extern const struct blkid_idinfo mac_pt_idinfo;
-extern const struct blkid_idinfo dos_pt_idinfo;
-extern const struct blkid_idinfo minix_pt_idinfo;
-extern const struct blkid_idinfo gpt_pt_idinfo;
-extern const struct blkid_idinfo ultrix_pt_idinfo;
-
-#endif /* BLKID_PARTITIONS_H */
diff --git a/shlibs/blkid/src/partitions/sgi.c b/shlibs/blkid/src/partitions/sgi.c
deleted file mode 100644
index 945ead542..000000000
--- a/shlibs/blkid/src/partitions/sgi.c
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * sgi partition parsing code
- *
- * Copyright (C) 2009 Karel Zak <kzak@redhat.com>
- *
- * This file may be redistributed under the terms of the
- * GNU Lesser General Public License.
- *
- */
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdint.h>
-
-#include "partitions.h"
-
-#define SGI_MAXPARTITIONS 16
-
-/* partition type */
-#define SGI_TYPE_VOLHDR 0x00
-#define SGI_TYPE_VOLULME 0x06 /* entire disk */
-
-struct sgi_device_parameter {
- unsigned char skew;
- unsigned char gap1;
- unsigned char gap2;
- unsigned char sparecyl;
-
- uint16_t pcylcount;
- uint16_t head_vol0;
- uint16_t ntrks; /* tracks in cyl 0 or vol 0 */
-
- unsigned char cmd_tag_queue_depth;
- unsigned char unused0;
-
- uint16_t unused1;
- uint16_t nsect; /* sectors/tracks in cyl 0 or vol 0 */
- uint16_t bytes;
- uint16_t ilfact;
- uint32_t flags; /* controller flags */
- uint32_t datarate;
- uint32_t retries_on_error;
- uint32_t ms_per_word;
- uint16_t xylogics_gap1;
- uint16_t xylogics_syncdelay;
- uint16_t xylogics_readdelay;
- uint16_t xylogics_gap2;
- uint16_t xylogics_readgate;
- uint16_t xylogics_writecont;
-} __attribute__((packed));
-
-struct sgi_disklabel {
- uint32_t magic; /* magic number */
- uint16_t root_part_num; /* # root partition */
- uint16_t swap_part_num; /* # swap partition */
- unsigned char boot_file[16]; /* name of boot file */
-
- struct sgi_device_parameter devparam; /* not used now */
-
- struct sgi_volume {
- unsigned char name[8]; /* name of volume */
- uint32_t block_num; /* logical block number */
- uint32_t num_bytes; /* how big, in bytes */
- } __attribute__((packed)) volume[15];
-
- struct sgi_partition {
- uint32_t num_blocks; /* size in logical blocks */
- uint32_t first_block; /* first logical block */
- uint32_t type; /* type of this partition */
- } __attribute__((packed)) partitions[SGI_MAXPARTITIONS];
-
- /* checksum is the 32bit 2's complement sum of the disklabel */
- uint32_t csum; /* disk label checksum */
- uint32_t padding; /* padding */
-} __attribute__((packed));
-
-static uint32_t count_checksum(struct sgi_disklabel *label)
-{
- int i;
- uint32_t *ptr = (uint32_t *) label;
- uint32_t sum = 0;
-
- i = sizeof(*label) / sizeof(*ptr);
-
- while (i--)
- sum += be32_to_cpu(ptr[i]);
-
- return sum;
-}
-
-
-static int probe_sgi_pt(blkid_probe pr, const struct blkid_idmag *mag)
-{
- struct sgi_disklabel *l;
- struct sgi_partition *p;
- blkid_parttable tab = NULL;
- blkid_partlist ls;
- int i;
-
- l = (struct sgi_disklabel *) blkid_probe_get_sector(pr, 0);
- if (!l)
- goto nothing;
-
- if (count_checksum(l)) {
- DBG(DEBUG_LOWPROBE, printf(
- "detected corrupted sgi disk label -- ignore\n"));
- goto nothing;
- }
-
- if (blkid_partitions_need_typeonly(pr))
- /* caller does not ask for details about partitions */
- return 0;
-
- ls = blkid_probe_get_partlist(pr);
- if (!ls)
- goto err;
-
- tab = blkid_partlist_new_parttable(ls, "sgi", 0);
- if (!tab)
- goto err;
-
- for(i = 0, p = &l->partitions[0]; i < SGI_MAXPARTITIONS; i++, p++) {
- uint32_t size = be32_to_cpu(p->num_blocks);
- uint32_t start = be32_to_cpu(p->first_block);
- uint32_t type = be32_to_cpu(p->type);
- blkid_partition par;
-
- if (size == 0 || type == SGI_TYPE_VOLULME ||
- type == SGI_TYPE_VOLHDR) {
- blkid_partlist_increment_partno(ls);
- continue;
- }
- par = blkid_partlist_add_partition(ls, tab, start, size);
- if (!par)
- goto err;
-
- blkid_partition_set_type(par, type);
- }
-
- return 0;
-
-nothing:
- return 1;
-err:
- return -1;
-}
-
-const struct blkid_idinfo sgi_pt_idinfo =
-{
- .name = "sgi",
- .probefunc = probe_sgi_pt,
- .magics =
- {
- { .magic = "\x0B\xE5\xA9\x41", .len = 4 },
- { NULL }
- }
-};
-
diff --git a/shlibs/blkid/src/partitions/solaris_x86.c b/shlibs/blkid/src/partitions/solaris_x86.c
deleted file mode 100644
index ce102bd8f..000000000
--- a/shlibs/blkid/src/partitions/solaris_x86.c
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Solaris x86 partition parsing code
- *
- * Copyright (C) 2009 Karel Zak <kzak@redhat.com>
- *
- * This file may be redistributed under the terms of the
- * GNU Lesser General Public License.
- */
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdint.h>
-
-#include "partitions.h"
-
-/*
- * Solaris-x86 is always within primary dos partition (nested PT table). The
- * solaris-x86 vtoc allows to split the entire partition to "slices". The
- * offset (start) of the slice is always relatively to the primary dos
- * partition.
- *
- * Note that Solaris-SPARC uses entire disk with a different partitionning
- * scheme.
- */
-
-/* some other implementation than Linux kernel assume 8 partitions only */
-#define SOLARIS_MAXPARTITIONS 16
-
-/* disklabel (vtoc) location */
-#define SOLARIS_SECTOR 1 /* in 512-sectors */
-#define SOLARIS_OFFSET (SOLARIS_SECTOR << 9) /* in bytes */
-#define SOLARIS_MAGICOFFSET (SOLARIS_OFFSET + 12) /* v_sanity offset in bytes */
-
-/* slice tags */
-#define SOLARIS_TAG_WHOLEDISK 5
-
-struct solaris_slice {
- uint16_t s_tag; /* ID tag of partition */
- uint16_t s_flag; /* permission flags */
- uint32_t s_start; /* start sector no of partition */
- uint32_t s_size; /* # of blocks in partition */
-} __attribute__((packed));
-
-struct solaris_vtoc {
- unsigned int v_bootinfo[3]; /* info needed by mboot (unsupported) */
-
- uint32_t v_sanity; /* to verify vtoc sanity */
- uint32_t v_version; /* layout version */
- char v_volume[8]; /* volume name */
- uint16_t v_sectorsz; /* sector size in bytes */
- uint16_t v_nparts; /* number of partitions */
- unsigned int v_reserved[10]; /* free space */
-
- struct solaris_slice v_slice[SOLARIS_MAXPARTITIONS]; /* slices */
-
- unsigned int timestamp[SOLARIS_MAXPARTITIONS]; /* timestamp (unsupported) */
- char v_asciilabel[128]; /* for compatibility */
-} __attribute__((packed));
-
-static int probe_solaris_pt(blkid_probe pr, const struct blkid_idmag *mag)
-{
- struct solaris_vtoc *l; /* disk label */
- struct solaris_slice *p; /* partitsion */
- blkid_parttable tab = NULL;
- blkid_partition parent;
- blkid_partlist ls;
- int i;
- uint16_t nparts;
-
- l = (struct solaris_vtoc *) blkid_probe_get_sector(pr, SOLARIS_SECTOR);
- if (!l)
- goto nothing;
-
- if (le32_to_cpu(l->v_version) != 1) {
- DBG(DEBUG_LOWPROBE, printf(
- "WARNING: unsupported solaris x86 version %d, ignore\n",
- le32_to_cpu(l->v_version)));
- goto nothing;
- }
-
- if (blkid_partitions_need_typeonly(pr))
- /* caller does not ask for details about partitions */
- return 0;
-
- ls = blkid_probe_get_partlist(pr);
- if (!ls)
- goto err;
-
- parent = blkid_partlist_get_parent(ls);
-
- tab = blkid_partlist_new_parttable(ls, "solaris", SOLARIS_OFFSET);
- if (!tab)
- goto err;
-
- nparts = le16_to_cpu(l->v_nparts);
- if (nparts > SOLARIS_MAXPARTITIONS)
- nparts = SOLARIS_MAXPARTITIONS;
-
- for (i = 1, p = &l->v_slice[0]; i < nparts; i++, p++) {
-
- uint32_t start = le32_to_cpu(p->s_start);
- uint32_t size = le32_to_cpu(p->s_size);
- blkid_partition par;
-
- if (size == 0 || le16_to_cpu(p->s_tag) == SOLARIS_TAG_WHOLEDISK)
- continue;
-
- if (parent)
- /* Solaris slices are relative to the parent (primary
- * DOS partition) */
- start += blkid_partition_get_start(parent);
-
- if (parent && !blkid_is_nested_dimension(parent, start, size)) {
- DBG(DEBUG_LOWPROBE, printf(
- "WARNING: solaris partition (%d) overflow "
- "detected, ignore\n", i));
- continue;
- }
-
- par = blkid_partlist_add_partition(ls, tab, start, size);
- if (!par)
- goto err;
-
- blkid_partition_set_type(par, le16_to_cpu(p->s_tag));
- blkid_partition_set_flags(par, le16_to_cpu(p->s_flag));
- }
-
- return 0;
-
-nothing:
- return 1;
-err:
- return -1;
-}
-
-const struct blkid_idinfo solaris_x86_pt_idinfo =
-{
- .name = "solaris",
- .probefunc = probe_solaris_pt,
- .magics =
- {
- {
- .magic = "\xEE\xDE\x0D\x60", /* little-endian magic string */
- .len = 4, /* v_sanity size in bytes */
- .sboff = SOLARIS_MAGICOFFSET /* offset of v_sanity */
- },
- { NULL }
- }
-};
-
diff --git a/shlibs/blkid/src/partitions/sun.c b/shlibs/blkid/src/partitions/sun.c
deleted file mode 100644
index dffab24c6..000000000
--- a/shlibs/blkid/src/partitions/sun.c
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * sun (solaris-sparc) partition parsing code
- *
- * Copyright (C) 2009 Karel Zak <kzak@redhat.com>
- *
- * This file may be redistributed under the terms of the
- * GNU Lesser General Public License.
- */
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <stddef.h>
-
-#include "partitions.h"
-
-/* Supported VTOC setting */
-#define SUN_VTOC_SANITY 0x600DDEEE /* magic number */
-#define SUN_VTOC_VERSION 1
-
-#define SUN_MAXPARTITIONS 8
-
-/* Partition IDs */
-#define SUN_TAG_WHOLEDISK 0x05
-
-struct sun_disklabel {
- unsigned char info[128]; /* Informative text string */
-
- struct sun_vtoc {
- uint32_t version; /* version */
- char volume[8]; /* volume name */
- uint16_t nparts; /* num of partitions */
-
- struct sun_info { /* partition information */
- uint16_t id; /* tag */
- uint16_t flags;
- } __attribute__ ((packed)) infos[8];
-
- uint16_t padding; /* padding */
- uint32_t bootinfo[3]; /* info needed by mboot */
- uint32_t sanity; /* magic number */
- uint32_t reserved[10]; /* padding */
- uint32_t timestamp[8]; /* partition timestamp */
- } __attribute__ ((packed)) vtoc;
-
- uint32_t write_reinstruct; /* sectors to skip, writes */
- uint32_t read_reinstruct; /* sectors to skip, reads */
- unsigned char spare[148]; /* padding */
- uint16_t rspeed; /* disk rotational speed */
- uint16_t pcylcount; /* physical cylinder count */
- uint16_t sparecyl; /* extra sects per cylinder */
- uint16_t obs1;
- uint16_t obs2;
- uint16_t ilfact; /* interleave factor */
- uint16_t ncyl; /* data cylinder count */
- uint16_t nacyl; /* alt. cylinder count */
- uint16_t ntrks; /* tracks per cylinder <---- */
- uint16_t nsect; /* sectors per track <---- */
- uint16_t obs3;
- uint16_t obs4;
-
- struct sun_partition { /* partitions */
- uint32_t start_cylinder;
- uint32_t num_sectors;
- } __attribute__ ((packed)) partitions[8];
-
- uint16_t magic; /* magic number */
- uint16_t csum; /* label xor'd checksum */
-} __attribute__ ((packed));
-
-
-uint16_t count_checksum(struct sun_disklabel *label)
-{
- uint16_t *ptr = ((uint16_t *) (label + 1)) - 1;
- uint16_t sum;
-
- for (sum = 0; ptr >= ((uint16_t *) label);)
- sum ^= *ptr--;
-
- return sum;
-}
-
-static int probe_sun_pt(blkid_probe pr, const struct blkid_idmag *mag)
-{
- struct sun_disklabel *l;
- struct sun_partition *p;
- blkid_parttable tab = NULL;
- blkid_partlist ls;
- uint16_t nparts;
- blkid_loff_t spc;
- int i, use_vtoc;
-
- l = (struct sun_disklabel *) blkid_probe_get_sector(pr, 0);
- if (!l)
- goto nothing;
-
- if (count_checksum(l)) {
- DBG(DEBUG_LOWPROBE, printf(
- "detected corrupted sun disk label -- ignore\n"));
- goto nothing;
- }
-
- if (blkid_partitions_need_typeonly(pr))
- /* caller does not ask for details about partitions */
- return 0;
-
- ls = blkid_probe_get_partlist(pr);
- if (!ls)
- goto err;
-
- tab = blkid_partlist_new_parttable(ls, "sun", 0);
- if (!tab)
- goto err;
-
- /* sectors per cylinder (partition offset is in cylinders...) */
- spc = be16_to_cpu(l->ntrks) * be16_to_cpu(l->nsect);
-
- DBG(DEBUG_LOWPROBE,
- printf("Sun VTOC sanity=%u version=%u nparts=%u\n",
- be32_to_cpu(l->vtoc.sanity),
- be32_to_cpu(l->vtoc.version),
- be16_to_cpu(l->vtoc.nparts)));
-
- /* Check to see if we can use the VTOC table */
- use_vtoc = ((be32_to_cpu(l->vtoc.sanity) == SUN_VTOC_SANITY) &&
- (be32_to_cpu(l->vtoc.version) == SUN_VTOC_VERSION) &&
- (be16_to_cpu(l->vtoc.nparts) <= SUN_MAXPARTITIONS));
-
- /* Use 8 partition entries if not specified in validated VTOC */
- nparts = use_vtoc ? be16_to_cpu(l->vtoc.nparts) : SUN_MAXPARTITIONS;
-
- /*
- * So that old Linux-Sun partitions continue to work,
- * alow the VTOC to be used under the additional condition ...
- */
- use_vtoc = use_vtoc || !(l->vtoc.sanity || l->vtoc.version || l->vtoc.nparts);
-
- for (i = 0, p = l->partitions; i < nparts; i++, p++) {
-
- blkid_loff_t start, size;
- uint16_t type = 0, flags = 0;
- blkid_partition par;
-
- start = be32_to_cpu(p->start_cylinder) * spc;
- size = be32_to_cpu(p->num_sectors);
- if (use_vtoc) {
- type = be16_to_cpu(l->vtoc.infos[i].id);
- flags = be16_to_cpu(l->vtoc.infos[i].flags);
- }
-
- if (type == SUN_TAG_WHOLEDISK || !size) {
- blkid_partlist_increment_partno(ls);
- continue;
- }
- par = blkid_partlist_add_partition(ls, tab, start, size);
- if (!par)
- goto err;
-
- if (type)
- blkid_partition_set_type(par, type);
- if (flags)
- blkid_partition_set_flags(par, flags);
- }
- return 0;
-
-nothing:
- return 1;
-err:
- return -1;
-}
-
-
-const struct blkid_idinfo sun_pt_idinfo =
-{
- .name = "sun",
- .probefunc = probe_sun_pt,
- .magics =
- {
- {
- .magic = "\xDA\xBE", /* big-endian magic string */
- .len = 2,
- .sboff = offsetof(struct sun_disklabel, magic)
- },
- { NULL }
- }
-};
-
diff --git a/shlibs/blkid/src/partitions/ultrix.c b/shlibs/blkid/src/partitions/ultrix.c
deleted file mode 100644
index cc848d0a6..000000000
--- a/shlibs/blkid/src/partitions/ultrix.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * uktrix partition parsing code
- *
- * Copyright (C) 2010 Karel Zak <kzak@redhat.com>
- *
- * This file may be redistributed under the terms of the
- * GNU Lesser General Public License.
- *
- */
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdint.h>
-
-#include "partitions.h"
-
-#define ULTRIX_MAXPARTITIONS 8
-#define ULTRIX_MAGIC 0x032957
-
-/* sector with partition table */
-#define ULTRIX_SECTOR ((16384 - sizeof(struct ultrix_disklabel)) >> 9)
-/* position of partition table within ULTRIX_SECTOR */
-#define ULTRIX_OFFSET (512 - sizeof(struct ultrix_disklabel))
-
-struct ultrix_disklabel {
- int32_t pt_magic; /* magic no. indicating part. info exits */
- int32_t pt_valid; /* set by driver if pt is current */
- struct pt_info {
- int32_t pi_nblocks; /* no. of sectors */
- uint32_t pi_blkoff; /* block offset for start */
- } pt_part[ULTRIX_MAXPARTITIONS];
-} __attribute__((packed));
-
-
-static int probe_ultrix_pt(blkid_probe pr, const struct blkid_idmag *mag)
-{
- unsigned char *data;
- struct ultrix_disklabel *l;
- blkid_parttable tab = NULL;
- blkid_partlist ls;
- int i;
-
- data = blkid_probe_get_sector(pr, ULTRIX_SECTOR);
- if (!data)
- goto nothing;
-
- l = (struct ultrix_disklabel *) (data + ULTRIX_OFFSET);
-
- if (l->pt_magic != ULTRIX_MAGIC || l->pt_valid != 1)
- goto nothing;
-
- if (blkid_partitions_need_typeonly(pr))
- /* caller does not ask for details about partitions */
- return 0;
-
- ls = blkid_probe_get_partlist(pr);
- if (!ls)
- goto err;
-
- tab = blkid_partlist_new_parttable(ls, "ultrix", 0);
- if (!tab)
- goto err;
-
- for (i = 0; i < ULTRIX_MAXPARTITIONS; i++) {
- if (!l->pt_part[i].pi_nblocks)
- blkid_partlist_increment_partno(ls);
- else {
- if (!blkid_partlist_add_partition(ls, tab,
- l->pt_part[i].pi_blkoff,
- l->pt_part[i].pi_nblocks))
- goto err;
- }
- }
-
- return 0;
-nothing:
- return 1;
-err:
- return -1;
-}
-
-const struct blkid_idinfo ultrix_pt_idinfo =
-{
- .name = "ultrix",
- .probefunc = probe_ultrix_pt,
- .magics = BLKID_NONE_MAGIC
-};
-
diff --git a/shlibs/blkid/src/partitions/unixware.c b/shlibs/blkid/src/partitions/unixware.c
deleted file mode 100644
index ac11a46d3..000000000
--- a/shlibs/blkid/src/partitions/unixware.c
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * unixware partition parsing code
- *
- * Copyright (C) 2009 Karel Zak <kzak@redhat.com>
- *
- * This file may be redistributed under the terms of the
- * GNU Lesser General Public License.
- *
- *
- * The intersting information about unixware PT:
- * - Linux kernel / partx
- * - vtoc(7) SCO UNIX command man page
- * - evms source code (http://evms.sourceforge.net/)
- * - vxtools source code (http://martin.hinner.info/fs/vxfs/)
- */
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdint.h>
-
-#include "partitions.h"
-
-/* disklabel location */
-#define UNIXWARE_SECTOR 29
-#define UNIXWARE_OFFSET (UNIXWARE_SECTOR << 9) /* offset in bytes */
-#define UNIXWARE_KBOFFSET (UNIXWARE_OFFSET >> 10) /* offset in 1024-blocks */
-
-/* disklabel->d_magic offset within the last 1024 block */
-#define UNIXWARE_MAGICOFFSET (UNIXWARE_OFFSET - UNIXWARE_KBOFFSET + 4)
-
-#define UNIXWARE_VTOCMAGIC 0x600DDEEEUL
-#define UNIXWARE_MAXPARTITIONS 16
-
-/* unixware_partition->s_label flags */
-#define UNIXWARE_TAG_UNUSED 0x0000 /* unused partition */
-#define UNIXWARE_TAG_BOOT 0x0001 /* boot fs */
-#define UNIXWARE_TAG_ROOT 0x0002 /* root fs */
-#define UNIXWARE_TAG_SWAP 0x0003 /* swap fs */
-#define UNIXWARE_TAG_USER 0x0004 /* user fs */
-#define UNIXWARE_TAG_ENTIRE_DISK 0x0005 /* whole disk */
-#define UNIXWARE_TAG_ALT_S 0x0006 /* alternate sector space */
-#define UNIXWARE_TAG_OTHER 0x0007 /* non unix */
-#define UNIXWARE_TAG_ALT_T 0x0008 /* alternate track space */
-#define UNIXWARE_TAG_STAND 0x0009 /* stand partition */
-#define UNIXWARE_TAG_VAR 0x000a /* var partition */
-#define UNIXWARE_TAG_HOME 0x000b /* home partition */
-#define UNIXWARE_TAG_DUMP 0x000c /* dump partition */
-#define UNIXWARE_TAG_ALT_ST 0x000d /* alternate sector track */
-#define UNIXWARE_TAG_VM_PUBLIC 0x000e /* volume mgt public partition */
-#define UNIXWARE_TAG_VM_PRIVATE 0x000f /* volume mgt private partition */
-
-
-/* unixware_partition->s_flags flags */
-#define UNIXWARE_FLAG_VALID 0x0200
-
-struct unixware_partition {
- uint16_t s_label; /* partition label (tag) */
- uint16_t s_flags; /* permission flags */
- uint32_t start_sect; /* starting sector */
- uint32_t nr_sects; /* number of sectors */
-} __attribute__((packed));
-
-struct unixware_disklabel {
- uint32_t d_type; /* drive type */
- uint32_t d_magic; /* the magic number */
- uint32_t d_version; /* version number */
- char d_serial[12]; /* serial number of the device */
- uint32_t d_ncylinders; /* # of data cylinders per device */
- uint32_t d_ntracks; /* # of tracks per cylinder */
- uint32_t d_nsectors; /* # of data sectors per track */
- uint32_t d_secsize; /* # of bytes per sector */
- uint32_t d_part_start; /* # of first sector of this partition */
- uint32_t d_unknown1[12]; /* ? */
- uint32_t d_alt_tbl; /* byte offset of alternate table */
- uint32_t d_alt_len; /* byte length of alternate table */
- uint32_t d_phys_cyl; /* # of physical cylinders per device */
- uint32_t d_phys_trk; /* # of physical tracks per cylinder */
- uint32_t d_phys_sec; /* # of physical sectors per track */
- uint32_t d_phys_bytes; /* # of physical bytes per sector */
- uint32_t d_unknown2; /* ? */
- uint32_t d_unknown3; /* ? */
- uint32_t d_pad[8]; /* pad */
-
- struct unixware_vtoc {
- uint32_t v_magic; /* the magic number */
- uint32_t v_version; /* version number */
- char v_name[8]; /* volume name */
- uint16_t v_nslices; /* # of partitions */
- uint16_t v_unknown1; /* ? */
- uint32_t v_reserved[10]; /* reserved */
-
- struct unixware_partition
- v_slice[UNIXWARE_MAXPARTITIONS]; /* partition */
- } __attribute__((packed)) vtoc;
-};
-
-static int probe_unixware_pt(blkid_probe pr, const struct blkid_idmag *mag)
-{
- struct unixware_disklabel *l;
- struct unixware_partition *p;
- blkid_parttable tab = NULL;
- blkid_partition parent;
- blkid_partlist ls;
- int i;
-
- l = (struct unixware_disklabel *)
- blkid_probe_get_sector(pr, UNIXWARE_SECTOR);
- if (!l)
- goto nothing;
-
- if (le32_to_cpu(l->vtoc.v_magic) != UNIXWARE_VTOCMAGIC)
- goto nothing;
-
- if (blkid_partitions_need_typeonly(pr))
- /* caller does not ask for details about partitions */
- return 0;
-
- ls = blkid_probe_get_partlist(pr);
- if (!ls)
- goto err;
-
- parent = blkid_partlist_get_parent(ls);
-
- tab = blkid_partlist_new_parttable(ls, "unixware", UNIXWARE_OFFSET);
- if (!tab)
- goto err;
-
- /* Skip the first partition that describe whole disk
- */
- for (i = 1, p = &l->vtoc.v_slice[1];
- i < UNIXWARE_MAXPARTITIONS; i++, p++) {
-
- uint32_t start, size;
- uint16_t tag, flg;
- blkid_partition par;
-
- tag = le16_to_cpu(p->s_label);
- flg = le16_to_cpu(p->s_flags);
-
- if (tag == UNIXWARE_TAG_UNUSED ||
- tag == UNIXWARE_TAG_ENTIRE_DISK ||
- flg != UNIXWARE_FLAG_VALID)
- continue;
-
- start = le32_to_cpu(p->start_sect);
- size = le32_to_cpu(p->nr_sects);
-
- if (parent && !blkid_is_nested_dimension(parent, start, size)) {
- DBG(DEBUG_LOWPROBE, printf(
- "WARNING: unixware partition (%d) overflow "
- "detected, ignore\n", i));
- continue;
- }
-
- par = blkid_partlist_add_partition(ls, tab, start, size);
- if (!par)
- goto err;
-
- blkid_partition_set_type(par, tag);
- blkid_partition_set_flags(par, flg);
- }
-
- return 0;
-
-nothing:
- return 1;
-err:
- return -1;
-}
-
-
-/*
- * The unixware partition table is within primary DOS partition. The PT is
- * located on 29 sector, PT magic string is d_magic member of 'struct
- * unixware_disklabel'.
- */
-const struct blkid_idinfo unixware_pt_idinfo =
-{
- .name = "unixware",
- .probefunc = probe_unixware_pt,
- .minsz = 1024 * 1440 + 1, /* ignore floppies */
- .magics =
- {
- {
- .magic = "\x0D\x60\xE5\xCA", /* little-endian magic string */
- .len = 4, /* d_magic size in bytes */
- .kboff = UNIXWARE_KBOFFSET,
- .sboff = UNIXWARE_MAGICOFFSET
- },
- { NULL }
- }
-};
-