-
Notifications
You must be signed in to change notification settings - Fork 5
/
common.go
77 lines (65 loc) · 1.08 KB
/
common.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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
69
70
71
72
73
74
75
76
77
package main
import (
"errors"
"io"
"io/fs"
)
const cowAlignment = 4096
const cowMask = cowAlignment - 1
const cowMagic = "CAR!"
const cowEnd = "!RAC"
const (
tagHeader uint16 = iota + 1
tagName
tagData
tagLinkTarget
tagDevice
)
type fixedData struct {
Mode uint32
Uid uint32
Gid uint32
Mtime int64
}
type entry struct {
fixedData
name string
size uint64
localName string
link string
dev uint32
}
/*
Just a TLV (Type, Length, Value) structure,
but "type" is a reserved word in Go
*/
type tag struct {
Tag uint16
Length uint16
}
type paddedData struct {
Size uint64
Padding uint32
}
type archive interface {
archive(paths []string, outFile string) error
extract(inFile string) error
}
type dirMode struct {
name string
mode fs.FileMode
}
type car struct {
verbose bool
list bool
error int
infoFd io.Writer
superUser bool
dirModes []dirMode
destDir string
seekable bool
}
var reflinkError = errors.New("reflink not supported")
func round4k(size uint64) uint64 {
return (size + cowMask) & ^uint64(cowMask)
}