From 76df2068c469c25ea35d43d4a9f1c89aaa00dabe Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 14 Jan 2012 23:34:33 +0100 Subject: [PATCH] * grub-core/fs/hfs.c (macroman_to_utf8): Convert / to :. (utf8_to_macroman): Do the opposite. * grub-core/fs/hfsplus.c (grub_hfsplus_iterate_dir): Convert / to :. --- ChangeLog | 6 ++++++ grub-core/fs/hfs.c | 13 +++++++++++++ grub-core/fs/hfsplus.c | 9 ++++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 03fd8b808..391890587 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-01-14 Vladimir Serbinenko + + * grub-core/fs/hfs.c (macroman_to_utf8): Convert / to :. + (utf8_to_macroman): Do the opposite. + * grub-core/fs/hfsplus.c (grub_hfsplus_iterate_dir): Convert / to :. + 2012-01-14 Vladimir Serbinenko * configure.ac: Refise build qemu_mips w/o unifont. diff --git a/grub-core/fs/hfs.c b/grub-core/fs/hfs.c index 6a86e2e7d..c14a884cc 100644 --- a/grub-core/fs/hfs.c +++ b/grub-core/fs/hfs.c @@ -1004,6 +1004,12 @@ macroman_to_utf8 (char *to, const grub_uint8_t *from, grub_size_t len) for (iptr = from; iptr < from + len && *iptr; iptr++) { + /* Translate '/' to ':' as per HFS spec. */ + if (*iptr == '/') + { + *optr++ = ':'; + continue; + } if (!(*iptr & 0x80)) { *optr++ = *iptr; @@ -1024,6 +1030,13 @@ utf8_to_macroman (grub_uint8_t *to, const char *from) while (*iptr && optr < end) { int i, clen; + /* Translate ':' to '/' as per HFS spec. */ + if (*iptr == ':') + { + *optr++ = '/'; + iptr++; + continue; + } if (!(*iptr & 0x80)) { *optr++ = *iptr++; diff --git a/grub-core/fs/hfsplus.c b/grub-core/fs/hfsplus.c index d1fa15e9f..b20f9f3bb 100644 --- a/grub-core/fs/hfsplus.c +++ b/grub-core/fs/hfsplus.c @@ -789,6 +789,9 @@ grub_hfsplus_iterate_dir (grub_fshelp_node_t dir, { catkey->name[i] = grub_be_to_cpu16 (catkey->name[i]); + if (catkey->name[i] == '/') + catkey->name[i] = ':'; + /* If the name is obviously invalid, skip this node. */ if (catkey->name[i] == 0) return 0; @@ -799,7 +802,11 @@ grub_hfsplus_iterate_dir (grub_fshelp_node_t dir, /* Restore the byte order to what it was previously. */ for (i = 0; i < grub_be_to_cpu16 (catkey->namelen); i++) - catkey->name[i] = grub_be_to_cpu16 (catkey->name[i]); + { + if (catkey->name[i] == ':') + catkey->name[i] = '/'; + catkey->name[i] = grub_be_to_cpu16 (catkey->name[i]); + } /* hfs+ is case insensitive. */ if (! dir->data->case_sensitive)