go.mod: github.com/Microsoft/hcsshim v0.8.16
full diff: https://github.com/microsoft/hcsshim/compare/v0.8.15...v0.8.16 also updating github.com/Microsoft/hcsshim/test to current master Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
57
vendor/github.com/Microsoft/hcsshim/ext4/internal/compactext4/compact.go
generated
vendored
57
vendor/github.com/Microsoft/hcsshim/ext4/internal/compactext4/compact.go
generated
vendored
@@ -514,6 +514,45 @@ func (w *Writer) lookup(name string, mustExist bool) (*inode, *inode, string, er
|
||||
return dir, child, childname, nil
|
||||
}
|
||||
|
||||
// CreateWithParents adds a file to the file system creating the parent directories in the path if
|
||||
// they don't exist (like `mkdir -p`). These non existing parent directories are created
|
||||
// with the same permissions as that of it's parent directory. It is expected that the a
|
||||
// call to make these parent directories will be made at a later point with the correct
|
||||
// permissions, at that time the permissions of these directories will be updated.
|
||||
func (w *Writer) CreateWithParents(name string, f *File) error {
|
||||
// go through the directories in the path one by one and create the
|
||||
// parent directories if they don't exist.
|
||||
cleanname := path.Clean("/" + name)[1:]
|
||||
parentDirs, _ := path.Split(cleanname)
|
||||
currentPath := ""
|
||||
root := w.root()
|
||||
dirname := ""
|
||||
for parentDirs != "" {
|
||||
dirname, parentDirs = splitFirst(parentDirs)
|
||||
currentPath += "/" + dirname
|
||||
if _, ok := root.Children[dirname]; !ok {
|
||||
f := &File{
|
||||
Mode: root.Mode,
|
||||
Atime: time.Now(),
|
||||
Mtime: time.Now(),
|
||||
Ctime: time.Now(),
|
||||
Crtime: time.Now(),
|
||||
Size: 0,
|
||||
Uid: root.Uid,
|
||||
Gid: root.Gid,
|
||||
Devmajor: root.Devmajor,
|
||||
Devminor: root.Devminor,
|
||||
Xattrs: make(map[string][]byte),
|
||||
}
|
||||
if err := w.Create(currentPath, f); err != nil {
|
||||
return fmt.Errorf("failed while creating parent directories: %w", err)
|
||||
}
|
||||
}
|
||||
root = root.Children[dirname]
|
||||
}
|
||||
return w.Create(name, f)
|
||||
}
|
||||
|
||||
// Create adds a file to the file system.
|
||||
func (w *Writer) Create(name string, f *File) error {
|
||||
if err := w.finishInode(); err != nil {
|
||||
@@ -693,7 +732,7 @@ func (w *Writer) seekBlock(block uint32) {
|
||||
func (w *Writer) nextBlock() {
|
||||
if w.pos%blockSize != 0 {
|
||||
// Simplify callers; w.err is updated on failure.
|
||||
w.zero(blockSize - w.pos%blockSize)
|
||||
_, _ = w.zero(blockSize - w.pos%blockSize)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -743,7 +782,7 @@ func (w *Writer) writeExtents(inode *inode) error {
|
||||
extents [4]format.ExtentLeafNode
|
||||
}
|
||||
fillExtents(&root.hdr, root.extents[:extents], startBlock, 0, blocks)
|
||||
binary.Write(&b, binary.LittleEndian, root)
|
||||
_ = binary.Write(&b, binary.LittleEndian, root)
|
||||
} else if extents <= 4*extentsPerBlock {
|
||||
const extentsPerBlock = blockSize/extentNodeSize - 1
|
||||
extentBlocks := extents/extentsPerBlock + 1
|
||||
@@ -778,12 +817,12 @@ func (w *Writer) writeExtents(inode *inode) error {
|
||||
|
||||
offset := i * extentsPerBlock * maxBlocksPerExtent
|
||||
fillExtents(&node.hdr, node.extents[:extentsInBlock], startBlock+offset, offset, blocks)
|
||||
binary.Write(&b2, binary.LittleEndian, node)
|
||||
_ = binary.Write(&b2, binary.LittleEndian, node)
|
||||
if _, err := w.write(b2.Next(blockSize)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
binary.Write(&b, binary.LittleEndian, root)
|
||||
_ = binary.Write(&b, binary.LittleEndian, root)
|
||||
} else {
|
||||
panic("file too big")
|
||||
}
|
||||
@@ -1021,12 +1060,12 @@ func (w *Writer) writeInodeTable(tableSize uint32) error {
|
||||
binary.LittleEndian.PutUint32(binode.Block[4:], dev)
|
||||
}
|
||||
|
||||
binary.Write(&b, binary.LittleEndian, binode)
|
||||
_ = binary.Write(&b, binary.LittleEndian, binode)
|
||||
b.Truncate(inodeUsedSize)
|
||||
n, _ := b.Write(inode.XattrInline)
|
||||
io.CopyN(&b, zero, int64(inodeExtraSize-n))
|
||||
_, _ = io.CopyN(&b, zero, int64(inodeExtraSize-n))
|
||||
} else {
|
||||
io.CopyN(&b, zero, inodeSize)
|
||||
_, _ = io.CopyN(&b, zero, inodeSize)
|
||||
}
|
||||
if _, err := w.write(b.Next(inodeSize)); err != nil {
|
||||
return err
|
||||
@@ -1159,7 +1198,7 @@ func (w *Writer) Close() error {
|
||||
diskSize = minSize
|
||||
}
|
||||
|
||||
usedGdBlocks := (groups-1)/groupDescriptorSize + 1
|
||||
usedGdBlocks := (groups-1)/groupsPerDescriptorBlock + 1
|
||||
if usedGdBlocks > w.gdBlocks {
|
||||
return exceededMaxSizeError{w.maxDiskSize}
|
||||
}
|
||||
@@ -1276,7 +1315,7 @@ func (w *Writer) Close() error {
|
||||
if w.supportInlineData {
|
||||
sb.FeatureIncompat |= format.IncompatInlineData
|
||||
}
|
||||
binary.Write(b, binary.LittleEndian, sb)
|
||||
_ = binary.Write(b, binary.LittleEndian, sb)
|
||||
w.seekBlock(0)
|
||||
if _, err := w.write(blk[:]); err != nil {
|
||||
return err
|
||||
|
||||
37
vendor/github.com/Microsoft/hcsshim/ext4/tar2ext4/tar2ext4.go
generated
vendored
37
vendor/github.com/Microsoft/hcsshim/ext4/tar2ext4/tar2ext4.go
generated
vendored
@@ -5,10 +5,12 @@ import (
|
||||
"bufio"
|
||||
"encoding/binary"
|
||||
"io"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/Microsoft/hcsshim/ext4/internal/compactext4"
|
||||
"github.com/Microsoft/hcsshim/ext4/internal/format"
|
||||
)
|
||||
|
||||
type params struct {
|
||||
@@ -146,7 +148,7 @@ func Convert(r io.Reader, w io.ReadWriteSeeker, options ...Option) error {
|
||||
}
|
||||
f.Mode &= ^compactext4.TypeMask
|
||||
f.Mode |= typ
|
||||
err = fs.Create(hdr.Name, f)
|
||||
err = fs.CreateWithParents(hdr.Name, f)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -172,3 +174,36 @@ func Convert(r io.Reader, w io.ReadWriteSeeker, options ...Option) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ReadExt4SuperBlock reads and returns ext4 super block from VHD
|
||||
//
|
||||
// The layout on disk is as follows:
|
||||
// | Group 0 padding | - 1024 bytes
|
||||
// | ext4 SuperBlock | - 1 block
|
||||
// | Group Descriptors | - many blocks
|
||||
// | Reserved GDT Blocks | - many blocks
|
||||
// | Data Block Bitmap | - 1 block
|
||||
// | inode Bitmap | - 1 block
|
||||
// | inode Table | - many blocks
|
||||
// | Data Blocks | - many blocks
|
||||
//
|
||||
// More details can be found here https://ext4.wiki.kernel.org/index.php/Ext4_Disk_Layout
|
||||
//
|
||||
// Our goal is to skip the Group 0 padding, read and return the ext4 SuperBlock
|
||||
func ReadExt4SuperBlock(vhdPath string) (*format.SuperBlock, error) {
|
||||
vhd, err := os.OpenFile(vhdPath, os.O_RDONLY, 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer vhd.Close()
|
||||
|
||||
// Skip padding at the start
|
||||
if _, err := vhd.Seek(1024, io.SeekStart); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var sb format.SuperBlock
|
||||
if err := binary.Read(vhd, binary.LittleEndian, &sb); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &sb, nil
|
||||
}
|
||||
|
||||
2
vendor/github.com/Microsoft/hcsshim/ext4/tar2ext4/vhdfooter.go
generated
vendored
2
vendor/github.com/Microsoft/hcsshim/ext4/tar2ext4/vhdfooter.go
generated
vendored
@@ -56,7 +56,7 @@ func calculateCheckSum(footer *vhdFooter) uint32 {
|
||||
footer.Checksum = 0
|
||||
|
||||
buf := &bytes.Buffer{}
|
||||
binary.Write(buf, binary.BigEndian, footer)
|
||||
_ = binary.Write(buf, binary.BigEndian, footer)
|
||||
|
||||
var chk uint32
|
||||
bufBytes := buf.Bytes()
|
||||
|
||||
Reference in New Issue
Block a user