Commit 95fce6b
authored
tar: Only pad partially-filled blocks (#67)
Motivation
----------
Tar archives are stored sequences of 512-byte blocks, so archive members
must be zero-padded to the nearest whole number of blocks. The current
padding calculation incorrectly adds a full 512-byte padding block if
the member already finishes on a block boundary.
The tar end of file marker is defined as two consecutive empty blocks:
https://www.loc.gov/preservation/digital/formats/fdd/fdd000531.shtml
However interoperability testing with the system tar binary shows that a
single unnecessary empty block will be interpreted as the end of the
file.
Modifications
-------------
The padding calculation now correctly avoids zero-padding a file which
is already a whole number of blocks in length.
Result
------
* Tar archives produced by the `Tar` module will match the out put of
the system tar utilities.
* This commit will not immediately cause a noticeable change in
behaviour because `containertool` currently only stores one member - the
application binary - in an archive.
Test Plan
---------
* New tests check that padding is only applied to partially full blocks.
* All existing tests continue to pass.1 parent 90e62ec commit 95fce6b
2 files changed
+35
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
204 | 214 | | |
205 | 215 | | |
206 | 216 | | |
| |||
214 | 224 | | |
215 | 225 | | |
216 | 226 | | |
217 | | - | |
| 227 | + | |
218 | 228 | | |
219 | 229 | | |
220 | 230 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
45 | 69 | | |
46 | 70 | | |
47 | 71 | | |
| |||
0 commit comments