Skip to content

Commit 7c1f14f

Browse files
ddissnathanchance
authored andcommitted
docs: initramfs: file data alignment via name padding
The existing cpio extraction logic reads (maximum PATH_MAX) name_len bytes from the archive into the collected name buffer and ensures that the trailing byte is a null-terminator. This allows the actual file name to be shorter than name_len, with the name string simply zero-terminated prior to the last byte. Initramfs generators, such as dracut-cpio[1], can take advantage of name zero-padding to align file data segments within the archive to filesystem block boundaries. Block boundary alignment may allow the copy_file_range syscall to reflink archive source and destination extents. Link: dracutdevs/dracut@300e4b1 [1] Signed-off-by: David Disseldorp <ddiss@suse.de> Reviewed-by: Nicolas Schier <nsc@kernel.org> Link: https://lore.kernel.org/r/20250819032607.28727-7-ddiss@suse.de Signed-off-by: Nathan Chancellor <nathan@kernel.org>
1 parent 9135564 commit 7c1f14f

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Documentation/driver-api/early-userspace/buffer-format.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ c_mtime is ignored unless CONFIG_INITRAMFS_PRESERVE_MTIME=y is set.
8686
The c_filesize should be zero for any file which is not a regular file
8787
or symlink.
8888

89+
c_namesize may account for more than one trailing '\0', as long as the
90+
value doesn't exceed PATH_MAX. This can be useful for ensuring that a
91+
subsequent file data segment is aligned, e.g. to a filesystem block
92+
boundary.
93+
8994
The c_chksum field contains a simple 32-bit unsigned sum of all the
9095
bytes in the data field. cpio(1) refers to this as "crc", which is
9196
clearly incorrect (a cyclic redundancy check is a different and

0 commit comments

Comments
 (0)