Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(initrd): corrupted symlinks #850

Closed
wants to merge 2 commits into from
Closed

fix(initrd): corrupted symlinks #850

wants to merge 2 commits into from

Conversation

antoineco
Copy link
Contributor

@antoineco antoineco commented Sep 29, 2023

Prerequisite checklist

  • Read the contribution guidelines regarding submitting new changes to the project;
  • Tested your changes against relevant architectures and platforms;
  • Ran make fmt on your commit series before opening this PR;
  • Updated relevant documentation.

Description of changes

Due to an issue upstream (cavaliergopher/cpio#15) files with mode Symlink are written as zero-sized files, without symlink target:

Output of Unikraft:

Info: [libukcpio] <cpio.c @  298> Creating symlink /bin/arch
Info: [libukcpio] <cpio.c @  316> /bin/arch: Target is
dbg:  [libvfscore] <main.c @ 1668> (int) uk_syscall_r_symlink((const char*) 0x11eb0, (const char*) 0x43d2e0020)
ERR:  [libukcpio] <cpio.c @  318> /bin/arch: Failed to create symlink: Unknown error 0 (0)

Output of included tests:

=== RUN   TestNewFromMapping
    initrd_test.go:82: file [./lib/libtest.so.1]: got mode 0100000, expected 0120000
    initrd_test.go:85: file [./lib/libtest.so.1]: got linkname "", expected "libtest.so.1.0.0"
    initrd_test.go:88: file [./lib/libtest.so.1]: got size 16, expected 0

This PR refactors the NewFromMapping function to use a (hopefully temporary) fork which includes the relevant fix (cavaliergopher/cpio#16).

Additionally, I refactored the logic a little for readability.

Signed-off-by: Antoine Cotten <antoine@unikraft.io>
Due to an issue upstream, files with mode Symlink are written as
zero-sized files without target.

Signed-off-by: Antoine Cotten <antoine@unikraft.io>
@craciunoiuc
Copy link
Member

Code looks good, will try on Monday 🙏

@antoineco
Copy link
Contributor Author

I just learned @nderjung was already working on this.

@antoineco antoineco closed this Oct 2, 2023
@antoineco antoineco deleted the acotten/fix-cpio-symlink2 branch October 2, 2023 08:50
@craciunoiuc
Copy link
Member

it worked btw

@antoineco
Copy link
Contributor Author

I know, I included tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🚀 Done
Development

Successfully merging this pull request may close these issues.

2 participants