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

Reading non-contiguous symlink targets is not supported #36

Open
twiggler opened this issue Oct 15, 2024 · 0 comments
Open

Reading non-contiguous symlink targets is not supported #36

twiggler opened this issue Oct 15, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@twiggler
Copy link
Contributor

twiggler commented Oct 15, 2024

Almost always, the symlink target, which has a max size of 1024, fits within a block.
However, if the block size if 512 (default is 4k), at most three blocks are required to store the symlink target and headers. These three blocks could theoretically be distributed over multiple extents, where each extent has its own copy of the xfs_dsymlink_hdr symlink header structure.

Our implementation does not handle this edge case correctly.
Do note that the probability of this happening is estimated to be very low.

To fix this, we need to

  1. Allocate a buffer for the link target,
  2. Iterate over the extents,
  3. Read the header
  4. Read xfs_dsymlink_hdr::sl_bytes of the link target and place the bytes at xfs_dsymlink_hdr::sl_offset in the allocated buffer for the link target.

To create a test case, the write command of the xfs_db tool can be used to create multiple extents:

 write core.extent[0].startblock 100
 write core.extent[0].blockcount 1
 write core.extent[1].startblock 200
 write core.extent[1].blockcount 1
@twiggler twiggler added the bug Something isn't working label Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant