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-01 13:08:58 -07:00
committed by Ian Lance Taylor
parent 6a926be9bd
commit 3d37ad5750
18 changed files with 207 additions and 0 deletions

View File

@@ -85,6 +85,7 @@ struct termios2 {
#include <linux/cgroupstats.h>
#include <linux/cryptouser.h>
#include <linux/devlink.h>
#include <linux/dm-ioctl.h>
#include <linux/errqueue.h>
#include <linux/fanotify.h>
#include <linux/filter.h>
@@ -471,6 +472,25 @@ type FscryptRemoveKeyArg C.struct_fscrypt_remove_key_arg
type FscryptGetKeyStatusArg C.struct_fscrypt_get_key_status_arg
// Device Mapper
type DmIoctl C.struct_dm_ioctl
type DmTargetSpec C.struct_dm_target_spec
type DmTargetDeps C.struct_dm_target_deps
type DmNameList C.struct_dm_name_list
type DmTargetVersions C.struct_dm_target_versions
type DmTargetMsg C.struct_dm_target_msg
const (
SizeofDmIoctl = C.sizeof_struct_dm_ioctl
SizeofDmTargetSpec = C.sizeof_struct_dm_target_spec
)
// Structure for Keyctl
type KeyctlDHParams C.struct_keyctl_dh_params

View File

@@ -196,6 +196,7 @@ struct ltchars {
#include <linux/capability.h>
#include <linux/cryptouser.h>
#include <linux/devlink.h>
#include <linux/dm-ioctl.h>
#include <linux/errqueue.h>
#include <linux/falloc.h>
#include <linux/fanotify.h>
@@ -517,6 +518,7 @@ ccflags="$@"
$2 ~ /^FS_IOC_.*(ENCRYPTION|VERITY|[GS]ETFLAGS)/ ||
$2 ~ /^FS_VERITY_/ ||
$2 ~ /^FSCRYPT_/ ||
$2 ~ /^DM_/ ||
$2 ~ /^GRND_/ ||
$2 ~ /^RND/ ||
$2 ~ /^KEY_(SPEC|REQKEY_DEFL)_/ ||

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"))

View File

@@ -377,6 +377,51 @@ const (
DEVMEM_MAGIC = 0x454d444d
DEVPTS_SUPER_MAGIC = 0x1cd1
DMA_BUF_MAGIC = 0x444d4142
DM_ACTIVE_PRESENT_FLAG = 0x20
DM_BUFFER_FULL_FLAG = 0x100
DM_CONTROL_NODE = "control"
DM_DATA_OUT_FLAG = 0x10000
DM_DEFERRED_REMOVE = 0x20000
DM_DEV_ARM_POLL = 0xc138fd10
DM_DEV_CREATE = 0xc138fd03
DM_DEV_REMOVE = 0xc138fd04
DM_DEV_RENAME = 0xc138fd05
DM_DEV_SET_GEOMETRY = 0xc138fd0f
DM_DEV_STATUS = 0xc138fd07
DM_DEV_SUSPEND = 0xc138fd06
DM_DEV_WAIT = 0xc138fd08
DM_DIR = "mapper"
DM_GET_TARGET_VERSION = 0xc138fd11
DM_INACTIVE_PRESENT_FLAG = 0x40
DM_INTERNAL_SUSPEND_FLAG = 0x40000
DM_IOCTL = 0xfd
DM_LIST_DEVICES = 0xc138fd02
DM_LIST_VERSIONS = 0xc138fd0d
DM_MAX_TYPE_NAME = 0x10
DM_NAME_LEN = 0x80
DM_NOFLUSH_FLAG = 0x800
DM_PERSISTENT_DEV_FLAG = 0x8
DM_QUERY_INACTIVE_TABLE_FLAG = 0x1000
DM_READONLY_FLAG = 0x1
DM_REMOVE_ALL = 0xc138fd01
DM_SECURE_DATA_FLAG = 0x8000
DM_SKIP_BDGET_FLAG = 0x200
DM_SKIP_LOCKFS_FLAG = 0x400
DM_STATUS_TABLE_FLAG = 0x10
DM_SUSPEND_FLAG = 0x2
DM_TABLE_CLEAR = 0xc138fd0a
DM_TABLE_DEPS = 0xc138fd0b
DM_TABLE_LOAD = 0xc138fd09
DM_TABLE_STATUS = 0xc138fd0c
DM_TARGET_MSG = 0xc138fd0e
DM_UEVENT_GENERATED_FLAG = 0x2000
DM_UUID_FLAG = 0x4000
DM_UUID_LEN = 0x81
DM_VERSION = 0xc138fd00
DM_VERSION_EXTRA = "-ioctl (2020-02-27)"
DM_VERSION_MAJOR = 0x4
DM_VERSION_MINOR = 0x2a
DM_VERSION_PATCHLEVEL = 0x0
DT_BLK = 0x6
DT_CHR = 0x2
DT_DIR = 0x4

View File

@@ -140,6 +140,48 @@ type FscryptGetKeyStatusArg struct {
_ [13]uint32
}
type DmIoctl struct {
Version [3]uint32
Data_size uint32
Data_start uint32
Target_count uint32
Open_count int32
Flags uint32
Event_nr uint32
_ uint32
Dev uint64
Name [128]byte
Uuid [129]byte
Data [7]byte
}
type DmTargetSpec struct {
Sector_start uint64
Length uint64
Status int32
Next uint32
Target_type [16]byte
}
type DmTargetDeps struct {
Count uint32
_ uint32
}
type DmTargetVersions struct {
Next uint32
Version [3]uint32
}
type DmTargetMsg struct {
Sector uint64
}
const (
SizeofDmIoctl = 0x138
SizeofDmTargetSpec = 0x28
)
type KeyctlDHParams struct {
Private int32
Prime int32

View File

@@ -117,6 +117,11 @@ type Flock_t struct {
Pid int32
}
type DmNameList struct {
Dev uint64
Next uint32
}
const (
FADV_DONTNEED = 0x4
FADV_NOREUSE = 0x5

View File

@@ -117,6 +117,13 @@ type Flock_t struct {
_ [4]byte
}
type DmNameList struct {
Dev uint64
Next uint32
Name [0]byte
_ [4]byte
}
const (
FADV_DONTNEED = 0x4
FADV_NOREUSE = 0x5

View File

@@ -121,6 +121,13 @@ type Flock_t struct {
_ [4]byte
}
type DmNameList struct {
Dev uint64
Next uint32
Name [0]byte
_ [4]byte
}
const (
FADV_DONTNEED = 0x4
FADV_NOREUSE = 0x5

View File

@@ -118,6 +118,13 @@ type Flock_t struct {
_ [4]byte
}
type DmNameList struct {
Dev uint64
Next uint32
Name [0]byte
_ [4]byte
}
const (
FADV_DONTNEED = 0x4
FADV_NOREUSE = 0x5

View File

@@ -120,6 +120,13 @@ type Flock_t struct {
_ [4]byte
}
type DmNameList struct {
Dev uint64
Next uint32
Name [0]byte
_ [4]byte
}
const (
FADV_DONTNEED = 0x4
FADV_NOREUSE = 0x5

View File

@@ -118,6 +118,13 @@ type Flock_t struct {
_ [4]byte
}
type DmNameList struct {
Dev uint64
Next uint32
Name [0]byte
_ [4]byte
}
const (
FADV_DONTNEED = 0x4
FADV_NOREUSE = 0x5

View File

@@ -118,6 +118,13 @@ type Flock_t struct {
_ [4]byte
}
type DmNameList struct {
Dev uint64
Next uint32
Name [0]byte
_ [4]byte
}
const (
FADV_DONTNEED = 0x4
FADV_NOREUSE = 0x5

View File

@@ -120,6 +120,13 @@ type Flock_t struct {
_ [4]byte
}
type DmNameList struct {
Dev uint64
Next uint32
Name [0]byte
_ [4]byte
}
const (
FADV_DONTNEED = 0x4
FADV_NOREUSE = 0x5

View File

@@ -119,6 +119,13 @@ type Flock_t struct {
_ [4]byte
}
type DmNameList struct {
Dev uint64
Next uint32
Name [0]byte
_ [4]byte
}
const (
FADV_DONTNEED = 0x4
FADV_NOREUSE = 0x5

View File

@@ -119,6 +119,13 @@ type Flock_t struct {
_ [4]byte
}
type DmNameList struct {
Dev uint64
Next uint32
Name [0]byte
_ [4]byte
}
const (
FADV_DONTNEED = 0x4
FADV_NOREUSE = 0x5

View File

@@ -118,6 +118,13 @@ type Flock_t struct {
_ [4]byte
}
type DmNameList struct {
Dev uint64
Next uint32
Name [0]byte
_ [4]byte
}
const (
FADV_DONTNEED = 0x4
FADV_NOREUSE = 0x5

View File

@@ -117,6 +117,13 @@ type Flock_t struct {
_ [4]byte
}
type DmNameList struct {
Dev uint64
Next uint32
Name [0]byte
_ [4]byte
}
const (
FADV_DONTNEED = 0x6
FADV_NOREUSE = 0x7

View File

@@ -121,6 +121,13 @@ type Flock_t struct {
_ [2]byte
}
type DmNameList struct {
Dev uint64
Next uint32
Name [0]byte
_ [4]byte
}
const (
FADV_DONTNEED = 0x4
FADV_NOREUSE = 0x5