From owner-p4-projects Sat May 25 23:41:49 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 6C13437B401; Sat, 25 May 2002 23:41:43 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id A68FE37B406 for ; Sat, 25 May 2002 23:41:42 -0700 (PDT) Received: (from perforce@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g4Q6fgZ58054 for perforce@freebsd.org; Sat, 25 May 2002 23:41:42 -0700 (PDT) (envelope-from marcel@freebsd.org) Date: Sat, 25 May 2002 23:41:42 -0700 (PDT) Message-Id: <200205260641.g4Q6fgZ58054@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar Subject: PERFORCE change 11896 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://people.freebsd.org/~peter/p4db/chv.cgi?CH=11896 Change 11896 by marcel@marcel_vaio on 2002/05/25 23:40:42 Properly write the unicode name in the GPT entry. Internally we use 32-bit wide characters. The GPT entry uses 16-bit characters. Use 'short' as the base type for the name array and add a simple conversion function 'unicode16()' to map from wchar_t to short. I believe the unicode characters fit in 16 bit integrals, so I don't expect to loose information when we truncate... Affected files ... ... //depot/projects/ia64/sbin/gpt/gpt.c#3 edit ... //depot/projects/ia64/sbin/gpt/gpt.h#2 edit Differences ... ==== //depot/projects/ia64/sbin/gpt/gpt.c#3 (text+ko) ==== @@ -160,6 +160,15 @@ } static void +unicode16(short *dst, const wchar_t *src, size_t len) +{ + while (len-- && *src != 0) + *dst++ = *src++; + if (len) + *dst = 0; +} + +static void usage(void) { @@ -504,7 +513,7 @@ size = (size << 16) + mbr->mbr_part[i].part_size_lo; ent->ent_lba_start = start; ent->ent_lba_end = start + size - 1LL; - strcpy(ent->ent_name, "FreeBSD slice"); + unicode16(ent->ent_name, L"FreeBSD slice", 36); ent++; } ent = tbl->map_data; ==== //depot/projects/ia64/sbin/gpt/gpt.h#2 (text+ko) ==== @@ -55,7 +55,7 @@ uint64_t ent_lba_end; uint64_t ent_attr; #define GPT_ENT_ATTR_PLATFORM (1ULL << 0) - char ent_name[72]; /* UNICODE!!! */ + short ent_name[36]; /* UNICODE!!! */ }; #define GPT_ENT_TYPE_UNUSED \ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message