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); } _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"