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

feat: handle hardlinks #17

Merged

Conversation

zhijie-yang
Copy link

  • Have you signed the CLA?

This PR enables chisel to handle hard links. This is based on the assumption that the hard link and the target file are within the same tarball. If the hard links are not in the same slice as the target files in the slice definition file, the slice containing the target files should be included as the essential of the slice that contains the hard links.

Related Discussion:

canonical/chisel-releases#259 (comment)

Copy link
Owner

@letFunny letFunny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass. This is looking very good, overall just a couple of nitpicks and comments about missing tests.

internal/deb/extract_test.go Outdated Show resolved Hide resolved
internal/deb/extract_test.go Outdated Show resolved Hide resolved
internal/deb/extract_test.go Outdated Show resolved Hide resolved
internal/deb/extract_test.go Outdated Show resolved Hide resolved
internal/fsutil/create.go Show resolved Hide resolved
internal/fsutil/create.go Outdated Show resolved Hide resolved
internal/fsutil/create.go Outdated Show resolved Hide resolved
internal/testutil/pkgdata.go Show resolved Hide resolved
internal/deb/extract_test.go Outdated Show resolved Hide resolved
internal/deb/extract_test.go Outdated Show resolved Hide resolved
Copy link
Owner

@letFunny letFunny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks James, this is looking very good! I did another quick pass, a bunch of nitpicks basically. I think we should also change the implementation for TreeDumpEntry even if we are not using it right now.

internal/deb/extract_test.go Outdated Show resolved Hide resolved
internal/deb/extract_test.go Outdated Show resolved Hide resolved
internal/fsutil/create.go Outdated Show resolved Hide resolved
internal/fsutil/create.go Outdated Show resolved Hide resolved
internal/fsutil/create_test.go Outdated Show resolved Hide resolved
internal/deb/extract_test.go Show resolved Hide resolved
internal/deb/extract_test.go Outdated Show resolved Hide resolved
internal/deb/extract_test.go Outdated Show resolved Hide resolved
internal/fsutil/create_test.go Outdated Show resolved Hide resolved
internal/fsutil/create_test.go Outdated Show resolved Hide resolved
@zhijie-yang
Copy link
Author

Thanks James, this is looking very good! I did another quick pass, a bunch of nitpicks basically. I think we should also change the implementation for TreeDumpEntry even if we are not using it right now.

The implementation of TreeDumpEntry is changed in 06ccac5. Please have it reviewed. Thanks.

Copy link
Owner

@letFunny letFunny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes James. I think we are only need one more round to get this approved :D. Most of the comments are about changing the code to match the style of Chisel a bit more, which is always the tedious part in the beginning until we both share the same mindset.

internal/fsutil/create.go Outdated Show resolved Hide resolved
internal/fsutil/create_test.go Outdated Show resolved Hide resolved
internal/fsutil/create.go Outdated Show resolved Hide resolved
internal/testutil/treedump.go Outdated Show resolved Hide resolved
internal/testutil/treedump.go Outdated Show resolved Hide resolved
internal/fsutil/create_test.go Outdated Show resolved Hide resolved
internal/fsutil/create_test.go Outdated Show resolved Hide resolved
internal/fsutil/create_test.go Outdated Show resolved Hide resolved
internal/fsutil/create_test.go Outdated Show resolved Hide resolved
internal/fsutil/create_test.go Outdated Show resolved Hide resolved
Copy link
Owner

@letFunny letFunny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey James, another quick review pending the last pass. I see that you removed the changes to treedump.go that would print whether an entry is a hardlink. I think we should keep the changes in treedump.go even though we don't use it right now. I think that it is useful when:

  • we need to write other tests using it in the future,
  • debugging, think about a test that creates a hardlink when it shouldn't. If we do not introduce the changes then the output is going to be identical to a regular file and we won't be able to differentiate it.

internal/fsutil/create.go Outdated Show resolved Hide resolved
internal/fsutil/create.go Outdated Show resolved Hide resolved
internal/fsutil/create.go Outdated Show resolved Hide resolved
internal/fsutil/create_test.go Show resolved Hide resolved
internal/fsutil/create_test.go Outdated Show resolved Hide resolved
Copy link
Owner

@letFunny letFunny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks James, only nitpicks this time about names. In Chisel we try to keep everything short and concise, hence why I suggested some changes to the naming. We should only have long names / comments where it makes sense to have that extra information.

internal/deb/extract.go Outdated Show resolved Hide resolved
internal/deb/extract_test.go Outdated Show resolved Hide resolved
internal/deb/extract_test.go Outdated Show resolved Hide resolved
internal/fsutil/create.go Outdated Show resolved Hide resolved
Comment on lines 144 to 146
if os.SameFile(targetInfo, linkInfo) {
return nil
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some more tests and ln does not respect this, let's remove it. Probably previous comment about naming does not apply as we no longer need those variables.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bookkeeping: As per the offline discussion, this has to exist since there can be different slices in one package that create the same hard link multiple times.

internal/fsutil/create_test.go Outdated Show resolved Hide resolved
internal/fsutil/create_test.go Outdated Show resolved Hide resolved
internal/fsutil/create_test.go Outdated Show resolved Hide resolved
internal/fsutil/create_test.go Outdated Show resolved Hide resolved
internal/fsutil/create_test.go Outdated Show resolved Hide resolved
Copy link
Owner

@letFunny letFunny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks James, I did a thorough pass and everything is looking good, let's just fix these three nits and I will merge :)

Thanks again for your first contribution, I think you nailed it.

internal/slicer/slicer_test.go Outdated Show resolved Hide resolved
internal/slicer/slicer_test.go Outdated Show resolved Hide resolved
internal/testutil/treedump.go Outdated Show resolved Hide resolved
@letFunny letFunny changed the base branch from main to handle-hardlinks July 29, 2024 11:56
@letFunny letFunny merged commit f1de97a into letFunny:handle-hardlinks Jul 29, 2024
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants