2 * Copyright 2011, Jérôme Duval, korli@users.berlios.de.
3 * Copyright 2014 Haiku, Inc. All rights reserved.
5 * Distributed under the terms of the MIT License.
8 * Jérôme Duval, korli@users.berlios.de
9 * John Scipione, jscipione@gmail.com
21 #include "convertutf.h"
25 get_volume_name(struct exfat_entry
* entry
, char* name
, size_t length
)
27 if (entry
== NULL
|| name
== NULL
)
30 if (entry
->type
== EXFAT_ENTRY_TYPE_NOT_IN_USE
)
32 else if (entry
->type
== EXFAT_ENTRY_TYPE_LABEL
) {
33 ssize_t utf8Length
= utf16le_to_utf8(entry
->volume_label
.name
,
34 entry
->volume_label
.length
, name
, length
);
36 return (status_t
)utf8Length
;
38 return B_NAME_NOT_FOUND
;
45 get_default_volume_name(off_t partitionSize
, char* name
, size_t length
)
47 off_t divisor
= 1ULL << 40;
49 if (partitionSize
< divisor
) {
52 if (partitionSize
< divisor
) {
58 double size
= double((10 * partitionSize
+ divisor
- 1) / divisor
);
59 // %g in the kernel does not support precision...
61 snprintf(name
, length
, "%g%ciB ExFAT Volume", size
/ 10, unit
);