fs/udf/unicode.c
Source file repositories/reference/linux-study-clean/fs/udf/unicode.c
File Facts
- System
- Linux kernel
- Corpus path
fs/udf/unicode.c- Extension
.c- Size
- 9242 bytes
- Lines
- 400
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
udfdecl.hlinux/hex.hlinux/kernel.hlinux/string.hlinux/nls.hlinux/crc-itu-t.hlinux/slab.hudf_sb.h
Detected Declarations
function get_utf16_charfunction udf_name_conv_charfunction udf_name_from_CS0function udf_name_to_CS0function udf_dstrCS0toCharfunction udf_get_filenamefunction udf_put_filename
Annotated Snippet
if (str_i_idx >= str_i_max_len) {
c = UNICODE_MAX + 1;
goto out;
}
/* Low surrogate must follow the high one... */
if (c & SURROGATE_LOW) {
c = UNICODE_MAX + 1;
goto out;
}
WARN_ON_ONCE(u_ch != 2);
next = str_i[str_i_idx++] << 8;
next |= str_i[str_i_idx++];
if ((next & SURROGATE_MASK) != SURROGATE_PAIR ||
!(next & SURROGATE_LOW)) {
c = UNICODE_MAX + 1;
goto out;
}
c = PLANE_SIZE +
((c & SURROGATE_CHAR_MASK) << SURROGATE_CHAR_BITS) +
(next & SURROGATE_CHAR_MASK);
}
out:
*ret = c;
return str_i_idx - start_idx;
}
static int udf_name_conv_char(uint8_t *str_o, int str_o_max_len,
int *str_o_idx,
const uint8_t *str_i, int str_i_max_len,
int *str_i_idx,
int u_ch, int *needsCRC,
int (*conv_f)(wchar_t, unsigned char *, int),
int translate)
{
unicode_t c;
int illChar = 0;
int len, gotch = 0;
while (!gotch && *str_i_idx < str_i_max_len) {
if (*str_o_idx >= str_o_max_len) {
*needsCRC = 1;
return gotch;
}
len = get_utf16_char(str_i, str_i_max_len, *str_i_idx, u_ch,
&c);
/* These chars cannot be converted. Replace them. */
if (c == 0 || c > UNICODE_MAX || (conv_f && c > MAX_WCHAR_T) ||
(translate && c == '/')) {
illChar = 1;
if (!translate)
gotch = 1;
} else if (illChar)
break;
else
gotch = 1;
*str_i_idx += len;
}
if (illChar) {
*needsCRC = 1;
c = ILLEGAL_CHAR_MARK;
gotch = 1;
}
if (gotch) {
if (conv_f) {
len = conv_f(c, &str_o[*str_o_idx],
str_o_max_len - *str_o_idx);
} else {
len = utf32_to_utf8(c, &str_o[*str_o_idx],
str_o_max_len - *str_o_idx);
if (len < 0)
len = -ENAMETOOLONG;
}
/* Valid character? */
if (len >= 0)
*str_o_idx += len;
else if (len == -ENAMETOOLONG) {
*needsCRC = 1;
gotch = 0;
} else {
str_o[(*str_o_idx)++] = ILLEGAL_CHAR_MARK;
*needsCRC = 1;
}
}
return gotch;
}
Annotation
- Immediate include surface: `udfdecl.h`, `linux/hex.h`, `linux/kernel.h`, `linux/string.h`, `linux/nls.h`, `linux/crc-itu-t.h`, `linux/slab.h`, `udf_sb.h`.
- Detected declarations: `function get_utf16_char`, `function udf_name_conv_char`, `function udf_name_from_CS0`, `function udf_name_to_CS0`, `function udf_dstrCS0toChar`, `function udf_get_filename`, `function udf_put_filename`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source 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.