lib/uuid.c
Source file repositories/reference/linux-study-clean/lib/uuid.c
File Facts
- System
- Linux kernel
- Corpus path
lib/uuid.c- Extension
.c- Size
- 3013 bytes
- Lines
- 135
- Domain
- Kernel Services
- Bucket
- lib
- Inferred role
- Kernel Services: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
Dependency Surface
linux/kernel.hlinux/ctype.hlinux/errno.hlinux/export.hlinux/hex.hlinux/uuid.hlinux/random.h
Detected Declarations
function generate_random_uuidfunction generate_random_guidfunction __uuid_gen_commonfunction guid_genfunction uuid_genfunction uuid_is_validfunction __uuid_parsefunction guid_parsefunction uuid_parseexport guid_nullexport uuid_nullexport generate_random_uuidexport generate_random_guidexport guid_genexport uuid_genexport uuid_is_validexport guid_parseexport uuid_parse
Annotated Snippet
if (i == 8 || i == 13 || i == 18 || i == 23) {
if (uuid[i] != '-')
return false;
} else if (!isxdigit(uuid[i])) {
return false;
}
}
return true;
}
EXPORT_SYMBOL(uuid_is_valid);
static int __uuid_parse(const char *uuid, __u8 b[16], const u8 ei[16])
{
static const u8 si[16] = {0,2,4,6,9,11,14,16,19,21,24,26,28,30,32,34};
unsigned int i;
if (!uuid_is_valid(uuid))
return -EINVAL;
for (i = 0; i < 16; i++) {
int hi = hex_to_bin(uuid[si[i] + 0]);
int lo = hex_to_bin(uuid[si[i] + 1]);
b[ei[i]] = (hi << 4) | lo;
}
return 0;
}
int guid_parse(const char *uuid, guid_t *u)
{
return __uuid_parse(uuid, u->b, guid_index);
}
EXPORT_SYMBOL(guid_parse);
int uuid_parse(const char *uuid, uuid_t *u)
{
return __uuid_parse(uuid, u->b, uuid_index);
}
EXPORT_SYMBOL(uuid_parse);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/ctype.h`, `linux/errno.h`, `linux/export.h`, `linux/hex.h`, `linux/uuid.h`, `linux/random.h`.
- Detected declarations: `function generate_random_uuid`, `function generate_random_guid`, `function __uuid_gen_common`, `function guid_gen`, `function uuid_gen`, `function uuid_is_valid`, `function __uuid_parse`, `function guid_parse`, `function uuid_parse`, `export guid_null`.
- Atlas domain: Kernel Services / lib.
- 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.