forked from u-root/u-root
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkg/cpio,cmds/core/cpio: handle Inum 0 better, start numbering at 2
For reproducible builds, the u-root command produces cpio entries with inumber of 0. This has worked fine for years, until recently an archive was created with an empty, zero-length directory, when it failed on Harvey. Zero-length entities in cpio archives indicate a zero length file, OR, a second hard link to an already-written file, OR a directory. Commit 301d69f tried to handle zero-length entries but only got 2 of the 3 cases right. A recent commit, 676b9e5 fixed directories, but still had a few issues with Inums of 0, seen on Harvey. The problem boils down to handling entries with an inumber of 0. That is an illegal value for real file systems, but not illegal per se. The code now uses it as a sentinal to gate other tests. The code still leaves in a test which unconditionally skips directories, as there are cpio archives which strangely end up with directory inumbers the same as file inumbers. It pays to be careful. This change cleans up the last few problems we've seen processing u-root initramfs cpios on Harvey. Why did this not happen before? Because until now almnost all processing of u-root initramfs was done by the Linux kernel, not the u-root cpio command. Further, the commit mentioned above broke a few things starting in February 2020. This also fixes a bug in the original cpio package, in which the first inumber was zero, not a legal value. From the original Unix docs: " The root inode is the root of the file system. Inode 0 can't be used for normal purposes and historically bad blocks were linked to inode 1, thus the root inode is 2 (inode 1 is no longer used for this purpose, however numerous dump tapes make this assumption, so we are stuck with it)." Signed-off-by: Ronald G. Minnich <[email protected]>
- Loading branch information
1 parent
676b9e5
commit 2280e52
Showing
4 changed files
with
44 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters