fs/hfsplus/unicode.c
Source file repositories/reference/linux-study-clean/fs/hfsplus/unicode.c
File Facts
- System
- Linux kernel
- Corpus path
fs/hfsplus/unicode.c- Extension
.c- Size
- 13826 bytes
- Lines
- 629
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hlinux/nls.hkunit/visibility.hhfsplus_fs.hhfsplus_raw.h
Detected Declarations
function Copyrightfunction hfsplus_strcasecmpfunction hfsplus_strcmpfunction hfsplus_mac2linux_compatibility_checkfunction hfsplus_uni2ascfunction hfsplus_uni2asc_strfunction hfsplus_uni2asc_xattr_strfunction hfsplus_linux2mac_compatibility_checkfunction asc2unicharfunction Copyrightfunction hfsplus_asc2unifunction arefunction are
Annotated Snippet
while (len1 && !c1) {
c1 = case_fold(be16_to_cpu(*p1));
p1++;
len1--;
}
while (len2 && !c2) {
c2 = case_fold(be16_to_cpu(*p2));
p2++;
len2--;
}
if (c1 != c2)
return (c1 < c2) ? -1 : 1;
if (!c1 && !c2)
return 0;
}
}
EXPORT_SYMBOL_IF_KUNIT(hfsplus_strcasecmp);
/* Compare names as a sequence of 16-bit unsigned integers */
int hfsplus_strcmp(const struct hfsplus_unistr *s1,
const struct hfsplus_unistr *s2)
{
u16 len1, len2, c1, c2;
const hfsplus_unichr *p1, *p2;
int len;
len1 = be16_to_cpu(s1->length);
len2 = be16_to_cpu(s2->length);
p1 = s1->unicode;
p2 = s2->unicode;
if (len1 > HFSPLUS_MAX_STRLEN) {
len1 = HFSPLUS_MAX_STRLEN;
pr_err("invalid length %u has been corrected to %d\n",
be16_to_cpu(s1->length), len1);
}
if (len2 > HFSPLUS_MAX_STRLEN) {
len2 = HFSPLUS_MAX_STRLEN;
pr_err("invalid length %u has been corrected to %d\n",
be16_to_cpu(s2->length), len2);
}
for (len = min(len1, len2); len > 0; len--) {
c1 = be16_to_cpu(*p1);
c2 = be16_to_cpu(*p2);
if (c1 != c2)
return c1 < c2 ? -1 : 1;
p1++;
p2++;
}
return len1 < len2 ? -1 :
len1 > len2 ? 1 : 0;
}
EXPORT_SYMBOL_IF_KUNIT(hfsplus_strcmp);
#define Hangul_SBase 0xac00
#define Hangul_LBase 0x1100
#define Hangul_VBase 0x1161
#define Hangul_TBase 0x11a7
#define Hangul_SCount 11172
#define Hangul_LCount 19
#define Hangul_VCount 21
#define Hangul_TCount 28
#define Hangul_NCount (Hangul_VCount * Hangul_TCount)
static u16 *hfsplus_compose_lookup(u16 *p, u16 cc)
{
int i, s, e;
s = 1;
e = p[1];
if (!e || cc < p[s * 2] || cc > p[e * 2])
return NULL;
do {
i = (s + e) / 2;
if (cc > p[i * 2])
s = i + 1;
else if (cc < p[i * 2])
e = i - 1;
else
return hfsplus_compose_table + p[i * 2 + 1];
} while (s <= e);
return NULL;
}
/*
Annotation
- Immediate include surface: `linux/types.h`, `linux/nls.h`, `kunit/visibility.h`, `hfsplus_fs.h`, `hfsplus_raw.h`.
- Detected declarations: `function Copyright`, `function hfsplus_strcasecmp`, `function hfsplus_strcmp`, `function hfsplus_mac2linux_compatibility_check`, `function hfsplus_uni2asc`, `function hfsplus_uni2asc_str`, `function hfsplus_uni2asc_xattr_str`, `function hfsplus_linux2mac_compatibility_check`, `function asc2unichar`, `function Copyright`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.