scripts/genksyms/genksyms.c
Source file repositories/reference/linux-study-clean/scripts/genksyms/genksyms.c
File Facts
- System
- Linux kernel
- Corpus path
scripts/genksyms/genksyms.c- Extension
.c- Size
- 21230 bytes
- Lines
- 851
- Domain
- Support Tooling And Documentation
- Bucket
- scripts
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
stdio.hstring.hstdint.hstdlib.hunistd.hassert.hstdarg.hgetopt.hhashtable.hgenksyms.h
Detected Declarations
function partial_crc32_onefunction partial_crc32function crc32function map_to_nsfunction hash_for_each_possiblefunction is_unknown_symbolfunction free_nodefunction free_listfunction equal_listfunction read_referencefunction print_nodefunction print_listfunction expand_and_crc_symfunction export_symbolfunction print_locationfunction print_type_namefunction error_with_posfunction genksyms_usagefunction main
Annotated Snippet
if (defn) {
free_list(last_enum_expr, NULL);
last_enum_expr = copy_list_range(defn, NULL);
enum_counter = 1;
} else {
struct string_list *expr;
char buf[20];
snprintf(buf, sizeof(buf), "%d", enum_counter++);
if (last_enum_expr) {
expr = copy_list_range(last_enum_expr, NULL);
defn = concat_list(mk_node("("),
expr,
mk_node(")"),
mk_node("+"),
mk_node(buf), NULL);
} else {
defn = mk_node(buf);
}
}
} else {
free_list(last_enum_expr, NULL);
last_enum_expr = NULL;
enum_counter = 0;
if (!name)
/* Anonymous enum definition, nothing more to do */
return NULL;
}
return defn;
}
static struct symbol *__add_symbol(const char *name, enum symbol_type type,
struct string_list *defn, int is_extern,
int is_reference)
{
unsigned long h;
struct symbol *sym;
enum symbol_status status = STATUS_UNCHANGED;
if ((type == SYM_ENUM_CONST || type == SYM_ENUM) && !is_reference) {
defn = process_enum(name, type, defn);
if (defn == NULL)
return NULL;
}
h = crc32(name);
hash_for_each_possible(symbol_hashtable, sym, hnode, h) {
if (map_to_ns(sym->type) != map_to_ns(type) ||
strcmp(name, sym->name))
continue;
if (is_reference) {
break;
} else if (sym->type == type && equal_list(sym->defn, defn)) {
if (!sym->is_declared && sym->is_override) {
print_location();
print_type_name(type, name);
fprintf(stderr, " modversion is unchanged\n");
}
sym->is_declared = 1;
} else if (sym->is_declared) {
error_with_pos("redefinition of %s", name);
} else if (sym->is_override && flag_preserve) {
print_location();
fprintf(stderr, "ignoring ");
print_type_name(type, name);
fprintf(stderr, " modversion change\n");
sym->is_declared = 1;
} else {
status = is_unknown_symbol(sym) ?
STATUS_DEFINED : STATUS_MODIFIED;
break;
}
free_list(defn, NULL);
return sym;
}
if (sym) {
hash_del(&sym->hnode);
free_list(sym->defn, NULL);
free(sym->name);
free(sym);
--nsyms;
}
sym = xmalloc(sizeof(*sym));
sym->name = xstrdup(name);
sym->type = type;
Annotation
- Immediate include surface: `stdio.h`, `string.h`, `stdint.h`, `stdlib.h`, `unistd.h`, `assert.h`, `stdarg.h`, `getopt.h`.
- Detected declarations: `function partial_crc32_one`, `function partial_crc32`, `function crc32`, `function map_to_ns`, `function hash_for_each_possible`, `function is_unknown_symbol`, `function free_node`, `function free_list`, `function equal_list`, `function read_reference`.
- Atlas domain: Support Tooling And Documentation / scripts.
- 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.