Skip to content

fix(extractinitrd): create leading directories when extracting a selection - #2754

Merged
bdrung merged 1 commit into
dracut-ng:mainfrom
aafeijoo-suse:extractinitrd-make-dirs-fix
Nov 5, 2026
Merged

bdrung merged 1 commit into
dracut-ng:mainfrom
aafeijoo-suse:extractinitrd-make-dirs-fix

Conversation

@aafeijoo-suse

@aafeijoo-suse aafeijoo-suse commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

cpio without the -d/--make-directories option does not create leading directories where needed (see cpio(1)). Extracting a selection of files fails if the archive entry for a parent directory is not part of that. E.g.:

$ sudo dracutbasedir=. ./lsinitrd.sh --unpack /boot/initrd etc/cmdline.d/*
cpio: etc/cmdline.d/00-btrfs.conf: Cannot open: No such file or directory
cpio: etc/cmdline.d/90crypt.conf: Cannot open: No such file or directory
cpio: etc/cmdline.d/95resume.conf: Cannot open: No such file or directory
cpio: etc/cmdline.d/95root-dev.conf: Cannot open: No such file or directory
dracut-extractinitrd: cpio failed

Checklist

  • I have tested it locally
  • I have reviewed and updated any documentation if relevant
  • I am providing new code and test(s) for it

Comment thread src/extractinitrd/extractinitrd.c Resolved
@aafeijoo-suse
aafeijoo-suse force-pushed the extractinitrd-make-dirs-fix branch 2 times, most recently from ff55336 to 32fd838 Compare September 11, 2026 11:01
@bdrung

bdrung commented Nov 3, 2026

Copy link
Copy Markdown
Member

Could you add a test case to TEST-83-EXTRACTINITRD to cover this case?

…ction

cpio without the `-d/--make-directories` option does not create leading
directories where needed (see cpio(1)). Extracting a selection of files fails
if the archive entry for a parent directory is not part of that. E.g.:

```
$ sudo dracutbasedir=. ./lsinitrd.sh --unpack /boot/initrd etc/cmdline.d/*
cpio: etc/cmdline.d/00-btrfs.conf: Cannot open: No such file or directory
cpio: etc/cmdline.d/90crypt.conf: Cannot open: No such file or directory
cpio: etc/cmdline.d/95resume.conf: Cannot open: No such file or directory
cpio: etc/cmdline.d/95root-dev.conf: Cannot open: No such file or directory
dracut-extractinitrd: cpio failed
```

Used Claude to create a test case.

Co-developed-by: Claude Opus 5.5 <noreply@anthropic.com>
@aafeijoo-suse
aafeijoo-suse force-pushed the extractinitrd-make-dirs-fix branch from 32fd838 to 1f430ea Compare November 5, 2026 08:29
@github-actions github-actions Bot added the test Issues related to testing label Nov 5, 2026
@bdrung bdrung added this to the 113 milestone Nov 5, 2026
@bdrung
bdrung merged commit 2890b3e into dracut-ng:main Nov 5, 2026
127 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c extractinitrd test Issues related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants