Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 19 Feb 2011 11:09:38 +0000 (UTC)
From:      Takahashi Yoshihiro <nyan@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r218845 - head/sys/geom/part
Message-ID:  <201102191109.p1JB9crL093778@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: nyan
Date: Sat Feb 19 11:09:38 2011
New Revision: 218845
URL: http://svn.freebsd.org/changeset/base/218845

Log:
  Add support to set a slice name.

Modified:
  head/sys/geom/part/g_part_pc98.c

Modified: head/sys/geom/part/g_part_pc98.c
==============================================================================
--- head/sys/geom/part/g_part_pc98.c	Sat Feb 19 11:06:00 2011	(r218844)
+++ head/sys/geom/part/g_part_pc98.c	Sat Feb 19 11:09:38 2011	(r218845)
@@ -140,6 +140,20 @@ pc98_parse_type(const char *type, u_char
 	return (EINVAL);
 }
 
+static int
+pc98_set_slicename(const char *label, u_char *dp_name)
+{
+	int len;
+
+	len = strlen(label);
+	if (len > sizeof(((struct pc98_partition *)NULL)->dp_name))
+		return (EINVAL);
+	bzero(dp_name, sizeof(((struct pc98_partition *)NULL)->dp_name));
+	strncpy(dp_name, label, len);
+
+	return (0);
+}
+
 static void
 pc98_set_chs(struct g_part_table *table, uint32_t lba, u_short *cylp,
     u_char *hdp, u_char *secp)
@@ -164,9 +178,7 @@ g_part_pc98_add(struct g_part_table *bas
 	struct g_part_pc98_entry *entry;
 	struct g_part_pc98_table *table;
 	uint32_t cyl, start, size;
-
-	if (gpp->gpp_parms & G_PART_PARM_LABEL)
-		return (EINVAL);
+	int error;
 
 	cyl = basetable->gpt_heads * basetable->gpt_sectors;
 
@@ -199,8 +211,16 @@ g_part_pc98_add(struct g_part_table *bas
 	    &entry->ent.dp_shd, &entry->ent.dp_ssect);
 	pc98_set_chs(basetable, baseentry->gpe_end, &entry->ent.dp_ecyl,
 	    &entry->ent.dp_ehd, &entry->ent.dp_esect);
-	return (pc98_parse_type(gpp->gpp_type, &entry->ent.dp_mid,
-	    &entry->ent.dp_sid));
+
+	error = pc98_parse_type(gpp->gpp_type, &entry->ent.dp_mid,
+	    &entry->ent.dp_sid);
+	if (error)
+		return (error);
+
+	if (gpp->gpp_parms & G_PART_PARM_LABEL)
+		return (pc98_set_slicename(gpp->gpp_label, entry->ent.dp_name));
+
+	return (0);
 }
 
 static int
@@ -231,7 +251,7 @@ g_part_pc98_create(struct g_part_table *
 	pp = gpp->gpp_provider;
 	cp = LIST_FIRST(&pp->consumers);
 
-	if (pp->sectorsize < SECSIZE || pp->mediasize < 2 * SECSIZE)
+	if (pp->sectorsize < SECSIZE || pp->mediasize < BOOTSIZE)
 		return (ENOSPC);
 	if (pp->sectorsize > SECSIZE)
 		return (ENXIO);
@@ -305,14 +325,20 @@ g_part_pc98_modify(struct g_part_table *
     struct g_part_entry *baseentry, struct g_part_parms *gpp)
 {
 	struct g_part_pc98_entry *entry;
+	int error;
+
+	entry = (struct g_part_pc98_entry *)baseentry;
+
+	if (gpp->gpp_parms & G_PART_PARM_TYPE) {
+		error = pc98_parse_type(gpp->gpp_type, &entry->ent.dp_mid,
+		    &entry->ent.dp_sid);
+		if (error)
+			return (error);
+	}
 
 	if (gpp->gpp_parms & G_PART_PARM_LABEL)
-		return (EINVAL);
+		return (pc98_set_slicename(gpp->gpp_label, entry->ent.dp_name));
 
-	entry = (struct g_part_pc98_entry *)baseentry;
-	if (gpp->gpp_parms & G_PART_PARM_TYPE)
-		return (pc98_parse_type(gpp->gpp_type, &entry->ent.dp_mid,
-		    &entry->ent.dp_sid));
 	return (0);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201102191109.p1JB9crL093778>