Date: Sat, 25 May 2002 23:41:42 -0700 (PDT) From: Marcel Moolenaar <marcel@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 11896 for review Message-ID: <200205260641.g4Q6fgZ58054@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200205260641.g4Q6fgZ58054>