public inbox for linux-next@vger.kernel.org
 help / color / mirror / Atom feed
From: David Disseldorp <ddiss@suse.de>
To: linux-kbuild@vger.kernel.org, linux-fsdevel@vger.kernel.org
Cc: linux-next@vger.kernel.org, ddiss@suse.de, nsc@kernel.org
Subject: [PATCH v3 6/8] docs: initramfs: file data alignment via name padding
Date: Tue, 19 Aug 2025 13:05:49 +1000	[thread overview]
Message-ID: <20250819032607.28727-7-ddiss@suse.de> (raw)
In-Reply-To: <20250819032607.28727-1-ddiss@suse.de>

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: https://github.com/dracutdevs/dracut/commit/300e4b116c624bca1b9e7251708b1ae656fe9157 [1]
Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Nicolas Schier <nsc@kernel.org>
---
 Documentation/driver-api/early-userspace/buffer-format.rst | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Documentation/driver-api/early-userspace/buffer-format.rst b/Documentation/driver-api/early-userspace/buffer-format.rst
index 726bfa2fe70da..4597a91100b7b 100644
--- a/Documentation/driver-api/early-userspace/buffer-format.rst
+++ b/Documentation/driver-api/early-userspace/buffer-format.rst
@@ -86,6 +86,11 @@ c_mtime is ignored unless CONFIG_INITRAMFS_PRESERVE_MTIME=y is set.
 The c_filesize should be zero for any file which is not a regular file
 or symlink.
 
+c_namesize may account for more than one trailing '\0', as long as the
+value doesn't exceed PATH_MAX.  This can be useful for ensuring that a
+subsequent file data segment is aligned, e.g. to a filesystem block
+boundary.
+
 The c_chksum field contains a simple 32-bit unsigned sum of all the
 bytes in the data field.  cpio(1) refers to this as "crc", which is
 clearly incorrect (a cyclic redundancy check is a different and
-- 
2.43.0


  parent reply	other threads:[~2025-08-19  3:50 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-19  3:05 [PATCH v3 0/8] gen_init_cpio: add copy_file_range / reflink support David Disseldorp
2025-08-19  3:05 ` [PATCH v3 1/8] gen_init_cpio: write to fd instead of stdout stream David Disseldorp
2025-08-19  3:05 ` [PATCH v3 2/8] gen_init_cpio: support -o <output_file> parameter David Disseldorp
2025-08-19  3:05 ` [PATCH v3 3/8] gen_init_cpio: attempt copy_file_range for file data David Disseldorp
2025-08-19  3:05 ` [PATCH v3 4/8] gen_init_cpio: avoid duplicate strlen calls David Disseldorp
2025-08-19  3:05 ` [PATCH v3 5/8] gen_initramfs.sh: use gen_init_cpio -o parameter David Disseldorp
2025-08-19  3:05 ` David Disseldorp [this message]
2025-08-19  3:05 ` [PATCH v3 7/8] gen_init_cpio: add -a <data_align> as reflink optimization David Disseldorp
2025-08-19  3:05 ` [PATCH v3 8/8] initramfs_test: add filename padding test case David Disseldorp
2025-08-19 20:16   ` kernel test robot
2025-08-20  1:13     ` David Disseldorp
2025-08-20 21:02       ` Nicolas Schier
2025-08-21  5:04         ` David Disseldorp
2025-08-21  5:40           ` Nicolas Schier
2025-08-21 19:09 ` [PATCH v3 0/8] gen_init_cpio: add copy_file_range / reflink support Nathan Chancellor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250819032607.28727-7-ddiss@suse.de \
    --to=ddiss@suse.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=nsc@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox