Skip to content

Commit f24a822

Browse files
Marcel MoolenaarMarcel Moolenaar
authored andcommitted
Add a partition type for nandfs to the apm, bsd, gpt and vtoc8 schemes.
The gpart alias for these partition types is "freebsd-nandfs".
1 parent 3c52150 commit f24a822

10 files changed

Lines changed: 35 additions & 2 deletions

File tree

sys/geom/part/g_part.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ struct g_part_alias_list {
8383
{ "fat32", G_PART_ALIAS_MS_FAT32 },
8484
{ "freebsd", G_PART_ALIAS_FREEBSD },
8585
{ "freebsd-boot", G_PART_ALIAS_FREEBSD_BOOT },
86+
{ "freebsd-nandfs", G_PART_ALIAS_FREEBSD_NANDFS },
8687
{ "freebsd-swap", G_PART_ALIAS_FREEBSD_SWAP },
8788
{ "freebsd-ufs", G_PART_ALIAS_FREEBSD_UFS },
8889
{ "freebsd-vinum", G_PART_ALIAS_FREEBSD_VINUM },

sys/geom/part/g_part.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ enum g_part_alias {
4646
G_PART_ALIAS_EFI, /* A EFI system partition entry. */
4747
G_PART_ALIAS_FREEBSD, /* A BSD labeled partition entry. */
4848
G_PART_ALIAS_FREEBSD_BOOT, /* A FreeBSD boot partition entry. */
49+
G_PART_ALIAS_FREEBSD_NANDFS, /* A FreeBSD nandfs partition entry. */
4950
G_PART_ALIAS_FREEBSD_SWAP, /* A swap partition entry. */
5051
G_PART_ALIAS_FREEBSD_UFS, /* A UFS/UFS2 file system entry. */
5152
G_PART_ALIAS_FREEBSD_VINUM, /* A Vinum partition entry. */

sys/geom/part/g_part_apm.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ apm_parse_type(const char *type, char *buf, size_t bufsz)
159159
strcpy(buf, APM_ENT_TYPE_FREEBSD);
160160
return (0);
161161
}
162+
alias = g_part_alias_name(G_PART_ALIAS_FREEBSD_NANDFS);
163+
if (!strcasecmp(type, alias)) {
164+
strcpy(buf, APM_ENT_TYPE_FREEBSD_NANDFS);
165+
return (0);
166+
}
162167
alias = g_part_alias_name(G_PART_ALIAS_FREEBSD_SWAP);
163168
if (!strcasecmp(type, alias)) {
164169
strcpy(buf, APM_ENT_TYPE_FREEBSD_SWAP);
@@ -485,6 +490,8 @@ g_part_apm_type(struct g_part_table *basetable, struct g_part_entry *baseentry,
485490
return (g_part_alias_name(G_PART_ALIAS_APPLE_UFS));
486491
if (!strcmp(type, APM_ENT_TYPE_FREEBSD))
487492
return (g_part_alias_name(G_PART_ALIAS_FREEBSD));
493+
if (!strcmp(type, APM_ENT_TYPE_FREEBSD_NANDFS))
494+
return (g_part_alias_name(G_PART_ALIAS_FREEBSD_NANDFS));
488495
if (!strcmp(type, APM_ENT_TYPE_FREEBSD_SWAP))
489496
return (g_part_alias_name(G_PART_ALIAS_FREEBSD_SWAP));
490497
if (!strcmp(type, APM_ENT_TYPE_FREEBSD_UFS))

sys/geom/part/g_part_bsd.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ bsd_parse_type(const char *type, uint8_t *fstype)
126126
*fstype = (u_int)lt;
127127
return (0);
128128
}
129+
alias = g_part_alias_name(G_PART_ALIAS_FREEBSD_NANDFS);
130+
if (!strcasecmp(type, alias)) {
131+
*fstype = FS_NANDFS;
132+
return (0);
133+
}
129134
alias = g_part_alias_name(G_PART_ALIAS_FREEBSD_SWAP);
130135
if (!strcasecmp(type, alias)) {
131136
*fstype = FS_SWAP;
@@ -450,6 +455,8 @@ g_part_bsd_type(struct g_part_table *basetable, struct g_part_entry *baseentry,
450455

451456
entry = (struct g_part_bsd_entry *)baseentry;
452457
type = entry->part.p_fstype;
458+
if (type == FS_NANDFS)
459+
return (g_part_alias_name(G_PART_ALIAS_FREEBSD_NANDFS));
453460
if (type == FS_SWAP)
454461
return (g_part_alias_name(G_PART_ALIAS_FREEBSD_SWAP));
455462
if (type == FS_BSDFFS)

sys/geom/part/g_part_gpt.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ static struct uuid gpt_uuid_bios_boot = GPT_ENT_TYPE_BIOS_BOOT;
155155
static struct uuid gpt_uuid_efi = GPT_ENT_TYPE_EFI;
156156
static struct uuid gpt_uuid_freebsd = GPT_ENT_TYPE_FREEBSD;
157157
static struct uuid gpt_uuid_freebsd_boot = GPT_ENT_TYPE_FREEBSD_BOOT;
158+
static struct uuid gpt_uuid_freebsd_nandfs = GPT_ENT_TYPE_FREEBSD_NANDFS;
158159
static struct uuid gpt_uuid_freebsd_swap = GPT_ENT_TYPE_FREEBSD_SWAP;
159160
static struct uuid gpt_uuid_freebsd_ufs = GPT_ENT_TYPE_FREEBSD_UFS;
160161
static struct uuid gpt_uuid_freebsd_vinum = GPT_ENT_TYPE_FREEBSD_VINUM;
@@ -195,6 +196,7 @@ static struct g_part_uuid_alias {
195196
{ &gpt_uuid_efi, G_PART_ALIAS_EFI, 0xee },
196197
{ &gpt_uuid_freebsd, G_PART_ALIAS_FREEBSD, 0xa5 },
197198
{ &gpt_uuid_freebsd_boot, G_PART_ALIAS_FREEBSD_BOOT, 0 },
199+
{ &gpt_uuid_freebsd_nandfs, G_PART_ALIAS_FREEBSD_NANDFS, 0 },
198200
{ &gpt_uuid_freebsd_swap, G_PART_ALIAS_FREEBSD_SWAP, 0 },
199201
{ &gpt_uuid_freebsd_ufs, G_PART_ALIAS_FREEBSD_UFS, 0 },
200202
{ &gpt_uuid_freebsd_vinum, G_PART_ALIAS_FREEBSD_VINUM, 0 },

sys/geom/part/g_part_vtoc8.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ vtoc8_parse_type(const char *type, uint16_t *tag)
114114
*tag = (uint16_t)lt;
115115
return (0);
116116
}
117+
alias = g_part_alias_name(G_PART_ALIAS_FREEBSD_NANDFS);
118+
if (!strcasecmp(type, alias)) {
119+
*tag = VTOC_TAG_FREEBSD_NANDFS;
120+
return (0);
121+
}
117122
alias = g_part_alias_name(G_PART_ALIAS_FREEBSD_SWAP);
118123
if (!strcasecmp(type, alias)) {
119124
*tag = VTOC_TAG_FREEBSD_SWAP;
@@ -487,6 +492,8 @@ g_part_vtoc8_type(struct g_part_table *basetable, struct g_part_entry *entry,
487492

488493
table = (struct g_part_vtoc8_table *)basetable;
489494
tag = be16dec(&table->vtoc.part[entry->gpe_index - 1].tag);
495+
if (tag == VTOC_TAG_FREEBSD_NANDFS)
496+
return (g_part_alias_name(G_PART_ALIAS_FREEBSD_NANDFS));
490497
if (tag == VTOC_TAG_FREEBSD_SWAP)
491498
return (g_part_alias_name(G_PART_ALIAS_FREEBSD_SWAP));
492499
if (tag == VTOC_TAG_FREEBSD_UFS)

sys/sys/apm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ struct apm_ent {
5656
#define APM_ENT_TYPE_UNUSED "Apple_Free"
5757

5858
#define APM_ENT_TYPE_FREEBSD "FreeBSD"
59+
#define APM_ENT_TYPE_FREEBSD_NANDFS "FreeBSD-nandfs"
5960
#define APM_ENT_TYPE_FREEBSD_SWAP "FreeBSD-swap"
6061
#define APM_ENT_TYPE_FREEBSD_UFS "FreeBSD-UFS"
6162
#define APM_ENT_TYPE_FREEBSD_VINUM "FreeBSD-Vinum"

sys/sys/disklabel.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ static const char *dktypenames[] = {
232232
#define FS_UDF 24 /* UDF */
233233
#define FS_EFS 26 /* SGI's Extent File system */
234234
#define FS_ZFS 27 /* Sun's ZFS */
235+
#define FS_NANDFS 30 /* FreeBSD nandfs (NiLFS derived) */
235236

236237
#ifdef FSTYPENAMES
237238
static const char *fstypenames[] = {
@@ -263,6 +264,9 @@ static const char *fstypenames[] = {
263264
"?",
264265
"EFS",
265266
"ZFS",
267+
"?",
268+
"?",
269+
"nandfs",
266270
NULL
267271
};
268272
#define FSMAXTYPES (sizeof(fstypenames) / sizeof(fstypenames[0]) - 1)

sys/sys/gpt.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ struct gpt_ent {
7979
{0x024dee41,0x33e7,0x11d3,0x9d,0x69,{0x00,0x08,0xc7,0x81,0xf3,0x9f}}
8080
#define GPT_ENT_TYPE_FREEBSD \
8181
{0x516e7cb4,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
82+
#define GPT_ENT_TYPE_FREEBSD_BOOT \
83+
{0x83bd6b9d,0x7f41,0x11dc,0xbe,0x0b,{0x00,0x15,0x60,0xb8,0x4f,0x0f}}
84+
#define GPT_ENT_TYPE_FREEBSD_NANDFS \
85+
{0x74ba7dd9,0xa689,0x11e1,0xbd,0x04,{0x00,0xe0,0x81,0x28,0x6a,0xcf}}
8286
#define GPT_ENT_TYPE_FREEBSD_SWAP \
8387
{0x516e7cb5,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
8488
#define GPT_ENT_TYPE_FREEBSD_UFS \
@@ -87,8 +91,6 @@ struct gpt_ent {
8791
{0x516e7cb8,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
8892
#define GPT_ENT_TYPE_FREEBSD_ZFS \
8993
{0x516e7cba,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
90-
#define GPT_ENT_TYPE_FREEBSD_BOOT \
91-
{0x83bd6b9d,0x7f41,0x11dc,0xbe,0x0b,{0x00,0x15,0x60,0xb8,0x4f,0x0f}}
9294

9395
/*
9496
* The following are unused but documented here to avoid reuse.

sys/sys/vtoc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#define VTOC_TAG_FREEBSD_UFS 0x0902
5252
#define VTOC_TAG_FREEBSD_VINUM 0x0903
5353
#define VTOC_TAG_FREEBSD_ZFS 0x0904
54+
#define VTOC_TAG_FREEBSD_NANDFS 0x0905
5455

5556
#define VTOC_FLAG_UNMNT 0x01 /* unmountable partition */
5657
#define VTOC_FLAG_RDONLY 0x10 /* partition is read/only */

0 commit comments

Comments
 (0)