History log of /haiku/src/add-ons/kernel/file_systems/exfat/Utility.cpp
Revision Date Author Comments
# 65e832b7 08-Jul-2018 Jérôme Duval <jerome.duval@gmail.com>

exfat: fix warning.


# ebd3bcdb 12-Feb-2014 John Scipione <jscipione@gmail.com>

exfat: handle 4-byte UTF-16 surrogate pairs

... in filenames. Replace the existing Unicode conversion functions
with UTF conversion functions from js that he relicensed MIT for us.

Put the UTF conversion functions in a private but shared code location
so that they can be accessed throughout the kernel.

Right now we only provide functions to convert between UTF-8 and UTF-16.
At some point we should also add functions to convert between UTF-8 and
UTF-32 and UTF-16 and UTF-32 but these aren't needed by exfat.

Remove the old Unicode conversion functions from exfat as they assumed
UCS-2 characters and don't work with UTF-16 used by exfat.

Rename most variables with the term length with code unit where code units
are intended. The term length, when used, means length in bytes while code
units represent either a full 2-byte UTF-16 character or half a 4-byte
surrogate pair.


# 5b10d763 11-Feb-2014 John Scipione <jscipione@gmail.com>

exfat: use diff structs 4 vol labels and filenames

... and rename the structs to reflect this.

* Volume labels contain up to 11 uint16s (11 2-byte UTF-16 characters).
* Filenames are packed into 1 to 17 structs of 15 uint16s each (for a total
of 255 2-byte UTF-16 characters).
* Use 2 different packed structs in the exfat_entry union (same bytes, accessed
with different structs) to access these 2 things.
* Remove a check that assumed the length returned the number of 2-byte UTF-16
characters, i.e. the number of uint16s the string uses. It doesn't, it
returns the number of characters contained in the string which might be 2 or
4-bytes wide. We're doing the conversion wrong for 4-byte UTF-16 characters
anyway, more on that later.


# 3472fc55 06-Feb-2014 John Scipione <jscipione@gmail.com>

exfat: style fix param/variable renaming

Pass the partition size into the default name, not the device size,
this makes the variable names match the comment.

There is no functional change here, the variable names got renamed
to make it more clear what's happening. We want show the partition
size, not the device size, and we want to error if the device size is less
than the partition size, not if the partition size is less than the device size.


# dae266a8 05-Feb-2014 John Scipione <jscipione@gmail.com>

exfat: fix problems with hrev46820

* Set the size of the volume name member var to B_FILE_NAME_LENGTH which is the
max width of a volume name according to the BeBook and the Support Kit code. We'll
deal with trying to stuff the volume name back into the exfat volume label later.
* Rename volume_name() to get_volume_name()
* Pass the name string length into get_volume_name() and use it to avoid buffer overrun.
* Fill name with a blank string if volume has no label.
* Don't memset the name with zeros before doing the conversion from Unicode to UTF-8,
the conversion function will make sure the result is NUL-terminated if it returns B_OK.
* Also check the return value of the Unicode conversion function and return an error if it fails.
* Add get_default_volume_name() method to Utility.cpp which is used to fill out the default
volume name in the case volume name is blank. e.g. 32GiB ExFAT Volume. This now
applies to both the volume name and mount point.
* Use non-metric prefixes for default volume name, e.g. MiB, GiB, TiB
* For an unset volume name fill the volume name with an empty string.
* Remove the leading underscore from _name and _partition parameters
* Replace size constants with sizeof() calls
* Remove Axel from the copyright statement in Utility.cpp, he had nothing to do with it,
add Jérôme (aka korli) because he wrote the code for get_default_volume_name()
(was in Volumes.cpp)
* Remove some trailing spaces from encodings.cpp

Thanks Axel.


# 762b846c 04-Feb-2014 John Scipione <jscipione@gmail.com>

exfat: Set the mountpoint to same as volume name

Fixes #10501

* update copyright headers, attribute to Haiku, Inc. add authors
* volume_name gets filled out by a utility function in Utility.cpp
* update exfat_entry
- rename name_label to just label
- adjust volume_label to have 11 uint16 chars plus 8 uint8 reserved
- add guid partition info
* Added a couple new entry type defines
* fName is 34 bytes long which fits the 11 3-byte UTF-8 chars and a \0


