Allow wedges to be created for all defined partitions on a GPT disk.

Use __arraycount on the GUID to type mapping array.
Add HFS to the list of types with dkw_ptypes.

reviewed by cube.
This commit is contained in:
jakllsch 2008-10-23 19:37:40 +00:00
parent c6d8e2874c
commit 76a01a44a6
1 changed files with 16 additions and 22 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dkwedge_gpt.c,v 1.9 2008/06/29 15:13:28 christos Exp $ */
/* $NetBSD: dkwedge_gpt.c,v 1.10 2008/10/23 19:37:40 jakllsch Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dkwedge_gpt.c,v 1.9 2008/06/29 15:13:28 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: dkwedge_gpt.c,v 1.10 2008/10/23 19:37:40 jakllsch Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -47,14 +47,19 @@ __KERNEL_RCSID(0, "$NetBSD: dkwedge_gpt.c,v 1.9 2008/06/29 15:13:28 christos Exp
#include <sys/disklabel_gpt.h>
#include <sys/uuid.h>
/*
* GUID to dkw_ptype mapping information.
*
* GPT_ENT_TYPE_MS_BASIC_DATA is not suited to mapping. Aside from being
* used for multiple Microsoft file systems, Linux uses it for it's own
* set of native file systems. Treating this GUID as unknown seems best.
*/
static const struct {
struct uuid ptype_guid;
const char *ptype_str;
} gpt_ptype_guid_to_str_tab[] = {
{ GPT_ENT_TYPE_EFI, "msdos" }, /* XXX yes? */
#if 0
{ GPT_ENT_TYPE_FREEBSD, ??? },
#endif
{ GPT_ENT_TYPE_EFI, DKW_PTYPE_FAT },
{ GPT_ENT_TYPE_NETBSD_SWAP, DKW_PTYPE_SWAP },
{ GPT_ENT_TYPE_FREEBSD_SWAP, DKW_PTYPE_SWAP },
{ GPT_ENT_TYPE_NETBSD_FFS, DKW_PTYPE_FFS },
@ -64,10 +69,7 @@ static const struct {
{ GPT_ENT_TYPE_NETBSD_RAIDFRAME, DKW_PTYPE_RAIDFRAME },
{ GPT_ENT_TYPE_NETBSD_CCD, DKW_PTYPE_CCD },
{ GPT_ENT_TYPE_NETBSD_CGD, DKW_PTYPE_CGD },
/* XXX What about the MS and Linux types? */
{ { .time_low = 0 }, NULL },
{ GPT_ENT_TYPE_APPLE_HFS, DKW_PTYPE_APPLEHFS },
};
static const char *
@ -75,13 +77,13 @@ gpt_ptype_guid_to_str(const struct uuid *guid)
{
int i;
for (i = 0; gpt_ptype_guid_to_str_tab[i].ptype_str != NULL; i++) {
for (i = 0; i < __arraycount(gpt_ptype_guid_to_str_tab); i++) {
if (memcmp(&gpt_ptype_guid_to_str_tab[i].ptype_guid,
guid, sizeof(*guid)) == 0)
return (gpt_ptype_guid_to_str_tab[i].ptype_str);
}
return (NULL);
return (DKW_PTYPE_UNKNOWN);
}
static const uint32_t gpt_crc_tab[16] = {
@ -251,16 +253,8 @@ dkwedge_discover_gpt(struct disk *pdk, struct vnode *vp)
uuid_snprintf(ent_guid_str, sizeof(ent_guid_str),
&ent_guid);
/* Skip it if we don't grok this ptype. */
if ((ptype = gpt_ptype_guid_to_str(&ptype_guid)) == NULL) {
/*
* XXX Should probably just add these... maybe
* XXX just have an empty ptype?
*/
aprint_verbose("%s: skipping entry %u (%s), type %s\n",
pdk->dk_name, i, ent_guid_str, ptype_guid_str);
continue;
}
/* figure out the type */
ptype = gpt_ptype_guid_to_str(&ptype_guid);
strcpy(dkw.dkw_ptype, ptype);
strcpy(dkw.dkw_parent, pdk->dk_name);