fs/hfs/trans.c
Source file repositories/reference/linux-study-clean/fs/hfs/trans.c
File Facts
- System
- Linux kernel
- Corpus path
fs/hfs/trans.c- Extension
.c- Size
- 3462 bytes
- Lines
- 151
- 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
linux/types.hlinux/nls.hhfs_fs.h
Detected Declarations
function Copyrightfunction hfs_asc2mac
Annotated Snippet
while (srclen > 0) {
if (nls_disk) {
size = nls_disk->char2uni(src, srclen, &ch);
if (size <= 0) {
ch = '?';
size = 1;
}
src += size;
srclen -= size;
} else {
ch = *src++;
srclen--;
}
if (ch == '/')
ch = ':';
size = nls_io->uni2char(ch, dst, dstlen);
if (size < 0) {
if (size == -ENAMETOOLONG)
goto out;
*dst = '?';
size = 1;
}
dst += size;
dstlen -= size;
}
} else {
char ch;
while (--srclen >= 0)
*dst++ = (ch = *src++) == '/' ? ':' : ch;
}
out:
return dst - out;
}
/*
* hfs_asc2mac()
*
* Given an ASCII string (not null-terminated) and its length,
* generate the corresponding filename in the Macintosh character set
* using the 'trivial' name-mangling scheme, returning the length of
* the mangled filename. Note that the output string is not NULL
* terminated.
*
* This routine is a inverse to hfs_mac2triv().
* A ':' is replaced by a '/'.
*/
void hfs_asc2mac(struct super_block *sb, struct hfs_name *out, const struct qstr *in)
{
struct nls_table *nls_disk = HFS_SB(sb)->nls_disk;
struct nls_table *nls_io = HFS_SB(sb)->nls_io;
const char *src;
char *dst;
int srclen, dstlen, size;
src = in->name;
srclen = in->len;
dst = out->name;
dstlen = HFS_NAMELEN;
if (nls_io) {
wchar_t ch;
while (srclen > 0 && dstlen > 0) {
size = nls_io->char2uni(src, srclen, &ch);
if (size < 0) {
ch = '?';
size = 1;
}
src += size;
srclen -= size;
if (ch == ':')
ch = '/';
if (nls_disk) {
size = nls_disk->uni2char(ch, dst, dstlen);
if (size < 0) {
if (size == -ENAMETOOLONG)
goto out;
*dst = '?';
size = 1;
}
dst += size;
dstlen -= size;
} else {
*dst++ = ch > 0xff ? '?' : ch;
dstlen--;
}
}
} else {
char ch;
Annotation
- Immediate include surface: `linux/types.h`, `linux/nls.h`, `hfs_fs.h`.
- Detected declarations: `function Copyright`, `function hfs_asc2mac`.
- 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.