# ebd3bcdb9be2d6a57fc5b3270dcb49a9e1894d11 12-Feb-2014 John Scipione <jscipione@gmail.com>

exfat: handle 4-byte UTF-16 surrogate pairs

... in filenames. Replace the existing Unicode conversion functions
with UTF conversion functions from js that he relicensed MIT for us.

Put the UTF conversion functions in a private but shared code location
so that they can be accessed throughout the kernel.

Right now we only provide functions to convert between UTF-8 and UTF-16.
At some point we should also add functions to convert between UTF-8 and
UTF-32 and UTF-16 and UTF-32 but these aren't needed by exfat.

Remove the old Unicode conversion functions from exfat as they assumed
UCS-2 characters and don't work with UTF-16 used by exfat.

Rename most variables with the term length with code unit where code units
are intended. The term length, when used, means length in bytes while code
units represent either a full 2-byte UTF-16 character or half a 4-byte
surrogate pair.


# 5b10d763d0da84a6f0cb07c610eb25df776273b2 11-Feb-2014 John Scipione <jscipione@gmail.com>

exfat: use diff structs 4 vol labels and filenames

... and rename the structs to reflect this.

* Volume labels contain up to 11 uint16s (11 2-byte UTF-16 characters).
* Filenames are packed into 1 to 17 structs of 15 uint16s each (for a total
of 255 2-byte UTF-16 characters).
* Use 2 different packed structs in the exfat_entry union (same bytes, accessed
with different structs) to access these 2 things.
* Remove a check that assumed the length returned the number of 2-byte UTF-16
characters, i.e. the number of uint16s the string uses. It doesn't, it
returns the number of characters contained in the string which might be 2 or
4-bytes wide. We're doing the conversion wrong for 4-byte UTF-16 characters
anyway, more on that later.


# 3472fc553eb5a8e2d9ff40c9a33f083b6f303081 06-Feb-2014 John Scipione <jscipione@gmail.com>

exfat: style fix param/variable renaming

Pass the partition size into the default name, not the device size,
this makes the variable names match the comment.

There is no functional change here, the variable names got renamed
to make it more clear what's happening. We want show the partition
size, not the device size, and we want to error if the device size is less
than the partition size, not if the partition size is less than the device size.


# dae266a8a4141d0c1059685b78bb9bd5b27c8389 05-Feb-2014 John Scipione <jscipione@gmail.com>

exfat: fix problems with hrev46820

* Set the size of the volume name member var to B_FILE_NAME_LENGTH which is the
max width of a volume name according to the BeBook and the Support Kit code. We'll
deal with trying to stuff the volume name back into the exfat volume label later.
* Rename volume_name() to get_volume_name()
* Pass the name string length into get_volume_name() and use it to avoid buffer overrun.
* Fill name with a blank string if volume has no label.
* Don't memset the name with zeros before doing the conversion from Unicode to UTF-8,
the conversion function will make sure the result is NUL-terminated if it returns B_OK.
* Also check the return value of the Unicode conversion function and return an error if it fails.
* Add get_default_volume_name() method to Utility.cpp which is used to fill out the default
volume name in the case volume name is blank. e.g. 32GiB ExFAT Volume. This now
applies to both the volume name and mount point.
* Use non-metric prefixes for default volume name, e.g. MiB, GiB, TiB
* For an unset volume name fill the volume name with an empty string.
* Remove the leading underscore from _name and _partition parameters
* Replace size constants with sizeof() calls
* Remove Axel from the copyright statement in Utility.cpp, he had nothing to do with it,
add Jérôme (aka korli) because he wrote the code for get_default_volume_name()
(was in Volumes.cpp)
* Remove some trailing spaces from encodings.cpp

Thanks Axel.


# 762b846cf8ba678f31a854a85e68003d2071be8d 04-Feb-2014 John Scipione <jscipione@gmail.com>

exfat: Set the mountpoint to same as volume name

Fixes #10501

* update copyright headers, attribute to Haiku, Inc. add authors
* volume_name gets filled out by a utility function in Utility.cpp
* update exfat_entry
- rename name_label to just label
- adjust volume_label to have 11 uint16 chars plus 8 uint8 reserved
- add guid partition info
* Added a couple new entry type defines
* fName is 34 bytes long which fits the 11 3-byte UTF-8 chars and a \0