Further work on Inode
This commit is contained in:
+50
-6
@@ -1,6 +1,12 @@
|
||||
package inode
|
||||
|
||||
type CommonHeader struct {
|
||||
import (
|
||||
"encoding/binary"
|
||||
"io"
|
||||
)
|
||||
|
||||
//InodeCommon is the comon header for all inodes
|
||||
type InodeCommon struct {
|
||||
InodeType uint16
|
||||
Permissions uint16
|
||||
UID uint16
|
||||
@@ -9,6 +15,7 @@ type CommonHeader struct {
|
||||
Number uint32
|
||||
}
|
||||
|
||||
//BasicDirectory is self explainatory
|
||||
type BasicDirectory struct {
|
||||
DirectoryIndex uint32
|
||||
HardLinks uint32
|
||||
@@ -17,6 +24,7 @@ type BasicDirectory struct {
|
||||
ParentInodeNumber uint32
|
||||
}
|
||||
|
||||
//ExtendedDirectoryInit is the information that can be directoy decoded
|
||||
type ExtendedDirectoryInit struct {
|
||||
HardLinks uint32
|
||||
DirectorySize uint32
|
||||
@@ -27,19 +35,31 @@ type ExtendedDirectoryInit struct {
|
||||
XattrIndex uint32
|
||||
}
|
||||
|
||||
//ExtendedDirectory is a directory with extra info
|
||||
type ExtendedDirectory struct {
|
||||
ExtendedDirectoryInit
|
||||
//TODO indexes []DirectoryIndex
|
||||
Init ExtendedDirectoryInit
|
||||
//TODO: indexes []DirectoryIndex
|
||||
}
|
||||
|
||||
//NewExtendedDirectory creates a new ExtendedDirectory
|
||||
func NewExtendedDirectory(rdr *io.Reader) (*ExtendedDirectory, error) {
|
||||
var inode ExtendedDirectory
|
||||
err := binary.Read(*rdr, binary.LittleEndian, inode.Init)
|
||||
//TODO: Read directory indexes
|
||||
return &inode, err
|
||||
}
|
||||
|
||||
//BasicFile is self explainatory
|
||||
type BasicFile struct {
|
||||
BlockStart uint32
|
||||
FragmentIndex uint32
|
||||
FragmentOffset uint32
|
||||
Size uint32
|
||||
BlockSizes []uint32
|
||||
//TODO: possibly fix BlockSizes
|
||||
}
|
||||
|
||||
//ExtendedFile is a file with additional information
|
||||
type ExtendedFile struct {
|
||||
BlockStart uint32
|
||||
Size uint32
|
||||
@@ -49,6 +69,7 @@ type ExtendedFile struct {
|
||||
FragmentOffset uint32
|
||||
XattrIndex uint32
|
||||
BlockSizes []uint32
|
||||
//TODO: possibly fix BlockSizes
|
||||
}
|
||||
|
||||
type BasicSymlinkInit struct {
|
||||
@@ -57,8 +78,19 @@ type BasicSymlinkInit struct {
|
||||
}
|
||||
|
||||
type BasicSymlink struct {
|
||||
BasicSymlinkInit
|
||||
targetPath []byte //len is TargetPathSize
|
||||
Init BasicSymlinkInit
|
||||
targetPath []uint8 //len is TargetPathSize
|
||||
}
|
||||
|
||||
func NewBasicSymlink(rdr *io.Reader) (*BasicSymlink, error) {
|
||||
var inode BasicSymlink
|
||||
err := binary.Read(*rdr, binary.LittleEndian, inode.Init)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
inode.targetPath = make([]uint8, inode.Init.TargetPathSize)
|
||||
err = binary.Read(*rdr, binary.LittleEndian, inode.targetPath)
|
||||
return &inode, err
|
||||
}
|
||||
|
||||
type ExtendedSymlinkInit struct {
|
||||
@@ -67,10 +99,22 @@ type ExtendedSymlinkInit struct {
|
||||
}
|
||||
|
||||
type ExtendedSymlink struct {
|
||||
targetPath []byte
|
||||
Init ExtendedSymlinkInit
|
||||
TargetPath []uint8
|
||||
XattrIndex uint32
|
||||
}
|
||||
|
||||
func NewExtendedSymlink(rdr *io.Reader) (*ExtendedSymlink, error) {
|
||||
var inode ExtendedSymlink
|
||||
err := binary.Read(*rdr, binary.LittleEndian, inode.Init)
|
||||
if err != nil {
|
||||
return &inode, err
|
||||
}
|
||||
inode.TargetPath = make([]uint8, inode.Init.TargetPathSize)
|
||||
err = binary.Read(*rdr, binary.LittleEndian, &inode.XattrIndex)
|
||||
return &inode, err
|
||||
}
|
||||
|
||||
type BasicDevice struct {
|
||||
HardLinks uint32
|
||||
Device uint32
|
||||
|
||||
Reference in New Issue
Block a user