Evolve the ctlreq interface added to geom_gpt into a generic
partitioning class that supports multiple schemes. Current schemes supported are APM (Apple Partition Map) and GPT. Change all GEOM_APPLE anf GEOM_GPT options into GEOM_PART_APM and GEOM_PART_GPT (resp). The ctlreq interface supports verbs to create and destroy partitioning schemes on a disk; to add, delete and modify partitions; and to commit or undo changes made.
This commit is contained in:
parent
e8865caffb
commit
1d3aed33e8
@ -43,7 +43,7 @@ options MSDOSFS # MSDOS Filesystem
|
||||
options CD9660 # ISO 9660 Filesystem
|
||||
options PROCFS # Process filesystem (requires PSEUDOFS)
|
||||
options PSEUDOFS # Pseudo-filesystem framework
|
||||
options GEOM_GPT # GUID Partition Tables.
|
||||
options GEOM_PART_GPT # GUID Partition Tables.
|
||||
options COMPAT_43TTY # BSD 4.3 TTY compat [KEEP THIS!]
|
||||
options COMPAT_IA32 # Compatible with i386 binaries
|
||||
options COMPAT_FREEBSD4 # Compatible with FreeBSD4
|
||||
|
@ -56,7 +56,7 @@ options SYSVMSG #SYSV-style message queues
|
||||
options SYSVSEM #SYSV-style semaphores
|
||||
options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
|
||||
options KBD_INSTALL_CDEV # install a CDEV entry in /dev
|
||||
options GEOM_GPT # GUID Partition Tables.
|
||||
options GEOM_PART_GPT # GUID Partition Tables.
|
||||
options GEOM_MBR # DOS/MBR partitioning
|
||||
options GEOM_LABEL # Providers labelization.
|
||||
|
||||
|
@ -136,7 +136,6 @@ options MAXPHYS=(128*1024)
|
||||
options INCLUDE_CONFIG_FILE # Include this file in kernel
|
||||
|
||||
options GEOM_AES # Don't use, use GEOM_BDE
|
||||
options GEOM_APPLE # Apple partitioning
|
||||
options GEOM_BDE # Disk encryption.
|
||||
options GEOM_BSD # BSD disklabels
|
||||
options GEOM_CACHE # Disk cache.
|
||||
@ -144,12 +143,13 @@ options GEOM_CONCAT # Disk concatenation.
|
||||
options GEOM_ELI # Disk encryption.
|
||||
options GEOM_FOX # Redundant path mitigation
|
||||
options GEOM_GATE # Userland services.
|
||||
options GEOM_GPT # GPT partitioning
|
||||
options GEOM_JOURNAL # Journaling.
|
||||
options GEOM_LABEL # Providers labelization.
|
||||
options GEOM_MBR # DOS/MBR partitioning
|
||||
options GEOM_MIRROR # Disk mirroring.
|
||||
options GEOM_NOP # Test class.
|
||||
options GEOM_PART_APM # Apple partitioning
|
||||
options GEOM_PART_GPT # GPT partitioning
|
||||
options GEOM_PC98 # NEC PC9800 partitioning
|
||||
options GEOM_RAID3 # RAID3 functionality.
|
||||
options GEOM_SHSEC # Shared secret.
|
||||
|
@ -1178,7 +1178,6 @@ geom/eli/g_eli_privacy.c optional geom_eli
|
||||
geom/eli/pkcs5v2.c optional geom_eli
|
||||
geom/gate/g_gate.c optional geom_gate
|
||||
geom/geom_aes.c optional geom_aes
|
||||
geom/geom_apple.c optional geom_apple
|
||||
geom/geom_bsd.c optional geom_bsd
|
||||
geom/geom_bsd_enc.c optional geom_bsd
|
||||
geom/geom_ccd.c optional ccd | geom_ccd
|
||||
@ -1188,7 +1187,6 @@ geom/geom_disk.c standard
|
||||
geom/geom_dump.c standard
|
||||
geom/geom_event.c standard
|
||||
geom/geom_fox.c optional geom_fox
|
||||
geom/geom_gpt.c optional geom_gpt
|
||||
geom/geom_io.c standard
|
||||
geom/geom_kern.c standard
|
||||
geom/geom_mbr.c optional geom_mbr
|
||||
@ -1213,6 +1211,10 @@ geom/label/g_label_ufs.c optional geom_label
|
||||
geom/mirror/g_mirror.c optional geom_mirror
|
||||
geom/mirror/g_mirror_ctl.c optional geom_mirror
|
||||
geom/nop/g_nop.c optional geom_nop
|
||||
geom/part/g_part.c standard
|
||||
geom/part/g_part_if.m standard
|
||||
geom/part/g_part_apm.c optional geom_part_apm
|
||||
geom/part/g_part_gpt.c optional geom_part_gpt
|
||||
geom/raid3/g_raid3.c optional geom_raid3
|
||||
geom/raid3/g_raid3_ctl.c optional geom_raid3
|
||||
geom/shsec/g_shsec.c optional geom_shsec
|
||||
|
@ -32,7 +32,6 @@ dev/syscons/scgfbrndr.c optional sc
|
||||
dev/syscons/scterm-sc.c optional sc
|
||||
dev/syscons/scvtb.c optional sc
|
||||
dev/uart/uart_cpu_powerpc.c optional uart
|
||||
geom/geom_apple.c standard
|
||||
kern/syscalls.c optional ktr
|
||||
powerpc/powerpc/atomic.S standard
|
||||
powerpc/powerpc/autoconf.c standard
|
||||
|
@ -74,7 +74,6 @@ DIRECTIO
|
||||
FULL_PREEMPTION opt_sched.h
|
||||
IPI_PREEMPTION opt_sched.h
|
||||
GEOM_AES opt_geom.h
|
||||
GEOM_APPLE opt_geom.h
|
||||
GEOM_BDE opt_geom.h
|
||||
GEOM_BSD opt_geom.h
|
||||
GEOM_CACHE opt_geom.h
|
||||
@ -82,12 +81,13 @@ GEOM_CONCAT opt_geom.h
|
||||
GEOM_ELI opt_geom.h
|
||||
GEOM_FOX opt_geom.h
|
||||
GEOM_GATE opt_geom.h
|
||||
GEOM_GPT opt_geom.h
|
||||
GEOM_JOURNAL opt_geom.h
|
||||
GEOM_LABEL opt_geom.h
|
||||
GEOM_MBR opt_geom.h
|
||||
GEOM_MIRROR opt_geom.h
|
||||
GEOM_NOP opt_geom.h
|
||||
GEOM_PART_APM opt_geom.h
|
||||
GEOM_PART_GPT opt_geom.h
|
||||
GEOM_PC98 opt_geom.h
|
||||
GEOM_RAID3 opt_geom.h
|
||||
GEOM_SHSEC opt_geom.h
|
||||
|
@ -1,263 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 2002 Peter Grehan.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* GEOM module for Apple Partition Maps
|
||||
* As described in 'Inside Macintosh Vol 3: About the SCSI Manager -
|
||||
* The Structure of Block Devices"
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/endian.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/bio.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/mutex.h>
|
||||
|
||||
#include <sys/sbuf.h>
|
||||
#include <geom/geom.h>
|
||||
#include <geom/geom_slice.h>
|
||||
|
||||
#define APPLE_CLASS_NAME "APPLE"
|
||||
|
||||
#define NAPMPART 16 /* Max partitions */
|
||||
|
||||
struct apm_partition {
|
||||
char am_sig[2];
|
||||
u_int32_t am_mapcnt;
|
||||
u_int32_t am_start;
|
||||
u_int32_t am_partcnt;
|
||||
char am_name[32];
|
||||
char am_type[32];
|
||||
};
|
||||
|
||||
struct g_apple_softc {
|
||||
u_int16_t dd_bsiz;
|
||||
u_int32_t dd_blkcnt;
|
||||
u_int16_t dd_drvrcnt;
|
||||
u_int32_t am_mapcnt0;
|
||||
struct apm_partition apmpart[NAPMPART];
|
||||
};
|
||||
|
||||
static void
|
||||
g_dec_drvrdesc(u_char *ptr, struct g_apple_softc *sc)
|
||||
{
|
||||
sc->dd_bsiz = be16dec(ptr + 2);
|
||||
sc->dd_blkcnt = be32dec(ptr + 4);
|
||||
sc->dd_drvrcnt = be32dec(ptr + 16);
|
||||
}
|
||||
|
||||
static void
|
||||
g_dec_apple_partition(u_char *ptr, struct apm_partition *d)
|
||||
{
|
||||
d->am_sig[0] = ptr[0];
|
||||
d->am_sig[1] = ptr[1];
|
||||
d->am_mapcnt = be32dec(ptr + 4);
|
||||
d->am_start = be32dec(ptr + 8);
|
||||
d->am_partcnt = be32dec(ptr + 12);
|
||||
memcpy(d->am_name, ptr + 16, 32);
|
||||
memcpy(d->am_type, ptr + 48, 32);
|
||||
}
|
||||
|
||||
static int
|
||||
g_apple_start(struct bio *bp)
|
||||
{
|
||||
struct g_provider *pp;
|
||||
struct g_geom *gp;
|
||||
struct g_slicer *gsp;
|
||||
|
||||
pp = bp->bio_to;
|
||||
gp = pp->geom;
|
||||
gsp = gp->softc;
|
||||
if (bp->bio_cmd == BIO_GETATTR) {
|
||||
if (g_handleattr_off_t(bp, "APM::offset",
|
||||
gsp->slices[pp->index].offset))
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
g_apple_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
|
||||
struct g_consumer *cp __unused, struct g_provider *pp)
|
||||
{
|
||||
struct g_apple_softc *mp;
|
||||
struct g_slicer *gsp;
|
||||
|
||||
gsp = gp->softc;
|
||||
mp = gsp->softc;
|
||||
g_slice_dumpconf(sb, indent, gp, cp, pp);
|
||||
if (pp != NULL) {
|
||||
if (indent == NULL) {
|
||||
sbuf_printf(sb, " ty %s",
|
||||
mp->apmpart[pp->index].am_type);
|
||||
if (*mp->apmpart[pp->index].am_name)
|
||||
sbuf_printf(sb, " sn %s",
|
||||
mp->apmpart[pp->index].am_name);
|
||||
} else {
|
||||
sbuf_printf(sb, "%s<name>%s</name>\n", indent,
|
||||
mp->apmpart[pp->index].am_name);
|
||||
sbuf_printf(sb, "%s<type>%s</type>\n", indent,
|
||||
mp->apmpart[pp->index].am_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
g_apple_print()
|
||||
{
|
||||
|
||||
/* XXX */
|
||||
}
|
||||
#endif
|
||||
|
||||
static struct g_geom *
|
||||
g_apple_taste(struct g_class *mp, struct g_provider *pp, int insist)
|
||||
{
|
||||
struct g_geom *gp;
|
||||
struct g_consumer *cp;
|
||||
int i;
|
||||
struct g_apple_softc *ms;
|
||||
struct apm_partition *apm;
|
||||
u_int sectorsize;
|
||||
u_char *buf;
|
||||
|
||||
g_trace(G_T_TOPOLOGY, "apple_taste(%s,%s)", mp->name, pp->name);
|
||||
g_topology_assert();
|
||||
gp = g_slice_new(mp, NAPMPART, pp, &cp, &ms, sizeof *ms, g_apple_start);
|
||||
if (gp == NULL)
|
||||
return (NULL);
|
||||
g_topology_unlock();
|
||||
do {
|
||||
if (gp->rank != 2 && insist == 0)
|
||||
break;
|
||||
|
||||
sectorsize = cp->provider->sectorsize;
|
||||
if (sectorsize != 512)
|
||||
break;
|
||||
|
||||
buf = g_read_data(cp, 0, sectorsize, NULL);
|
||||
if (buf == NULL)
|
||||
break;
|
||||
|
||||
/*
|
||||
* Test for the sector 0 driver record signature, and
|
||||
* validate sector and disk size
|
||||
*/
|
||||
if (buf[0] != 'E' && buf[1] != 'R') {
|
||||
g_free(buf);
|
||||
break;
|
||||
}
|
||||
g_dec_drvrdesc(buf, ms);
|
||||
g_free(buf);
|
||||
|
||||
if (ms->dd_bsiz != 512) {
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read in the first partition map
|
||||
*/
|
||||
buf = g_read_data(cp, sectorsize, sectorsize, NULL);
|
||||
if (buf == NULL)
|
||||
break;
|
||||
|
||||
/*
|
||||
* Decode the first partition: it's another indication of
|
||||
* validity, as well as giving the size of the partition
|
||||
* map
|
||||
*/
|
||||
apm = &ms->apmpart[0];
|
||||
g_dec_apple_partition(buf, apm);
|
||||
g_free(buf);
|
||||
|
||||
if (apm->am_sig[0] != 'P' || apm->am_sig[1] != 'M')
|
||||
break;
|
||||
ms->am_mapcnt0 = apm->am_mapcnt;
|
||||
|
||||
buf = g_read_data(cp, 2 * sectorsize,
|
||||
(NAPMPART - 1) * sectorsize, NULL);
|
||||
if (buf == NULL)
|
||||
break;
|
||||
|
||||
for (i = 1; i < NAPMPART; i++) {
|
||||
g_dec_apple_partition(buf + ((i - 1) * sectorsize),
|
||||
&ms->apmpart[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < NAPMPART; i++) {
|
||||
apm = &ms->apmpart[i];
|
||||
|
||||
/*
|
||||
* Validate partition sig and global mapcount
|
||||
*/
|
||||
if (apm->am_sig[0] != 'P' ||
|
||||
apm->am_sig[1] != 'M')
|
||||
continue;
|
||||
if (apm->am_mapcnt != ms->am_mapcnt0)
|
||||
continue;
|
||||
|
||||
if (bootverbose) {
|
||||
printf("APM Slice %d (%s/%s) on %s:\n",
|
||||
i + 1, apm->am_name, apm->am_type,
|
||||
gp->name);
|
||||
/* g_apple_print(i, dp + i); */
|
||||
}
|
||||
g_topology_lock();
|
||||
g_slice_config(gp, i, G_SLICE_CONFIG_SET,
|
||||
(off_t)apm->am_start << 9ULL,
|
||||
(off_t)apm->am_partcnt << 9ULL,
|
||||
sectorsize,
|
||||
"%ss%d", gp->name, i + 1);
|
||||
g_topology_unlock();
|
||||
}
|
||||
g_free(buf);
|
||||
break;
|
||||
} while(0);
|
||||
g_topology_lock();
|
||||
g_access(cp, -1, 0, 0);
|
||||
if (LIST_EMPTY(&gp->provider)) {
|
||||
g_slice_spoiled(cp);
|
||||
return (NULL);
|
||||
}
|
||||
return (gp);
|
||||
}
|
||||
|
||||
|
||||
static struct g_class g_apple_class = {
|
||||
.name = APPLE_CLASS_NAME,
|
||||
.version = G_VERSION,
|
||||
.taste = g_apple_taste,
|
||||
.dumpconf = g_apple_dumpconf,
|
||||
};
|
||||
|
||||
DECLARE_GEOM_CLASS(g_apple_class, g_apple);
|
1356
sys/geom/geom_gpt.c
1356
sys/geom/geom_gpt.c
File diff suppressed because it is too large
Load Diff
1385
sys/geom/part/g_part.c
Normal file
1385
sys/geom/part/g_part.c
Normal file
File diff suppressed because it is too large
Load Diff
130
sys/geom/part/g_part.h
Normal file
130
sys/geom/part/g_part.h
Normal file
@ -0,0 +1,130 @@
|
||||
/*-
|
||||
* Copyright (c) 2006, 2007 Marcel Moolenaar
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _GEOM_PART_H_
|
||||
#define _GEOM_PART_H_
|
||||
|
||||
#define G_PART_TRACE(args) g_trace args
|
||||
|
||||
#define G_PART_PROBE_PRI_LOW -10
|
||||
#define G_PART_PROBE_PRI_NORM -5
|
||||
#define G_PART_PROBE_PRI_HIGH 0
|
||||
|
||||
enum g_part_alias {
|
||||
G_PART_ALIAS_EFI, /* A EFI system partition entry. */
|
||||
G_PART_ALIAS_FREEBSD, /* A BSD labeled partition entry. */
|
||||
G_PART_ALIAS_FREEBSD_SWAP, /* A swap partition entry. */
|
||||
G_PART_ALIAS_FREEBSD_UFS, /* A UFS/UFS2 file system entry. */
|
||||
G_PART_ALIAS_FREEBSD_VINUM, /* A Vinum partition entry. */
|
||||
G_PART_ALIAS_MBR, /* A MBR (extended) partition entry. */
|
||||
/* Keep the following last */
|
||||
G_PART_ALIAS_COUNT
|
||||
};
|
||||
|
||||
const char *g_part_alias_name(enum g_part_alias);
|
||||
|
||||
/* G_PART scheme (KOBJ class). */
|
||||
struct g_part_scheme {
|
||||
KOBJ_CLASS_FIELDS;
|
||||
size_t gps_entrysz;
|
||||
int gps_minent;
|
||||
int gps_maxent;
|
||||
};
|
||||
#define G_PART_SCHEME_DECLARE(s) DATA_SET(g_part_scheme_set, s)
|
||||
|
||||
struct g_part_entry {
|
||||
LIST_ENTRY(g_part_entry) gpe_entry;
|
||||
struct g_provider *gpe_pp; /* Corresponding provider. */
|
||||
off_t gpe_offset; /* Byte offset. */
|
||||
quad_t gpe_start; /* First LBA of partition. */
|
||||
quad_t gpe_end; /* Last LBA of partition. */
|
||||
int gpe_index;
|
||||
int gpe_created:1; /* Entry is newly created. */
|
||||
int gpe_deleted:1; /* Entry has been deleted. */
|
||||
int gpe_modified:1; /* Entry has been modified. */
|
||||
};
|
||||
|
||||
/* G_PART table (KOBJ instance). */
|
||||
struct g_part_table {
|
||||
KOBJ_FIELDS;
|
||||
struct g_part_scheme *gpt_scheme;
|
||||
struct g_geom *gpt_gp;
|
||||
LIST_HEAD(, g_part_entry) gpt_entry;
|
||||
quad_t gpt_first; /* First allocatable LBA */
|
||||
quad_t gpt_last; /* Last allocatable LBA */
|
||||
int gpt_entries;
|
||||
/*
|
||||
* gpt_smhead and gpt_smtail are bitmaps representing the first
|
||||
* 32 sectors on the disk (gpt_smhead) and the last 32 sectors
|
||||
* on the disk (gpt_smtail). These maps are used by the commit
|
||||
* verb to clear sectors previously used by a scheme after the
|
||||
* partitioning scheme has been destroyed.
|
||||
*/
|
||||
uint32_t gpt_smhead;
|
||||
uint32_t gpt_smtail;
|
||||
|
||||
int gpt_depth; /* Sub-partitioning level. */
|
||||
int gpt_isleaf:1; /* Cannot be sub-partitioned. */
|
||||
int gpt_created:1; /* Newly created. */
|
||||
int gpt_modified:1; /* Table changes have been made. */
|
||||
int gpt_opened:1; /* Permissions obtained. */
|
||||
};
|
||||
|
||||
struct g_part_entry *g_part_new_entry(struct g_part_table *, int, quad_t,
|
||||
quad_t);
|
||||
|
||||
/* G_PART ctlreq parameters. */
|
||||
#define G_PART_PARM_ENTRIES 0x0001
|
||||
#define G_PART_PARM_FLAGS 0x0002
|
||||
#define G_PART_PARM_GEOM 0x0004
|
||||
#define G_PART_PARM_INDEX 0x0008
|
||||
#define G_PART_PARM_LABEL 0x0010
|
||||
#define G_PART_PARM_PROVIDER 0x0020
|
||||
#define G_PART_PARM_REQUEST 0x0040
|
||||
#define G_PART_PARM_RESPONSE 0x0080
|
||||
#define G_PART_PARM_SCHEME 0x0100
|
||||
#define G_PART_PARM_SIZE 0x0200
|
||||
#define G_PART_PARM_START 0x0400
|
||||
#define G_PART_PARM_TYPE 0x0800
|
||||
|
||||
struct g_part_parms {
|
||||
unsigned int gpp_parms;
|
||||
unsigned int gpp_entries;
|
||||
const char *gpp_flags;
|
||||
struct g_geom *gpp_geom;
|
||||
unsigned int gpp_index;
|
||||
const char *gpp_label;
|
||||
struct g_provider *gpp_provider;
|
||||
const char *gpp_request;
|
||||
struct g_part_scheme *gpp_scheme;
|
||||
quad_t gpp_size;
|
||||
quad_t gpp_start;
|
||||
const char *gpp_type;
|
||||
};
|
||||
|
||||
#endif /* !_GEOM_PART_H_ */
|
414
sys/geom/part/g_part_apm.c
Normal file
414
sys/geom/part/g_part_apm.c
Normal file
@ -0,0 +1,414 @@
|
||||
/*-
|
||||
* Copyright (c) 2006, 2007 Marcel Moolenaar
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/apm.h>
|
||||
#include <sys/bio.h>
|
||||
#include <sys/diskmbr.h>
|
||||
#include <sys/endian.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/kobj.h>
|
||||
#include <sys/limits.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/sbuf.h>
|
||||
#include <sys/systm.h>
|
||||
#include <geom/geom.h>
|
||||
#include <geom/part/g_part.h>
|
||||
|
||||
#include "g_part_if.h"
|
||||
|
||||
struct g_part_apm_table {
|
||||
struct g_part_table base;
|
||||
struct apm_ddr ddr;
|
||||
struct apm_ent self;
|
||||
};
|
||||
|
||||
struct g_part_apm_entry {
|
||||
struct g_part_entry base;
|
||||
struct apm_ent ent;
|
||||
};
|
||||
|
||||
static int g_part_apm_add(struct g_part_table *, struct g_part_entry *,
|
||||
struct g_part_parms *);
|
||||
static int g_part_apm_create(struct g_part_table *, struct g_part_parms *);
|
||||
static int g_part_apm_destroy(struct g_part_table *, struct g_part_parms *);
|
||||
static int g_part_apm_dumpto(struct g_part_table *, struct g_part_entry *);
|
||||
static int g_part_apm_modify(struct g_part_table *, struct g_part_entry *,
|
||||
struct g_part_parms *);
|
||||
static char *g_part_apm_name(struct g_part_table *, struct g_part_entry *,
|
||||
char *, size_t);
|
||||
static int g_part_apm_probe(struct g_part_table *, struct g_consumer *);
|
||||
static int g_part_apm_read(struct g_part_table *, struct g_consumer *);
|
||||
static const char *g_part_apm_type(struct g_part_table *, struct g_part_entry *,
|
||||
char *, size_t);
|
||||
static int g_part_apm_write(struct g_part_table *, struct g_consumer *);
|
||||
|
||||
static kobj_method_t g_part_apm_methods[] = {
|
||||
KOBJMETHOD(g_part_add, g_part_apm_add),
|
||||
KOBJMETHOD(g_part_create, g_part_apm_create),
|
||||
KOBJMETHOD(g_part_destroy, g_part_apm_destroy),
|
||||
KOBJMETHOD(g_part_dumpto, g_part_apm_dumpto),
|
||||
KOBJMETHOD(g_part_modify, g_part_apm_modify),
|
||||
KOBJMETHOD(g_part_name, g_part_apm_name),
|
||||
KOBJMETHOD(g_part_probe, g_part_apm_probe),
|
||||
KOBJMETHOD(g_part_read, g_part_apm_read),
|
||||
KOBJMETHOD(g_part_type, g_part_apm_type),
|
||||
KOBJMETHOD(g_part_write, g_part_apm_write),
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static struct g_part_scheme g_part_apm_scheme = {
|
||||
"APM",
|
||||
g_part_apm_methods,
|
||||
sizeof(struct g_part_apm_table),
|
||||
.gps_entrysz = sizeof(struct g_part_apm_entry),
|
||||
.gps_minent = 16,
|
||||
.gps_maxent = INT_MAX,
|
||||
};
|
||||
G_PART_SCHEME_DECLARE(g_part_apm_scheme);
|
||||
|
||||
static int
|
||||
apm_parse_type(const char *type, char *buf, size_t bufsz)
|
||||
{
|
||||
|
||||
if (type[0] != '@') {
|
||||
if (strlen(type) > bufsz)
|
||||
return (EINVAL);
|
||||
if (!strcmp(type, APM_ENT_TYPE_SELF) ||
|
||||
!strcmp(type, APM_ENT_TYPE_UNUSED))
|
||||
return (EINVAL);
|
||||
strncpy(buf, type, bufsz);
|
||||
return (0);
|
||||
}
|
||||
if (!strcmp(type, g_part_alias_name(G_PART_ALIAS_FREEBSD)))
|
||||
strcpy(buf, APM_ENT_TYPE_FREEBSD);
|
||||
else if (!strcmp(type, g_part_alias_name(G_PART_ALIAS_FREEBSD_SWAP)))
|
||||
strcpy(buf, APM_ENT_TYPE_FREEBSD_SWAP);
|
||||
else if (!strcmp(type, g_part_alias_name(G_PART_ALIAS_FREEBSD_UFS)))
|
||||
strcpy(buf, APM_ENT_TYPE_FREEBSD_UFS);
|
||||
else if (!strcmp(type, g_part_alias_name(G_PART_ALIAS_FREEBSD_VINUM)))
|
||||
strcpy(buf, APM_ENT_TYPE_FREEBSD_VINUM);
|
||||
else
|
||||
return (EINVAL);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
apm_read_ent(struct g_consumer *cp, uint32_t blk, struct apm_ent *ent)
|
||||
{
|
||||
struct g_provider *pp;
|
||||
char *buf;
|
||||
int error;
|
||||
|
||||
pp = cp->provider;
|
||||
buf = g_read_data(cp, pp->sectorsize * blk, pp->sectorsize, &error);
|
||||
if (buf == NULL)
|
||||
return (error);
|
||||
ent->ent_sig = be16dec(buf);
|
||||
ent->ent_pmblkcnt = be32dec(buf + 4);
|
||||
ent->ent_start = be32dec(buf + 8);
|
||||
ent->ent_size = be32dec(buf + 12);
|
||||
bcopy(buf + 16, ent->ent_name, sizeof(ent->ent_name));
|
||||
bcopy(buf + 48, ent->ent_type, sizeof(ent->ent_type));
|
||||
g_free(buf);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
g_part_apm_add(struct g_part_table *basetable, struct g_part_entry *baseentry,
|
||||
struct g_part_parms *gpp)
|
||||
{
|
||||
struct g_part_apm_entry *entry;
|
||||
struct g_part_apm_table *table;
|
||||
int error;
|
||||
|
||||
entry = (struct g_part_apm_entry *)baseentry;
|
||||
table = (struct g_part_apm_table *)basetable;
|
||||
entry->ent.ent_sig = APM_ENT_SIG;
|
||||
entry->ent.ent_pmblkcnt = table->self.ent_pmblkcnt;
|
||||
entry->ent.ent_start = gpp->gpp_start;
|
||||
entry->ent.ent_size = gpp->gpp_size;
|
||||
if (baseentry->gpe_deleted) {
|
||||
bzero(entry->ent.ent_type, sizeof(entry->ent.ent_type));
|
||||
bzero(entry->ent.ent_name, sizeof(entry->ent.ent_name));
|
||||
}
|
||||
error = apm_parse_type(gpp->gpp_type, entry->ent.ent_type,
|
||||
sizeof(entry->ent.ent_type));
|
||||
if (error)
|
||||
return (error);
|
||||
if (gpp->gpp_parms & G_PART_PARM_LABEL) {
|
||||
if (strlen(gpp->gpp_label) > sizeof(entry->ent.ent_name))
|
||||
return (EINVAL);
|
||||
strncpy(entry->ent.ent_name, gpp->gpp_label,
|
||||
sizeof(entry->ent.ent_name));
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
g_part_apm_create(struct g_part_table *basetable, struct g_part_parms *gpp)
|
||||
{
|
||||
struct g_provider *pp;
|
||||
struct g_part_apm_table *table;
|
||||
|
||||
table = (struct g_part_apm_table *)basetable;
|
||||
pp = gpp->gpp_provider;
|
||||
if (pp->sectorsize != 512 ||
|
||||
pp->mediasize < (2 + 2 * basetable->gpt_entries) * pp->sectorsize)
|
||||
return (ENOSPC);
|
||||
|
||||
basetable->gpt_first = 2 + basetable->gpt_entries;
|
||||
basetable->gpt_last = (pp->mediasize / pp->sectorsize) - 1;
|
||||
|
||||
table->ddr.ddr_sig = APM_DDR_SIG;
|
||||
table->ddr.ddr_blksize = pp->sectorsize;
|
||||
table->ddr.ddr_blkcount = basetable->gpt_last + 1;
|
||||
|
||||
table->self.ent_sig = APM_ENT_SIG;
|
||||
table->self.ent_pmblkcnt = basetable->gpt_entries + 1;
|
||||
table->self.ent_start = 1;
|
||||
table->self.ent_size = table->self.ent_pmblkcnt;
|
||||
strcpy(table->self.ent_name, "Apple");
|
||||
strcpy(table->self.ent_type, APM_ENT_TYPE_SELF);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
g_part_apm_destroy(struct g_part_table *basetable, struct g_part_parms *gpp)
|
||||
{
|
||||
|
||||
/* Wipe the first 2 sectors to clear the partitioning. */
|
||||
basetable->gpt_smhead |= 3;
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
g_part_apm_dumpto(struct g_part_table *table, struct g_part_entry *baseentry)
|
||||
{
|
||||
struct g_part_apm_entry *entry;
|
||||
|
||||
entry = (struct g_part_apm_entry *)baseentry;
|
||||
return ((!strcmp(entry->ent.ent_type, APM_ENT_TYPE_FREEBSD_SWAP))
|
||||
? 1 : 0);
|
||||
}
|
||||
|
||||
static int
|
||||
g_part_apm_modify(struct g_part_table *basetable,
|
||||
struct g_part_entry *baseentry, struct g_part_parms *gpp)
|
||||
{
|
||||
struct g_part_apm_entry *entry;
|
||||
int error;
|
||||
|
||||
entry = (struct g_part_apm_entry *)baseentry;
|
||||
if (gpp->gpp_parms & G_PART_PARM_LABEL) {
|
||||
if (strlen(gpp->gpp_label) > sizeof(entry->ent.ent_name))
|
||||
return (EINVAL);
|
||||
}
|
||||
if (gpp->gpp_parms & G_PART_PARM_TYPE) {
|
||||
error = apm_parse_type(gpp->gpp_type, entry->ent.ent_type,
|
||||
sizeof(entry->ent.ent_type));
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
if (gpp->gpp_parms & G_PART_PARM_LABEL) {
|
||||
strncpy(entry->ent.ent_name, gpp->gpp_label,
|
||||
sizeof(entry->ent.ent_name));
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
static char *
|
||||
g_part_apm_name(struct g_part_table *table, struct g_part_entry *baseentry,
|
||||
char *buf, size_t bufsz)
|
||||
{
|
||||
|
||||
snprintf(buf, bufsz, "s%d", baseentry->gpe_index + 1);
|
||||
return (buf);
|
||||
}
|
||||
|
||||
static int
|
||||
g_part_apm_probe(struct g_part_table *basetable, struct g_consumer *cp)
|
||||
{
|
||||
struct g_provider *pp;
|
||||
struct g_part_apm_table *table;
|
||||
char *buf;
|
||||
int error;
|
||||
|
||||
/* We don't nest, which means that our depth should be 0. */
|
||||
if (basetable->gpt_depth != 0)
|
||||
return (ENXIO);
|
||||
|
||||
table = (struct g_part_apm_table *)basetable;
|
||||
pp = cp->provider;
|
||||
|
||||
/* Sanity-check the provider. */
|
||||
if (pp->mediasize < 4 * pp->sectorsize)
|
||||
return (ENOSPC);
|
||||
|
||||
/* Check that there's a Driver Descriptor Record (DDR). */
|
||||
buf = g_read_data(cp, 0L, pp->sectorsize, &error);
|
||||
if (buf == NULL)
|
||||
return (error);
|
||||
table->ddr.ddr_sig = be16dec(buf);
|
||||
table->ddr.ddr_blksize = be16dec(buf + 2);
|
||||
table->ddr.ddr_blkcount = be32dec(buf + 4);
|
||||
g_free(buf);
|
||||
if (table->ddr.ddr_sig != APM_DDR_SIG)
|
||||
return (ENXIO);
|
||||
if (table->ddr.ddr_blksize != pp->sectorsize)
|
||||
return (ENXIO);
|
||||
|
||||
/* Check that there's a Partition Map. */
|
||||
error = apm_read_ent(cp, 1, &table->self);
|
||||
if (error)
|
||||
return (error);
|
||||
if (table->self.ent_sig != APM_ENT_SIG)
|
||||
return (ENXIO);
|
||||
if (strcmp(table->self.ent_type, APM_ENT_TYPE_SELF))
|
||||
return (ENXIO);
|
||||
if (table->self.ent_pmblkcnt >= table->ddr.ddr_blkcount)
|
||||
return (ENXIO);
|
||||
return (G_PART_PROBE_PRI_NORM);
|
||||
}
|
||||
|
||||
static int
|
||||
g_part_apm_read(struct g_part_table *basetable, struct g_consumer *cp)
|
||||
{
|
||||
struct apm_ent ent;
|
||||
struct g_part_apm_entry *entry;
|
||||
struct g_part_apm_table *table;
|
||||
int error, index;
|
||||
|
||||
table = (struct g_part_apm_table *)basetable;
|
||||
|
||||
basetable->gpt_first = table->self.ent_pmblkcnt + 1;
|
||||
basetable->gpt_last = table->ddr.ddr_blkcount - 1;
|
||||
basetable->gpt_entries = table->self.ent_pmblkcnt - 1;
|
||||
|
||||
for (index = table->self.ent_pmblkcnt - 1; index > 0; index--) {
|
||||
error = apm_read_ent(cp, index + 1, &ent);
|
||||
if (error)
|
||||
continue;
|
||||
if (!strcmp(ent.ent_type, APM_ENT_TYPE_UNUSED))
|
||||
continue;
|
||||
entry = (struct g_part_apm_entry *)g_part_new_entry(basetable,
|
||||
index, ent.ent_start, ent.ent_start + ent.ent_size - 1);
|
||||
entry->ent = ent;
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static const char *
|
||||
g_part_apm_type(struct g_part_table *basetable, struct g_part_entry *baseentry,
|
||||
char *buf, size_t bufsz)
|
||||
{
|
||||
struct g_part_apm_entry *entry;
|
||||
const char *type;
|
||||
size_t len;
|
||||
|
||||
entry = (struct g_part_apm_entry *)baseentry;
|
||||
type = entry->ent.ent_type;
|
||||
if (!strcmp(type, APM_ENT_TYPE_FREEBSD))
|
||||
return (g_part_alias_name(G_PART_ALIAS_FREEBSD));
|
||||
if (!strcmp(type, APM_ENT_TYPE_FREEBSD_SWAP))
|
||||
return (g_part_alias_name(G_PART_ALIAS_FREEBSD_SWAP));
|
||||
if (!strcmp(type, APM_ENT_TYPE_FREEBSD_UFS))
|
||||
return (g_part_alias_name(G_PART_ALIAS_FREEBSD_UFS));
|
||||
if (!strcmp(type, APM_ENT_TYPE_FREEBSD_VINUM))
|
||||
return (g_part_alias_name(G_PART_ALIAS_FREEBSD_VINUM));
|
||||
len = MIN(sizeof(entry->ent.ent_type), bufsz - 1);
|
||||
bcopy(type, buf, len);
|
||||
buf[len] = '\0';
|
||||
return (buf);
|
||||
}
|
||||
|
||||
static int
|
||||
g_part_apm_write(struct g_part_table *basetable, struct g_consumer *cp)
|
||||
{
|
||||
char buf[512];
|
||||
struct g_part_entry *baseentry;
|
||||
struct g_part_apm_entry *entry;
|
||||
struct g_part_apm_table *table;
|
||||
int error, index;
|
||||
|
||||
table = (struct g_part_apm_table *)basetable;
|
||||
bzero(buf, sizeof(buf));
|
||||
|
||||
/* Write the DDR and 'self' entry only when we're newly created. */
|
||||
if (basetable->gpt_created) {
|
||||
be16enc(buf, table->ddr.ddr_sig);
|
||||
be16enc(buf + 2, table->ddr.ddr_blksize);
|
||||
be32enc(buf + 4, table->ddr.ddr_blkcount);
|
||||
error = g_write_data(cp, 0, buf, sizeof(buf));
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
|
||||
be16enc(buf, table->self.ent_sig);
|
||||
be16enc(buf + 2, 0);
|
||||
be32enc(buf + 4, table->self.ent_pmblkcnt);
|
||||
|
||||
if (basetable->gpt_created) {
|
||||
be32enc(buf + 8, table->self.ent_start);
|
||||
be32enc(buf + 12, table->self.ent_size);
|
||||
bcopy(table->self.ent_name, buf + 16,
|
||||
sizeof(table->self.ent_name));
|
||||
bcopy(table->self.ent_type, buf + 48,
|
||||
sizeof(table->self.ent_type));
|
||||
error = g_write_data(cp, 512, buf, sizeof(buf));
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
|
||||
baseentry = LIST_FIRST(&basetable->gpt_entry);
|
||||
for (index = 1; index <= basetable->gpt_entries; index++) {
|
||||
if (baseentry != NULL && index == baseentry->gpe_index) {
|
||||
entry = (struct g_part_apm_entry *)baseentry;
|
||||
be32enc(buf + 8, entry->ent.ent_start);
|
||||
be32enc(buf + 12, entry->ent.ent_size);
|
||||
bcopy(entry->ent.ent_name, buf + 16,
|
||||
sizeof(entry->ent.ent_name));
|
||||
bcopy(entry->ent.ent_type, buf + 48,
|
||||
sizeof(entry->ent.ent_type));
|
||||
baseentry = LIST_NEXT(baseentry, gpe_entry);
|
||||
} else {
|
||||
bzero(buf + 8, 4 + 4 + 32 + 32);
|
||||
strcpy(buf + 48, APM_ENT_TYPE_UNUSED);
|
||||
}
|
||||
error = g_write_data(cp, (index + 1) * 512, buf, sizeof(buf));
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
736
sys/geom/part/g_part_gpt.c
Normal file
736
sys/geom/part/g_part_gpt.c
Normal file
@ -0,0 +1,736 @@
|
||||
/*-
|
||||
* Copyright (c) 2002, 2005, 2006, 2007 Marcel Moolenaar
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/bio.h>
|
||||
#include <sys/diskmbr.h>
|
||||
#include <sys/endian.h>
|
||||
#include <sys/gpt.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/kobj.h>
|
||||
#include <sys/limits.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/sbuf.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/uuid.h>
|
||||
#include <geom/geom.h>
|
||||
#include <geom/part/g_part.h>
|
||||
|
||||
#include "g_part_if.h"
|
||||
|
||||
CTASSERT(offsetof(struct gpt_hdr, padding) == 92);
|
||||
CTASSERT(sizeof(struct gpt_ent) == 128);
|
||||
|
||||
#define EQUUID(a,b) (memcmp(a, b, sizeof(struct uuid)) == 0)
|
||||
|
||||
enum gpt_elt {
|
||||
GPT_ELT_PRIHDR,
|
||||
GPT_ELT_PRITBL,
|
||||
GPT_ELT_SECHDR,
|
||||
GPT_ELT_SECTBL,
|
||||
GPT_ELT_COUNT
|
||||
};
|
||||
|
||||
enum gpt_state {
|
||||
GPT_STATE_UNKNOWN, /* Not determined. */
|
||||
GPT_STATE_MISSING, /* No signature found. */
|
||||
GPT_STATE_CORRUPT, /* Checksum mismatch. */
|
||||
GPT_STATE_INVALID, /* Nonconformant/invalid. */
|
||||
GPT_STATE_OK /* Perfectly fine. */
|
||||
};
|
||||
|
||||
struct g_part_gpt_table {
|
||||
struct g_part_table base;
|
||||
struct gpt_hdr hdr;
|
||||
quad_t lba[GPT_ELT_COUNT];
|
||||
enum gpt_state state[GPT_ELT_COUNT];
|
||||
};
|
||||
|
||||
struct g_part_gpt_entry {
|
||||
struct g_part_entry base;
|
||||
struct gpt_ent ent;
|
||||
};
|
||||
|
||||
static int g_part_gpt_add(struct g_part_table *, struct g_part_entry *,
|
||||
struct g_part_parms *);
|
||||
static int g_part_gpt_create(struct g_part_table *, struct g_part_parms *);
|
||||
static int g_part_gpt_destroy(struct g_part_table *, struct g_part_parms *);
|
||||
static int g_part_gpt_dumpto(struct g_part_table *, struct g_part_entry *);
|
||||
static int g_part_gpt_modify(struct g_part_table *, struct g_part_entry *,
|
||||
struct g_part_parms *);
|
||||
static char *g_part_gpt_name(struct g_part_table *, struct g_part_entry *,
|
||||
char *, size_t);
|
||||
static int g_part_gpt_probe(struct g_part_table *, struct g_consumer *);
|
||||
static int g_part_gpt_read(struct g_part_table *, struct g_consumer *);
|
||||
static const char *g_part_gpt_type(struct g_part_table *, struct g_part_entry *,
|
||||
char *, size_t);
|
||||
static int g_part_gpt_write(struct g_part_table *, struct g_consumer *);
|
||||
|
||||
static kobj_method_t g_part_gpt_methods[] = {
|
||||
KOBJMETHOD(g_part_add, g_part_gpt_add),
|
||||
KOBJMETHOD(g_part_create, g_part_gpt_create),
|
||||
KOBJMETHOD(g_part_destroy, g_part_gpt_destroy),
|
||||
KOBJMETHOD(g_part_dumpto, g_part_gpt_dumpto),
|
||||
KOBJMETHOD(g_part_modify, g_part_gpt_modify),
|
||||
KOBJMETHOD(g_part_name, g_part_gpt_name),
|
||||
KOBJMETHOD(g_part_probe, g_part_gpt_probe),
|
||||
KOBJMETHOD(g_part_read, g_part_gpt_read),
|
||||
KOBJMETHOD(g_part_type, g_part_gpt_type),
|
||||
KOBJMETHOD(g_part_write, g_part_gpt_write),
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static struct g_part_scheme g_part_gpt_scheme = {
|
||||
"GPT",
|
||||
g_part_gpt_methods,
|
||||
sizeof(struct g_part_gpt_table),
|
||||
.gps_entrysz = sizeof(struct g_part_gpt_entry),
|
||||
.gps_minent = 128,
|
||||
.gps_maxent = INT_MAX,
|
||||
};
|
||||
G_PART_SCHEME_DECLARE(g_part_gpt_scheme);
|
||||
|
||||
static struct uuid gpt_uuid_efi = GPT_ENT_TYPE_EFI;
|
||||
static struct uuid gpt_uuid_freebsd = GPT_ENT_TYPE_FREEBSD;
|
||||
static struct uuid gpt_uuid_freebsd_swap = GPT_ENT_TYPE_FREEBSD_SWAP;
|
||||
static struct uuid gpt_uuid_freebsd_ufs = GPT_ENT_TYPE_FREEBSD_UFS;
|
||||
static struct uuid gpt_uuid_freebsd_vinum = GPT_ENT_TYPE_FREEBSD_VINUM;
|
||||
static struct uuid gpt_uuid_linux_swap = GPT_ENT_TYPE_LINUX_SWAP;
|
||||
static struct uuid gpt_uuid_mbr = GPT_ENT_TYPE_MBR;
|
||||
static struct uuid gpt_uuid_unused = GPT_ENT_TYPE_UNUSED;
|
||||
|
||||
static void
|
||||
gpt_read_hdr(struct g_part_gpt_table *table, struct g_consumer *cp,
|
||||
enum gpt_elt elt, struct gpt_hdr *hdr)
|
||||
{
|
||||
struct uuid uuid;
|
||||
struct g_provider *pp;
|
||||
char *buf;
|
||||
quad_t lba, last;
|
||||
int error;
|
||||
uint32_t crc, sz;
|
||||
|
||||
pp = cp->provider;
|
||||
last = (pp->mediasize / pp->sectorsize) - 1;
|
||||
table->lba[elt] = (elt == GPT_ELT_PRIHDR) ? 1 : last;
|
||||
table->state[elt] = GPT_STATE_MISSING;
|
||||
buf = g_read_data(cp, table->lba[elt] * pp->sectorsize, pp->sectorsize,
|
||||
&error);
|
||||
if (buf == NULL)
|
||||
return;
|
||||
bcopy(buf, hdr, sizeof(*hdr));
|
||||
if (memcmp(hdr->hdr_sig, GPT_HDR_SIG, sizeof(hdr->hdr_sig)) != 0)
|
||||
return;
|
||||
|
||||
table->state[elt] = GPT_STATE_CORRUPT;
|
||||
sz = le32toh(hdr->hdr_size);
|
||||
if (sz < 92 || sz > pp->sectorsize)
|
||||
return;
|
||||
crc = le32toh(hdr->hdr_crc_self);
|
||||
hdr->hdr_crc_self = 0;
|
||||
if (crc32(hdr, sz) != crc)
|
||||
return;
|
||||
hdr->hdr_size = sz;
|
||||
hdr->hdr_crc_self = crc;
|
||||
|
||||
table->state[elt] = GPT_STATE_INVALID;
|
||||
hdr->hdr_revision = le32toh(hdr->hdr_revision);
|
||||
if (hdr->hdr_revision < 0x00010000)
|
||||
return;
|
||||
hdr->hdr_lba_self = le64toh(hdr->hdr_lba_self);
|
||||
if (hdr->hdr_lba_self != table->lba[elt])
|
||||
return;
|
||||
hdr->hdr_lba_alt = le64toh(hdr->hdr_lba_alt);
|
||||
|
||||
/* Check the managed area. */
|
||||
hdr->hdr_lba_start = le64toh(hdr->hdr_lba_start);
|
||||
if (hdr->hdr_lba_start < 2 || hdr->hdr_lba_start >= last)
|
||||
return;
|
||||
hdr->hdr_lba_end = le64toh(hdr->hdr_lba_end);
|
||||
if (hdr->hdr_lba_end < hdr->hdr_lba_start || hdr->hdr_lba_end >= last)
|
||||
return;
|
||||
|
||||
/* Check the table location and size of the table. */
|
||||
hdr->hdr_entries = le32toh(hdr->hdr_entries);
|
||||
hdr->hdr_entsz = le32toh(hdr->hdr_entsz);
|
||||
if (hdr->hdr_entries == 0 || hdr->hdr_entsz < 128 ||
|
||||
(hdr->hdr_entsz & 7) != 0)
|
||||
return;
|
||||
hdr->hdr_lba_table = le64toh(hdr->hdr_lba_table);
|
||||
if (hdr->hdr_lba_table < 2 || hdr->hdr_lba_table >= last)
|
||||
return;
|
||||
if (hdr->hdr_lba_table >= hdr->hdr_lba_start &&
|
||||
hdr->hdr_lba_table <= hdr->hdr_lba_end)
|
||||
return;
|
||||
lba = hdr->hdr_lba_table +
|
||||
(hdr->hdr_entries * hdr->hdr_entsz + pp->sectorsize - 1) /
|
||||
pp->sectorsize - 1;
|
||||
if (lba >= last)
|
||||
return;
|
||||
if (lba >= hdr->hdr_lba_start && lba <= hdr->hdr_lba_end)
|
||||
return;
|
||||
|
||||
table->state[elt] = GPT_STATE_OK;
|
||||
le_uuid_dec(&hdr->hdr_uuid, &uuid);
|
||||
hdr->hdr_uuid = uuid;
|
||||
hdr->hdr_crc_table = le32toh(hdr->hdr_crc_table);
|
||||
}
|
||||
|
||||
static struct gpt_ent *
|
||||
gpt_read_tbl(struct g_part_gpt_table *table, struct g_consumer *cp,
|
||||
enum gpt_elt elt, struct gpt_hdr *hdr)
|
||||
{
|
||||
struct g_provider *pp;
|
||||
struct gpt_ent *ent, *tbl;
|
||||
char *buf, *p;
|
||||
unsigned int idx, sectors, tblsz;
|
||||
int error;
|
||||
uint16_t ch;
|
||||
|
||||
pp = cp->provider;
|
||||
table->lba[elt] = hdr->hdr_lba_table;
|
||||
|
||||
table->state[elt] = GPT_STATE_MISSING;
|
||||
tblsz = hdr->hdr_entries * hdr->hdr_entsz;
|
||||
sectors = (tblsz + pp->sectorsize - 1) / pp->sectorsize;
|
||||
buf = g_read_data(cp, table->lba[elt] * pp->sectorsize,
|
||||
sectors * pp->sectorsize, &error);
|
||||
if (buf == NULL)
|
||||
return (NULL);
|
||||
|
||||
table->state[elt] = GPT_STATE_CORRUPT;
|
||||
if (crc32(buf, tblsz) != hdr->hdr_crc_table) {
|
||||
g_free(buf);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
table->state[elt] = GPT_STATE_OK;
|
||||
tbl = g_malloc(hdr->hdr_entries * sizeof(struct gpt_ent),
|
||||
M_WAITOK | M_ZERO);
|
||||
|
||||
for (idx = 0, ent = tbl, p = buf;
|
||||
idx < hdr->hdr_entries;
|
||||
idx++, ent++, p += hdr->hdr_entsz) {
|
||||
le_uuid_dec(p, &ent->ent_type);
|
||||
le_uuid_dec(p + 16, &ent->ent_uuid);
|
||||
ent->ent_lba_start = le64dec(p + 32);
|
||||
ent->ent_lba_end = le64dec(p + 40);
|
||||
ent->ent_attr = le64dec(p + 48);
|
||||
for (ch = 0; ch < sizeof(ent->ent_name)/2; ch++)
|
||||
ent->ent_name[ch] = le16dec(p + 56 + ch * 2);
|
||||
}
|
||||
|
||||
g_free(buf);
|
||||
return (tbl);
|
||||
}
|
||||
|
||||
static int
|
||||
gpt_matched_hdrs(struct gpt_hdr *pri, struct gpt_hdr *sec)
|
||||
{
|
||||
|
||||
if (!EQUUID(&pri->hdr_uuid, &sec->hdr_uuid))
|
||||
return (0);
|
||||
return ((pri->hdr_revision == sec->hdr_revision &&
|
||||
pri->hdr_size == sec->hdr_size &&
|
||||
pri->hdr_lba_start == sec->hdr_lba_start &&
|
||||
pri->hdr_lba_end == sec->hdr_lba_end &&
|
||||
pri->hdr_entries == sec->hdr_entries &&
|
||||
pri->hdr_entsz == sec->hdr_entsz &&
|
||||
pri->hdr_crc_table == sec->hdr_crc_table) ? 1 : 0);
|
||||
}
|
||||
|
||||
static int
|
||||
gpt_parse_type(const char *type, struct uuid *uuid)
|
||||
{
|
||||
struct uuid tmp;
|
||||
int error;
|
||||
|
||||
if (type[0] != '@') {
|
||||
error = parse_uuid(type, &tmp);
|
||||
if (error)
|
||||
return (error);
|
||||
if (EQUUID(&tmp, &gpt_uuid_unused))
|
||||
return (EINVAL);
|
||||
*uuid = tmp;
|
||||
return (0);
|
||||
}
|
||||
if (!strcmp(type, g_part_alias_name(G_PART_ALIAS_EFI)))
|
||||
*uuid = gpt_uuid_efi;
|
||||
else if (!strcmp(type, g_part_alias_name(G_PART_ALIAS_FREEBSD)))
|
||||
*uuid = gpt_uuid_freebsd;
|
||||
else if (!strcmp(type, g_part_alias_name(G_PART_ALIAS_FREEBSD_SWAP)))
|
||||
*uuid = gpt_uuid_freebsd_swap;
|
||||
else if (!strcmp(type, g_part_alias_name(G_PART_ALIAS_FREEBSD_UFS)))
|
||||
*uuid = gpt_uuid_freebsd_ufs;
|
||||
else if (!strcmp(type, g_part_alias_name(G_PART_ALIAS_FREEBSD_VINUM)))
|
||||
*uuid = gpt_uuid_freebsd_vinum;
|
||||
else if (!strcmp(type, g_part_alias_name(G_PART_ALIAS_MBR)))
|
||||
*uuid = gpt_uuid_mbr;
|
||||
else
|
||||
return (EINVAL);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
g_part_gpt_add(struct g_part_table *basetable, struct g_part_entry *baseentry,
|
||||
struct g_part_parms *gpp)
|
||||
{
|
||||
struct g_part_gpt_entry *entry;
|
||||
int error;
|
||||
|
||||
entry = (struct g_part_gpt_entry *)baseentry;
|
||||
error = gpt_parse_type(gpp->gpp_type, &entry->ent.ent_type);
|
||||
if (error)
|
||||
return (error);
|
||||
kern_uuidgen(&entry->ent.ent_uuid, 1);
|
||||
entry->ent.ent_lba_start = baseentry->gpe_start;
|
||||
entry->ent.ent_lba_end = baseentry->gpe_end;
|
||||
if (baseentry->gpe_deleted) {
|
||||
entry->ent.ent_attr = 0;
|
||||
bzero(entry->ent.ent_name, sizeof(entry->ent.ent_name));
|
||||
}
|
||||
/* XXX label */
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
g_part_gpt_create(struct g_part_table *basetable, struct g_part_parms *gpp)
|
||||
{
|
||||
struct g_provider *pp;
|
||||
struct g_part_gpt_table *table;
|
||||
quad_t last;
|
||||
size_t tblsz;
|
||||
|
||||
table = (struct g_part_gpt_table *)basetable;
|
||||
pp = gpp->gpp_provider;
|
||||
tblsz = (basetable->gpt_entries * sizeof(struct gpt_ent) +
|
||||
pp->sectorsize - 1) / pp->sectorsize;
|
||||
if (pp->sectorsize < 512 ||
|
||||
pp->mediasize < (3 + 2 * tblsz + basetable->gpt_entries) *
|
||||
pp->sectorsize)
|
||||
return (ENOSPC);
|
||||
|
||||
last = (pp->mediasize / pp->sectorsize) - 1;
|
||||
|
||||
table->lba[GPT_ELT_PRIHDR] = 1;
|
||||
table->lba[GPT_ELT_PRITBL] = 2;
|
||||
table->lba[GPT_ELT_SECHDR] = last;
|
||||
table->lba[GPT_ELT_SECTBL] = last - tblsz;
|
||||
|
||||
bcopy(GPT_HDR_SIG, table->hdr.hdr_sig, sizeof(table->hdr.hdr_sig));
|
||||
table->hdr.hdr_revision = GPT_HDR_REVISION;
|
||||
table->hdr.hdr_size = offsetof(struct gpt_hdr, padding);
|
||||
table->hdr.hdr_lba_start = 2 + tblsz;
|
||||
table->hdr.hdr_lba_end = last - tblsz - 1;
|
||||
kern_uuidgen(&table->hdr.hdr_uuid, 1);
|
||||
table->hdr.hdr_entries = basetable->gpt_entries;
|
||||
table->hdr.hdr_entsz = sizeof(struct gpt_ent);
|
||||
|
||||
basetable->gpt_first = table->hdr.hdr_lba_start;
|
||||
basetable->gpt_last = table->hdr.hdr_lba_end;
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
g_part_gpt_destroy(struct g_part_table *basetable, struct g_part_parms *gpp)
|
||||
{
|
||||
|
||||
/*
|
||||
* Wipe the first 2 sectors as well as the last to clear the
|
||||
* partitioning.
|
||||
*/
|
||||
basetable->gpt_smhead |= 3;
|
||||
basetable->gpt_smtail |= 1;
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
g_part_gpt_dumpto(struct g_part_table *table, struct g_part_entry *baseentry)
|
||||
{
|
||||
struct g_part_gpt_entry *entry;
|
||||
|
||||
entry = (struct g_part_gpt_entry *)baseentry;
|
||||
return ((EQUUID(&entry->ent.ent_type, &gpt_uuid_freebsd_swap) ||
|
||||
EQUUID(&entry->ent.ent_type, &gpt_uuid_linux_swap)) ? 1 : 0);
|
||||
}
|
||||
|
||||
static int
|
||||
g_part_gpt_modify(struct g_part_table *basetable,
|
||||
struct g_part_entry *baseentry, struct g_part_parms *gpp)
|
||||
{
|
||||
struct g_part_gpt_entry *entry;
|
||||
int error;
|
||||
|
||||
entry = (struct g_part_gpt_entry *)baseentry;
|
||||
error = gpt_parse_type(gpp->gpp_type, &entry->ent.ent_type);
|
||||
if (error)
|
||||
return (error);
|
||||
/* XXX label */
|
||||
return (0);
|
||||
}
|
||||
|
||||
static char *
|
||||
g_part_gpt_name(struct g_part_table *table, struct g_part_entry *baseentry,
|
||||
char *buf, size_t bufsz)
|
||||
{
|
||||
struct g_part_gpt_entry *entry;
|
||||
char c;
|
||||
|
||||
entry = (struct g_part_gpt_entry *)baseentry;
|
||||
c = (EQUUID(&entry->ent.ent_type, &gpt_uuid_freebsd)) ? 's' : 'p';
|
||||
snprintf(buf, bufsz, "%c%d", c, baseentry->gpe_index);
|
||||
return (buf);
|
||||
}
|
||||
|
||||
static int
|
||||
g_part_gpt_probe(struct g_part_table *table, struct g_consumer *cp)
|
||||
{
|
||||
struct g_provider *pp;
|
||||
char *buf;
|
||||
int error, res;
|
||||
|
||||
/* We don't nest, which means that our depth should be 0. */
|
||||
if (table->gpt_depth != 0)
|
||||
return (ENXIO);
|
||||
|
||||
pp = cp->provider;
|
||||
|
||||
/*
|
||||
* Sanity-check the provider. Since the first sector on the provider
|
||||
* must be a PMBR and a PMBR is 512 bytes large, the sector size
|
||||
* must be at least 512 bytes. Also, since the theoretical minimum
|
||||
* number of sectors needed by GPT is 6, any medium that has less
|
||||
* than 6 sectors is never going to be able to hold a GPT. The
|
||||
* number 6 comes from:
|
||||
* 1 sector for the PMBR
|
||||
* 2 sectors for the GPT headers (each 1 sector)
|
||||
* 2 sectors for the GPT tables (each 1 sector)
|
||||
* 1 sector for an actual partition
|
||||
* It's better to catch this pathological case early than behaving
|
||||
* pathologically later on...
|
||||
*/
|
||||
if (pp->sectorsize < 512 || pp->mediasize < 6 * pp->sectorsize)
|
||||
return (ENOSPC);
|
||||
|
||||
/* Check that there's a MBR. */
|
||||
buf = g_read_data(cp, 0L, pp->sectorsize, &error);
|
||||
if (buf == NULL)
|
||||
return (error);
|
||||
res = le16dec(buf + DOSMAGICOFFSET);
|
||||
g_free(buf);
|
||||
if (res != DOSMAGIC)
|
||||
return (ENXIO);
|
||||
|
||||
/* Check that there's a primary header. */
|
||||
buf = g_read_data(cp, pp->sectorsize, pp->sectorsize, &error);
|
||||
if (buf == NULL)
|
||||
return (error);
|
||||
res = memcmp(buf, GPT_HDR_SIG, 8);
|
||||
g_free(buf);
|
||||
if (res == 0)
|
||||
return (G_PART_PROBE_PRI_HIGH);
|
||||
|
||||
/* No primary? Check that there's a secondary. */
|
||||
buf = g_read_data(cp, pp->mediasize - pp->sectorsize, pp->sectorsize,
|
||||
&error);
|
||||
if (buf == NULL)
|
||||
return (error);
|
||||
res = memcmp(buf, GPT_HDR_SIG, 8);
|
||||
g_free(buf);
|
||||
return ((res == 0) ? G_PART_PROBE_PRI_HIGH : ENXIO);
|
||||
}
|
||||
|
||||
static int
|
||||
g_part_gpt_read(struct g_part_table *basetable, struct g_consumer *cp)
|
||||
{
|
||||
struct gpt_hdr prihdr, sechdr;
|
||||
struct gpt_ent *tbl, *pritbl, *sectbl;
|
||||
struct g_provider *pp;
|
||||
struct g_part_gpt_table *table;
|
||||
struct g_part_gpt_entry *entry;
|
||||
int index;
|
||||
|
||||
table = (struct g_part_gpt_table *)basetable;
|
||||
pp = cp->provider;
|
||||
|
||||
/* Read the primary header and table. */
|
||||
gpt_read_hdr(table, cp, GPT_ELT_PRIHDR, &prihdr);
|
||||
if (table->state[GPT_ELT_PRIHDR] == GPT_STATE_OK) {
|
||||
pritbl = gpt_read_tbl(table, cp, GPT_ELT_PRITBL, &prihdr);
|
||||
} else {
|
||||
table->state[GPT_ELT_PRITBL] = GPT_STATE_MISSING;
|
||||
pritbl = NULL;
|
||||
}
|
||||
|
||||
/* Read the secondary header and table. */
|
||||
gpt_read_hdr(table, cp, GPT_ELT_SECHDR, &sechdr);
|
||||
if (table->state[GPT_ELT_SECHDR] == GPT_STATE_OK) {
|
||||
sectbl = gpt_read_tbl(table, cp, GPT_ELT_SECTBL, &sechdr);
|
||||
} else {
|
||||
table->state[GPT_ELT_SECTBL] = GPT_STATE_MISSING;
|
||||
sectbl = NULL;
|
||||
}
|
||||
|
||||
/* Fail if we haven't got any good tables at all. */
|
||||
if (table->state[GPT_ELT_PRITBL] != GPT_STATE_OK &&
|
||||
table->state[GPT_ELT_SECTBL] != GPT_STATE_OK) {
|
||||
printf("GEOM: %s: corrupt or invalid GPT detected.\n",
|
||||
pp->name);
|
||||
printf("GEOM: %s: GPT rejected -- may not be recoverable.\n",
|
||||
pp->name);
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
/*
|
||||
* If both headers are good but they disagree with each other,
|
||||
* then invalidate one. We prefer to keep the primary header,
|
||||
* unless the primary table is corrupt.
|
||||
*/
|
||||
if (table->state[GPT_ELT_PRIHDR] == GPT_STATE_OK &&
|
||||
table->state[GPT_ELT_SECHDR] == GPT_STATE_OK &&
|
||||
!gpt_matched_hdrs(&prihdr, &sechdr)) {
|
||||
if (table->state[GPT_ELT_PRITBL] == GPT_STATE_OK)
|
||||
table->state[GPT_ELT_SECHDR] = GPT_STATE_INVALID;
|
||||
else
|
||||
table->state[GPT_ELT_PRIHDR] = GPT_STATE_INVALID;
|
||||
}
|
||||
|
||||
if (table->state[GPT_ELT_PRIHDR] != GPT_STATE_OK) {
|
||||
printf("GEOM: %s: the primary GPT table is corrupt or "
|
||||
"invalid.\n", pp->name);
|
||||
printf("GEOM: %s: using the secondary instead -- recovery "
|
||||
"strongly advised.\n", pp->name);
|
||||
table->hdr = sechdr;
|
||||
tbl = sectbl;
|
||||
if (pritbl != NULL)
|
||||
g_free(pritbl);
|
||||
} else {
|
||||
if (table->state[GPT_ELT_SECHDR] != GPT_STATE_OK) {
|
||||
printf("GEOM: %s: the secondary GPT table is corrupt "
|
||||
"or invalid.\n", pp->name);
|
||||
printf("GEOM: %s: using the primary only -- recovery "
|
||||
"suggested.\n", pp->name);
|
||||
}
|
||||
table->hdr = prihdr;
|
||||
tbl = pritbl;
|
||||
if (sectbl != NULL)
|
||||
g_free(sectbl);
|
||||
}
|
||||
|
||||
basetable->gpt_first = table->hdr.hdr_lba_start;
|
||||
basetable->gpt_last = table->hdr.hdr_lba_end;
|
||||
basetable->gpt_entries = table->hdr.hdr_entries;
|
||||
|
||||
for (index = basetable->gpt_entries - 1; index >= 0; index--) {
|
||||
if (EQUUID(&tbl[index].ent_type, &gpt_uuid_unused))
|
||||
continue;
|
||||
entry = (struct g_part_gpt_entry *)g_part_new_entry(basetable,
|
||||
index+1, tbl[index].ent_lba_start, tbl[index].ent_lba_end);
|
||||
entry->ent = tbl[index];
|
||||
}
|
||||
|
||||
g_free(tbl);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static const char *
|
||||
g_part_gpt_type(struct g_part_table *basetable, struct g_part_entry *baseentry,
|
||||
char *buf, size_t bufsz)
|
||||
{
|
||||
struct g_part_gpt_entry *entry;
|
||||
struct uuid *type;
|
||||
|
||||
entry = (struct g_part_gpt_entry *)baseentry;
|
||||
type = &entry->ent.ent_type;
|
||||
if (EQUUID(type, &gpt_uuid_efi))
|
||||
return (g_part_alias_name(G_PART_ALIAS_EFI));
|
||||
if (EQUUID(type, &gpt_uuid_freebsd))
|
||||
return (g_part_alias_name(G_PART_ALIAS_FREEBSD));
|
||||
if (EQUUID(type, &gpt_uuid_freebsd_swap))
|
||||
return (g_part_alias_name(G_PART_ALIAS_FREEBSD_SWAP));
|
||||
if (EQUUID(type, &gpt_uuid_freebsd_ufs))
|
||||
return (g_part_alias_name(G_PART_ALIAS_FREEBSD_UFS));
|
||||
if (EQUUID(type, &gpt_uuid_freebsd_vinum))
|
||||
return (g_part_alias_name(G_PART_ALIAS_FREEBSD_VINUM));
|
||||
if (EQUUID(type, &gpt_uuid_mbr))
|
||||
return (g_part_alias_name(G_PART_ALIAS_MBR));
|
||||
snprintf_uuid(buf, bufsz, type);
|
||||
return (buf);
|
||||
}
|
||||
|
||||
static int
|
||||
g_part_gpt_write(struct g_part_table *basetable, struct g_consumer *cp)
|
||||
{
|
||||
unsigned char *buf, *bp;
|
||||
struct g_provider *pp;
|
||||
struct g_part_entry *baseentry;
|
||||
struct g_part_gpt_entry *entry;
|
||||
struct g_part_gpt_table *table;
|
||||
size_t tlbsz;
|
||||
uint32_t crc;
|
||||
int error, index;
|
||||
|
||||
pp = cp->provider;
|
||||
table = (struct g_part_gpt_table *)basetable;
|
||||
tlbsz = (table->hdr.hdr_entries * table->hdr.hdr_entsz +
|
||||
pp->sectorsize - 1) / pp->sectorsize;
|
||||
|
||||
if (basetable->gpt_created) {
|
||||
buf = g_malloc(pp->sectorsize, M_WAITOK | M_ZERO);
|
||||
le16enc(buf + DOSMAGICOFFSET, DOSMAGIC);
|
||||
buf[DOSPARTOFF + 1] = 0xff; /* shd */
|
||||
buf[DOSPARTOFF + 2] = 0xff; /* ssect */
|
||||
buf[DOSPARTOFF + 3] = 0xff; /* scyl */
|
||||
buf[DOSPARTOFF + 4] = 0xee; /* typ */
|
||||
buf[DOSPARTOFF + 5] = 0xff; /* ehd */
|
||||
buf[DOSPARTOFF + 6] = 0xff; /* esect */
|
||||
buf[DOSPARTOFF + 7] = 0xff; /* ecyl */
|
||||
le32enc(buf + DOSPARTOFF + 8, 1); /* start */
|
||||
le32enc(buf + DOSPARTOFF + 12,
|
||||
MIN(pp->mediasize / pp->sectorsize - 1, 0xffffffffLL));
|
||||
error = g_write_data(cp, 0, buf, pp->sectorsize);
|
||||
g_free(buf);
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
|
||||
/* Allocate space for the header and entries. */
|
||||
buf = g_malloc((tlbsz + 1) * pp->sectorsize, M_WAITOK | M_ZERO);
|
||||
|
||||
memcpy(buf, table->hdr.hdr_sig, sizeof(table->hdr.hdr_sig));
|
||||
le32enc(buf + 8, table->hdr.hdr_revision);
|
||||
le32enc(buf + 12, table->hdr.hdr_size);
|
||||
le64enc(buf + 40, table->hdr.hdr_lba_start);
|
||||
le64enc(buf + 48, table->hdr.hdr_lba_end);
|
||||
le_uuid_enc(buf + 56, &table->hdr.hdr_uuid);
|
||||
le32enc(buf + 80, table->hdr.hdr_entries);
|
||||
le32enc(buf + 84, table->hdr.hdr_entsz);
|
||||
|
||||
LIST_FOREACH(baseentry, &basetable->gpt_entry, gpe_entry) {
|
||||
entry = (struct g_part_gpt_entry *)baseentry;
|
||||
index = baseentry->gpe_index - 1;
|
||||
bp = buf + pp->sectorsize + table->hdr.hdr_entsz * index;
|
||||
le_uuid_enc(bp, &entry->ent.ent_type);
|
||||
le_uuid_enc(bp + 16, &entry->ent.ent_uuid);
|
||||
le64enc(bp + 32, entry->ent.ent_lba_start);
|
||||
le64enc(bp + 40, entry->ent.ent_lba_end);
|
||||
le64enc(bp + 48, entry->ent.ent_attr);
|
||||
memcpy(bp + 56, entry->ent.ent_name,
|
||||
sizeof(entry->ent.ent_name));
|
||||
}
|
||||
|
||||
crc = crc32(buf + pp->sectorsize,
|
||||
table->hdr.hdr_entries * table->hdr.hdr_entsz);
|
||||
le32enc(buf + 88, crc);
|
||||
|
||||
/* Write primary meta-data. */
|
||||
le32enc(buf + 16, 0); /* hdr_crc_self. */
|
||||
le64enc(buf + 24, table->lba[GPT_ELT_PRIHDR]); /* hdr_lba_self. */
|
||||
le64enc(buf + 32, table->lba[GPT_ELT_SECHDR]); /* hdr_lba_alt. */
|
||||
le64enc(buf + 72, table->lba[GPT_ELT_PRITBL]); /* hdr_lba_table. */
|
||||
crc = crc32(buf, table->hdr.hdr_size);
|
||||
le32enc(buf + 16, crc);
|
||||
|
||||
error = g_write_data(cp, table->lba[GPT_ELT_PRITBL] * pp->sectorsize,
|
||||
buf + pp->sectorsize, tlbsz * pp->sectorsize);
|
||||
if (error)
|
||||
goto out;
|
||||
error = g_write_data(cp, table->lba[GPT_ELT_PRIHDR] * pp->sectorsize,
|
||||
buf, pp->sectorsize);
|
||||
if (error)
|
||||
goto out;
|
||||
|
||||
/* Write secondary meta-data. */
|
||||
le32enc(buf + 16, 0); /* hdr_crc_self. */
|
||||
le64enc(buf + 24, table->lba[GPT_ELT_SECHDR]); /* hdr_lba_self. */
|
||||
le64enc(buf + 32, table->lba[GPT_ELT_PRIHDR]); /* hdr_lba_alt. */
|
||||
le64enc(buf + 72, table->lba[GPT_ELT_SECTBL]); /* hdr_lba_table. */
|
||||
crc = crc32(buf, table->hdr.hdr_size);
|
||||
le32enc(buf + 16, crc);
|
||||
|
||||
error = g_write_data(cp, table->lba[GPT_ELT_SECTBL] * pp->sectorsize,
|
||||
buf + pp->sectorsize, tlbsz * pp->sectorsize);
|
||||
if (error)
|
||||
goto out;
|
||||
error = g_write_data(cp, table->lba[GPT_ELT_SECHDR] * pp->sectorsize,
|
||||
buf, pp->sectorsize);
|
||||
|
||||
out:
|
||||
g_free(buf);
|
||||
return (error);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
g_gpt_to_utf8(struct sbuf *sb, uint16_t *str, size_t len)
|
||||
{
|
||||
u_int bo;
|
||||
uint32_t ch;
|
||||
uint16_t c;
|
||||
|
||||
bo = BYTE_ORDER;
|
||||
while (len > 0 && *str != 0) {
|
||||
ch = (bo == BIG_ENDIAN) ? be16toh(*str) : le16toh(*str);
|
||||
str++, len--;
|
||||
if ((ch & 0xf800) == 0xd800) {
|
||||
if (len > 0) {
|
||||
c = (bo == BIG_ENDIAN) ? be16toh(*str)
|
||||
: le16toh(*str);
|
||||
str++, len--;
|
||||
} else
|
||||
c = 0xfffd;
|
||||
if ((ch & 0x400) == 0 && (c & 0xfc00) == 0xdc00) {
|
||||
ch = ((ch & 0x3ff) << 10) + (c & 0x3ff);
|
||||
ch += 0x10000;
|
||||
} else
|
||||
ch = 0xfffd;
|
||||
} else if (ch == 0xfffe) { /* BOM (U+FEFF) swapped. */
|
||||
bo = (bo == BIG_ENDIAN) ? LITTLE_ENDIAN : BIG_ENDIAN;
|
||||
continue;
|
||||
} else if (ch == 0xfeff) /* BOM (U+FEFF) unswapped. */
|
||||
continue;
|
||||
|
||||
if (ch < 0x80)
|
||||
sbuf_printf(sb, "%c", ch);
|
||||
else if (ch < 0x800)
|
||||
sbuf_printf(sb, "%c%c", 0xc0 | (ch >> 6),
|
||||
0x80 | (ch & 0x3f));
|
||||
else if (ch < 0x10000)
|
||||
sbuf_printf(sb, "%c%c%c", 0xe0 | (ch >> 12),
|
||||
0x80 | ((ch >> 6) & 0x3f), 0x80 | (ch & 0x3f));
|
||||
else if (ch < 0x200000)
|
||||
sbuf_printf(sb, "%c%c%c%c", 0xf0 | (ch >> 18),
|
||||
0x80 | ((ch >> 12) & 0x3f),
|
||||
0x80 | ((ch >> 6) & 0x3f), 0x80 | (ch & 0x3f));
|
||||
}
|
||||
}
|
||||
#endif
|
117
sys/geom/part/g_part_if.m
Normal file
117
sys/geom/part/g_part_if.m
Normal file
@ -0,0 +1,117 @@
|
||||
#-
|
||||
# Copyright (c) 2006, 2007 Marcel Moolenaar
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# $FreeBSD$
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/sbuf.h>
|
||||
#include <sys/bus.h>
|
||||
#include <machine/bus.h>
|
||||
#include <geom/geom.h>
|
||||
#include <geom/part/g_part.h>
|
||||
|
||||
# The G_PART scheme interface.
|
||||
|
||||
INTERFACE g_part;
|
||||
|
||||
# add() - scheme specific processing for the add verb.
|
||||
METHOD int add {
|
||||
struct g_part_table *table;
|
||||
struct g_part_entry *entry;
|
||||
struct g_part_parms *gpp;
|
||||
};
|
||||
|
||||
# create() - scheme specific processing for the create verb.
|
||||
METHOD int create {
|
||||
struct g_part_table *table;
|
||||
struct g_part_parms *gpp;
|
||||
};
|
||||
|
||||
# destroy() - scheme specific processing for the destroy verb.
|
||||
METHOD int destroy {
|
||||
struct g_part_table *table;
|
||||
struct g_part_parms *gpp;
|
||||
};
|
||||
|
||||
# dumpconf()
|
||||
METHOD void dumpconf {
|
||||
struct g_part_table *table;
|
||||
struct g_part_entry *entry;
|
||||
struct sbuf *sb;
|
||||
const char *indent;
|
||||
};
|
||||
|
||||
# dumpto() - return whether the partiton can be used for kernel dumps.
|
||||
METHOD int dumpto {
|
||||
struct g_part_table *table;
|
||||
struct g_part_entry *entry;
|
||||
};
|
||||
|
||||
# modify() - scheme specific processing for the modify verb.
|
||||
METHOD int modify {
|
||||
struct g_part_table *table;
|
||||
struct g_part_entry *entry;
|
||||
struct g_part_parms *gpp;
|
||||
};
|
||||
|
||||
# name() - return the name of the given partition entry.
|
||||
# Typical names are "p1", "s0" or "c".
|
||||
METHOD const char * name {
|
||||
struct g_part_table *table;
|
||||
struct g_part_entry *entry;
|
||||
char *buf;
|
||||
size_t bufsz;
|
||||
};
|
||||
|
||||
# probe() - probe the provider attached to the given consumer for the
|
||||
# existence of the scheme implemented by the G_PART interface handler.
|
||||
METHOD int probe {
|
||||
struct g_part_table *table;
|
||||
struct g_consumer *cp;
|
||||
};
|
||||
|
||||
# read() - read the on-disk partition table into memory.
|
||||
METHOD int read {
|
||||
struct g_part_table *table;
|
||||
struct g_consumer *cp;
|
||||
};
|
||||
|
||||
# type() - return a string representation of the partition type.
|
||||
# Preferrably, the alias names.
|
||||
METHOD const char * type {
|
||||
struct g_part_table *table;
|
||||
struct g_part_entry *entry;
|
||||
char *buf;
|
||||
size_t bufsz;
|
||||
};
|
||||
|
||||
# write() - write the in-memory partition table to disk.
|
||||
METHOD int write {
|
||||
struct g_part_table *table;
|
||||
struct g_consumer *cp;
|
||||
};
|
@ -44,7 +44,7 @@ options MSDOSFS # MSDOS Filesystem
|
||||
options CD9660 # ISO 9660 Filesystem
|
||||
options PROCFS # Process filesystem (requires PSEUDOFS)
|
||||
options PSEUDOFS # Pseudo-filesystem framework
|
||||
options GEOM_GPT # GUID Partition Tables.
|
||||
options GEOM_PART_GPT # GUID Partition Tables.
|
||||
options COMPAT_43TTY # BSD 4.3 TTY compat [KEEP THIS!]
|
||||
options COMPAT_FREEBSD4 # Compatible with FreeBSD4
|
||||
options COMPAT_FREEBSD5 # Compatible with FreeBSD5
|
||||
|
@ -15,8 +15,8 @@ device mem # Memory and kernel memory devices
|
||||
device uart_ns8250
|
||||
|
||||
options GEOM_BSD
|
||||
options GEOM_GPT
|
||||
options GEOM_MBR
|
||||
options GEOM_PART_GPT
|
||||
|
||||
# KSE support went from being default to a kernel option
|
||||
options KSE
|
||||
|
@ -44,7 +44,7 @@ options MSDOSFS # MSDOS Filesystem
|
||||
options CD9660 # ISO 9660 Filesystem
|
||||
options PROCFS # Process filesystem (requires PSEUDOFS)
|
||||
options PSEUDOFS # Pseudo-filesystem framework
|
||||
options GEOM_GPT # GUID Partition Tables.
|
||||
options GEOM_PART_GPT # GUID Partition Tables.
|
||||
options COMPAT_43TTY # BSD 4.3 TTY compat [KEEP THIS!]
|
||||
options COMPAT_FREEBSD4 # Compatible with FreeBSD4
|
||||
options COMPAT_FREEBSD5 # Compatible with FreeBSD5
|
||||
|
@ -12,5 +12,7 @@ device mem # Memory and kernel memory devices
|
||||
device uart_ns8250
|
||||
device uart_z8530
|
||||
|
||||
options GEOM_PART_APM
|
||||
|
||||
# KSE support went from being default to a kernel option
|
||||
options KSE
|
||||
|
@ -45,7 +45,7 @@ options MSDOSFS #MSDOS Filesystem
|
||||
options CD9660 #ISO 9660 Filesystem
|
||||
options PROCFS #Process filesystem (requires PSEUDOFS)
|
||||
options PSEUDOFS #Pseudo-filesystem framework
|
||||
options GEOM_GPT #GUID Partition Tables.
|
||||
options GEOM_PART_GPT #GUID Partition Tables.
|
||||
options COMPAT_43TTY #BSD 4.3 TTY compat [KEEP THIS!]
|
||||
options COMPAT_FREEBSD4 #Keep this for a while
|
||||
options COMPAT_FREEBSD5 #Compatible with FreeBSD5
|
||||
|
@ -47,7 +47,7 @@ options NFS_ROOT # NFS usable as /, requires NFSCLIENT
|
||||
options CD9660 # ISO 9660 Filesystem
|
||||
options PROCFS # Process filesystem (requires PSEUDOFS)
|
||||
options PSEUDOFS # Pseudo-filesystem framework
|
||||
options GEOM_GPT # GUID Partition Tables.
|
||||
options GEOM_PART_GPT # GUID Partition Tables.
|
||||
options COMPAT_43TTY # BSD 4.3 TTY compat [KEEP THIS!]
|
||||
options COMPAT_FREEBSD5 # Compatible with FreeBSD5
|
||||
options COMPAT_FREEBSD6 # Compatible with FreeBSD6
|
||||
|
@ -46,7 +46,7 @@ options NULLFS
|
||||
options CD9660 # ISO 9660 Filesystem
|
||||
options PROCFS # Process filesystem (requires PSEUDOFS)
|
||||
options PSEUDOFS # Pseudo-filesystem framework
|
||||
options GEOM_GPT # GUID Partition Tables.
|
||||
options GEOM_PART_GPT # GUID Partition Tables.
|
||||
options COMPAT_43 # Compatible with BSD 4.3 [KEEP THIS!]
|
||||
options COMPAT_43TTY # BSD 4.3 TTY compat [KEEP THIS!]
|
||||
options COMPAT_FREEBSD5 # Compatible with FreeBSD5
|
||||
|
62
sys/sys/apm.h
Normal file
62
sys/sys/apm.h
Normal file
@ -0,0 +1,62 @@
|
||||
/*-
|
||||
* Copyright (c) 2007 Marcel Moolenaar
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _SYS_APM_H_
|
||||
#define _SYS_APM_H_
|
||||
|
||||
/* Driver Descriptor Record. */
|
||||
struct apm_ddr {
|
||||
uint16_t ddr_sig;
|
||||
#define APM_DDR_SIG 0x4552
|
||||
uint16_t ddr_blksize;
|
||||
uint32_t ddr_blkcount;
|
||||
};
|
||||
|
||||
/* Partition Map Entry Record. */
|
||||
struct apm_ent {
|
||||
uint16_t ent_sig;
|
||||
#define APM_ENT_SIG 0x504d
|
||||
uint16_t _pad_;
|
||||
uint32_t ent_pmblkcnt;
|
||||
uint32_t ent_start;
|
||||
uint32_t ent_size;
|
||||
char ent_name[32];
|
||||
char ent_type[32];
|
||||
};
|
||||
|
||||
#define APM_ENT_TYPE_SELF "Apple_partition_map"
|
||||
#define APM_ENT_TYPE_UNUSED "Apple_Free"
|
||||
|
||||
#define APM_ENT_TYPE_FREEBSD "FreeBSD"
|
||||
#define APM_ENT_TYPE_FREEBSD_SWAP "FreeBSD-swap"
|
||||
#define APM_ENT_TYPE_FREEBSD_UFS "FreeBSD-UFS"
|
||||
#define APM_ENT_TYPE_FREEBSD_VINUM "FreeBSD-Vinum"
|
||||
|
||||
#define APM_ENT_TYPE_APPLE_HFS "Apple_HFS"
|
||||
|
||||
#endif /* _SYS_APM_H_ */
|
Loading…
x
Reference in New Issue
Block a user