Skip to content

Commit 0c100ab

Browse files
committed
chrootarchive: Add a const for tar options fd
Minor unrelated cleanup. Signed-off-by: Colin Walters <[email protected]>
1 parent e9e9e1d commit 0c100ab

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pkg/chrootarchive/archive_unix.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ func (dst *unpackDestination) Close() error {
2929
return dst.root.Close()
3030
}
3131

32+
// tarOptionsDescriptor is passed as an extra file
33+
const tarOptionsDescriptor = 3
3234
// rootFileDescriptor is passed as an extra file
3335
const rootFileDescriptor = 4
3436

@@ -50,7 +52,7 @@ func untar() {
5052
var options archive.TarOptions
5153

5254
// read the options from the pipe "ExtraFiles"
53-
if err := json.NewDecoder(os.NewFile(3, "options")).Decode(&options); err != nil {
55+
if err := json.NewDecoder(os.NewFile(tarOptionsDescriptor, "options")).Decode(&options); err != nil {
5456
fatal(err)
5557
}
5658

@@ -131,6 +133,7 @@ func invokeUnpack(decompressedArchive io.Reader, dest *unpackDestination, option
131133
cmd := reexec.Command("storage-untar", dest.dest, procPathForFd(rootFileDescriptor))
132134
cmd.Stdin = decompressedArchive
133135

136+
// If you change this, change tarOptionsDescriptor above
134137
cmd.ExtraFiles = append(cmd.ExtraFiles, r) // fd 3
135138
// If you change this, change rootFileDescriptor above too
136139
cmd.ExtraFiles = append(cmd.ExtraFiles, dest.root) // fd 4

0 commit comments

Comments
 (0)