unix: add dm-ioctl constants and types

This interface is used by devicemapper framework to manage its block
devices.

Change-Id: If86a679461867dac18b56bdf005567ffc4b7f951
Reviewed-on: https://go-review.googlesource.com/c/sys/+/247437
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Anatol Pomozov
2020-08-14 20:00:57 +00:00
committed by Ian Lance Taylor
parent 6a926be9bd
commit 3d37ad5750
18 changed files with 207 additions and 0 deletions
+9
View File
@@ -81,6 +81,15 @@ func main() {
convertStatvfsRegex := regexp.MustCompile(`((Fstype|Mnton|Mntfrom)name)(\s+)\[(\d+)\]int8`)
b = convertStatvfsRegex.ReplaceAll(b, []byte("$1$3[$4]byte"))
// Convert []int8 to []byte in device mapper ioctl interface
convertDmIoctlNames := regexp.MustCompile(`(Name|Uuid|Target_type|Data)(\s+)\[(\d+)\]u?int8`)
dmIoctlTypes := regexp.MustCompile(`type Dm(\S+) struct {[^}]*}`)
dmStructs := dmIoctlTypes.FindAll(b, -1)
for _, s := range dmStructs {
newNames := convertDmIoctlNames.ReplaceAll(s, []byte("$1$2[$3]byte"))
b = bytes.Replace(b, s, newNames, 1)
}
// Convert [1024]int8 to [1024]byte in Ptmget members
convertPtmget := regexp.MustCompile(`([SC]n)(\s+)\[(\d+)\]u?int8`)
b = convertPtmget.ReplaceAll(b, []byte("$1[$3]byte"))