Geert Stappers
2014-Jun-24 04:19 UTC
[syslinux] [syslinux:master] isohybrid: Function to write UTF-16LE strings
Op 2014-06-23 om 20:09 schreef syslinux-bot for H. Peter Anvin:> Commit-ID: f9dad5340bcefe34d860e991e8743be01a4d6c3c > Gitweb: http://www.syslinux.org/commit/f9dad5340bcefe34d860e991e8743be01a4d6c3c > Author: H. Peter Anvin <hpa at zytor.com> > AuthorDate: Mon, 23 Jun 2014 20:06:51 -0700 > Committer: H. Peter Anvin <hpa at zytor.com> > CommitDate: Mon, 23 Jun 2014 20:06:51 -0700 > > isohybrid: Function to write UTF-16LE strings > > Rather than open-coding the content of UTF-16LE strings, just add a > simple function to convert ASCII (only) strings to UTF-16LE. > > Signed-off-by: H. Peter Anvin <hpa at zytor.com> > > --- > utils/isohybrid.c | 28 +++++++++++++++++++--------- > 1 file changed, 19 insertions(+), 9 deletions(-) > > diff --git a/utils/isohybrid.c b/utils/isohybrid.c > index 0011b78..e308a82 100644 > --- a/utils/isohybrid.c > +++ b/utils/isohybrid.c > @@ -593,7 +593,7 @@ read_mbr_template(char *path, uint8_t *mbr) > err(1, "could not open MBR template file `%s'", path); > clearerr(fp); > ret = fread(mbr, 1, MBRSIZE, fp); > - if (ferror(fp)) > + if (ferror(fp) || ret != MBRSIZE) > err(1, "error while reading MBR template file `%s'", path); > fclose(fp); > }Shouldn't that be in a separate commit?> @@ -786,6 +786,21 @@ reverse_uuid(uuid_t uuid) > t = p[6]; p[6] = p[7]; p[7] = t; > } > > +static uint16_t * > +ascii_to_utf16le(uint16_t *dst, const char *src) > +{ > + uint8_t *p = (uint8_t *)dst; > + char c; > + > + do { > + c = *src++; > + *p++ = c; > + *p++ = 0; > + } while (c); > + > + return (uint16_t *)p; > +} > + > void > initialise_gpt(uint8_t *gpt, uint32_t current, uint32_t alternate, int primary) > { > @@ -793,11 +808,6 @@ initialise_gpt(uint8_t *gpt, uint32_t current, uint32_t alternate, int primary) > struct gpt_part_header *part; > int hole = 0; > int gptsize = 128 / 4 + 2; > - char part_name_iso[] = {'I', 0, 'S', 0, 'O', 0, 'H', 0, 'y', 0, > - 'b', 0, 'r', 0, 'i', 0, 'd', 0, ' ', 0, > - 'I', 0, 'S', 0, 'O', 0, 0, 0}; > - char part_name_bootimg[]= {'I', 0, 'S', 0, 'O', 0, 'H', 0, 'y', 0, > - 'b', 0, 'r', 0, 'i', 0, 'd', 0, 0, 0}; > > if (mac_lba) { > /* 2048 bytes per partition, plus round to 2048 boundary */ > @@ -842,7 +852,7 @@ initialise_gpt(uint8_t *gpt, uint32_t current, uint32_t alternate, int primary) > memcpy(part->partTypeGUID, basic_partition, sizeof(uuid_t)); > part->firstLBA = lendian_64(0); > part->lastLBA = lendian_64(psize - 1); > - memcpy(part->name, part_name_iso, 28); > + ascii_to_utf16le(part->name, "ISOHybrid ISO"); > > gpt += sizeof(struct gpt_part_header); > part++; > @@ -851,7 +861,7 @@ initialise_gpt(uint8_t *gpt, uint32_t current, uint32_t alternate, int primary) > memcpy(part->partTypeGUID, basic_partition, sizeof(uuid_t)); > part->firstLBA = lendian_64(efi_lba * 4); > part->lastLBA = lendian_64(part->firstLBA + efi_count - 1); > - memcpy(part->name, part_name_bootimg, 20); > + ascii_to_utf16le(part->name, "ISOHybrid"); > > gpt += sizeof(struct gpt_part_header); > > @@ -864,7 +874,7 @@ initialise_gpt(uint8_t *gpt, uint32_t current, uint32_t alternate, int primary) > memcpy(part->partTypeGUID, hfs_partition, sizeof(uuid_t)); > part->firstLBA = lendian_64(mac_lba * 4); > part->lastLBA = lendian_64(part->firstLBA + mac_count - 1); > - memcpy(part->name, part_name_bootimg, 20); > + ascii_to_utf16le(part->name, "ISOHybrid"); > > part--; > } > _______________________________________________ > Syslinux-commits mailing list > Syslinux-commits at zytor.com > http://www.zytor.com/mailman/listinfo/syslinux-commits-- Groeten Geert Stappers -- Leven en laten leven
H. Peter Anvin
2014-Jun-24 04:23 UTC
[syslinux] [syslinux:master] isohybrid: Function to write UTF-16LE strings
On 06/23/2014 09:19 PM, Geert Stappers wrote:>> diff --git a/utils/isohybrid.c b/utils/isohybrid.c >> index 0011b78..e308a82 100644 >> --- a/utils/isohybrid.c >> +++ b/utils/isohybrid.c >> @@ -593,7 +593,7 @@ read_mbr_template(char *path, uint8_t *mbr) >> err(1, "could not open MBR template file `%s'", path); >> clearerr(fp); >> ret = fread(mbr, 1, MBRSIZE, fp); >> - if (ferror(fp)) >> + if (ferror(fp) || ret != MBRSIZE) >> err(1, "error while reading MBR template file `%s'", path); >> fclose(fp); >> } > > Shouldn't that be in a separate commit? >Yes, it really should have been. -hpa
Geert Stappers
2014-Jun-24 04:41 UTC
[syslinux] [syslinux:master] isohybrid: Function to write UTF-16LE strings
Op 2014-06-23 om 21:23 schreef H. Peter Anvin:> On 06/23/2014 09:19 PM, Geert Stappers wrote: > >> diff --git a/utils/isohybrid.c b/utils/isohybrid.c > >> index 0011b78..e308a82 100644 > >> --- a/utils/isohybrid.c > >> +++ b/utils/isohybrid.c > >> @@ -593,7 +593,7 @@ read_mbr_template(char *path, uint8_t *mbr) > >> err(1, "could not open MBR template file `%s'", path); > >> clearerr(fp); > >> ret = fread(mbr, 1, MBRSIZE, fp); > >> - if (ferror(fp)) > >> + if (ferror(fp) || ret != MBRSIZE) > >> err(1, "error while reading MBR template file `%s'", path); > >> fclose(fp); > >> } > > > > Shouldn't that be in a separate commit? > > > > Yes, it really should have been. >git commit --amend to amend the last commit message Groeten Geert Stappers -- Leven en laten leven
Seemingly Similar Threads
- [PATCH 1/6] utils/isohybrid.c: Encode GPT partition names as UTF-16LE
- isolinux: Generate GPT and Mac bootable images
- Announcing a patch series for isohybrid.c
- [PATCH 3/6] utils/isohybrid.c: Correct end block address of first GPT partition
- isohybrid.c, problem reports and questions