-
Notifications
You must be signed in to change notification settings - Fork 46
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: add support for hard links #179
base: main
Are you sure you want to change the base?
Conversation
Hard links can now be extracted and they are correctly reflected in the manifest. --------- Co-authored-by: Rafid Bin Mostofa <[email protected]> Co-authored-by: Alberto Carretero <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Alberto. This is looking great.
A few comments, and maybe the last pass:
internal/fsutil/create.go
Outdated
hash = hex.EncodeToString(rp.h.Sum(nil)) | ||
if o.Link != "" { | ||
err = createHardLink(o) | ||
hardLink = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need the boolean flag if we have the mode already? Looks like we've done without it for the Options, so the Entry could be the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an edge case where we are creating a hard link to a symlink. In that case, we are asking fsutil.Create
to create an entry with o.Link = "symlink_location"
and o.Mode & fs.ModeType = 0
(meaning no dir or symlink). However, the final entry will have the mode of the file that was created, if it points to symlink_location
then the mode will have the symlink bit set. The problem then is that we are not able to distinguish hard link to symlink from a plain symlink because Mode
and Link
match both.
internal/manifest/report.go
Outdated
@@ -18,6 +19,8 @@ type ReportEntry struct { | |||
Slices map[*setup.Slice]bool | |||
Link string | |||
FinalSHA256 string | |||
// If HardLinkID is greater than 0, all entries with the same id represent hard links to the same inode. | |||
HardLinkID uint64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of HardLinkID/hard_link_id
, I suggest naming this Inode/inode
. More general idea, it's naturally an integer, and reflects the semantics in the filesystem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't inode going to suggest there is some relationship with the physical inode in the filesystem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed offline and agreed that this is a hint that this is an inode, it could in fact be the physical one.
internal/deb/extract.go
Outdated
|
||
// sanitizeTarPath removes the leading "./" from the source path in the tarball, | ||
// and verifies that the path is not empty. | ||
func sanitizeTarPath(path string) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have any logic that prevents the tar from leaving the target directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we don't at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed offline to do it, just not in this PR.
Hard links can now be extracted and they are correctly reflected in the manifest.