scripts/livepatch/fix-patch-lines
Source file repositories/reference/linux-study-clean/scripts/livepatch/fix-patch-lines
File Facts
- System
- Linux kernel
- Corpus path
scripts/livepatch/fix-patch-lines- Extension
[no extension]- Size
- 1460 bytes
- Lines
- 80
- Domain
- Support Tooling And Documentation
- Bucket
- scripts
- Inferred role
- Support Tooling And Documentation: scripts
- Status
- atlas-only
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.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
function match
Annotated Snippet
#!/usr/bin/awk -f
# SPDX-License-Identifier: GPL-2.0
#
# Use #line directives to preserve original __LINE__ numbers across patches to
# avoid unwanted compilation changes.
BEGIN {
in_hunk = 0
skip = 0
}
/^--- / {
skip = $2 !~ /\.(c|h)$/
print
next
}
/^@@/ {
if (skip) {
print
next
}
in_hunk = 1
# @@ -1,3 +1,4 @@:
# 1: line number in old file
# 3: how many lines the hunk covers in old file
# 1: line number in new file
# 4: how many lines the hunk covers in new file
match($0, /^@@ -([0-9]+)(,([0-9]+))? \+([0-9]+)(,([0-9]+))? @@/, m)
# Set 'cur' to the old file's line number at the start of the hunk. It
# gets incremented for every context line and every line removal, so
# that it always represents the old file's current line number.
cur = m[1]
# last = last line number of current hunk
last = cur + (m[3] ? m[3] : 1) - 1
need_line_directive = 0
print
next
}
{
if (skip || !in_hunk || $0 ~ /^\\ No newline at end of file/) {
print
next
}
# change line
if ($0 ~ /^[+-]/) {
# inject #line after this group of changes
need_line_directive = 1
if ($0 ~ /^-/)
cur++
print
next
}
# If this is the first context line after a group of changes, inject
# the #line directive to force the compiler to correct the line
# numbering to match the original file.
if (need_line_directive) {
print "+#line " cur
Annotation
- Detected declarations: `function match`.
- Atlas domain: Support Tooling And Documentation / scripts.
- Implementation status: atlas-only.
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.