浏览代码

unix: add Linux blkpg_ioctl_arg and blkpg_partition types

For manipulating Linux partitions with the BLKPG ioctl.

Change-Id: I2196038ccfc39ecd6926817c3b310d0837220095
Reviewed-on: https://go-review.googlesource.com/125642
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Brad Fitzpatrick 7 年之前
父节点
当前提交
e3f9388ec6

+ 23 - 0
unix/linux/types.go

@@ -73,6 +73,7 @@ package unix
 #include <linux/socket.h>
 #include <linux/socket.h>
 #include <linux/hdreg.h>
 #include <linux/hdreg.h>
 #include <linux/rtc.h>
 #include <linux/rtc.h>
+#include <linux/blkpg.h>
 
 
 // abi/abi.h generated by mkall.go.
 // abi/abi.h generated by mkall.go.
 #include "abi/abi.h"
 #include "abi/abi.h"
@@ -312,6 +313,15 @@ struct ustat {
 	char f_fpack[6];
 	char f_fpack[6];
 };
 };
 
 
+// my_blkpg_partition is blkpg_partition with unsigned devname & volname.
+struct my_blkpg_partition {
+	long long start;
+	long long length;
+	int pno;
+	unsigned char devname[BLKPG_DEVNAMELTH];
+	unsigned char volname[BLKPG_VOLNAMELTH];
+};
+
 */
 */
 import "C"
 import "C"
 
 
@@ -1516,3 +1526,16 @@ type RTCTime C.struct_rtc_time
 type RTCWkAlrm C.struct_rtc_wkalrm
 type RTCWkAlrm C.struct_rtc_wkalrm
 
 
 type RTCPLLInfo C.struct_rtc_pll_info
 type RTCPLLInfo C.struct_rtc_pll_info
+
+// BLKPG ioctl:
+
+type BlkpgIoctlArg C.struct_blkpg_ioctl_arg
+
+type BlkpgPartition C.struct_my_blkpg_partition
+
+const (
+	BLKPG                  = C.BLKPG
+	BLKPG_ADD_PARTITION    = C.BLKPG_ADD_PARTITION
+	BLKPG_DEL_PARTITION    = C.BLKPG_DEL_PARTITION
+	BLKPG_RESIZE_PARTITION = C.BLKPG_RESIZE_PARTITION
+)

+ 22 - 0
unix/ztypes_linux_386.go

@@ -1852,3 +1852,25 @@ type RTCPLLInfo struct {
 	Negmult int32
 	Negmult int32
 	Clock   int32
 	Clock   int32
 }
 }
+
+type BlkpgIoctlArg struct {
+	Op      int32
+	Flags   int32
+	Datalen int32
+	Data    *byte
+}
+
+type BlkpgPartition struct {
+	Start   int64
+	Length  int64
+	Pno     int32
+	Devname [64]uint8
+	Volname [64]uint8
+}
+
+const (
+	BLKPG                  = 0x1269
+	BLKPG_ADD_PARTITION    = 0x1
+	BLKPG_DEL_PARTITION    = 0x2
+	BLKPG_RESIZE_PARTITION = 0x3
+)

+ 24 - 0
unix/ztypes_linux_amd64.go

@@ -1872,3 +1872,27 @@ type RTCPLLInfo struct {
 	Negmult int32
 	Negmult int32
 	Clock   int64
 	Clock   int64
 }
 }
+
+type BlkpgIoctlArg struct {
+	Op      int32
+	Flags   int32
+	Datalen int32
+	_       [4]byte
+	Data    *byte
+}
+
+type BlkpgPartition struct {
+	Start   int64
+	Length  int64
+	Pno     int32
+	Devname [64]uint8
+	Volname [64]uint8
+	_       [4]byte
+}
+
+const (
+	BLKPG                  = 0x1269
+	BLKPG_ADD_PARTITION    = 0x1
+	BLKPG_DEL_PARTITION    = 0x2
+	BLKPG_RESIZE_PARTITION = 0x3
+)

+ 23 - 0
unix/ztypes_linux_arm.go

@@ -1841,3 +1841,26 @@ type RTCPLLInfo struct {
 	Negmult int32
 	Negmult int32
 	Clock   int32
 	Clock   int32
 }
 }
+
+type BlkpgIoctlArg struct {
+	Op      int32
+	Flags   int32
+	Datalen int32
+	Data    *byte
+}
+
+type BlkpgPartition struct {
+	Start   int64
+	Length  int64
+	Pno     int32
+	Devname [64]uint8
+	Volname [64]uint8
+	_       [4]byte
+}
+
+const (
+	BLKPG                  = 0x1269
+	BLKPG_ADD_PARTITION    = 0x1
+	BLKPG_DEL_PARTITION    = 0x2
+	BLKPG_RESIZE_PARTITION = 0x3
+)

+ 24 - 0
unix/ztypes_linux_arm64.go

@@ -1851,3 +1851,27 @@ type RTCPLLInfo struct {
 	Negmult int32
 	Negmult int32
 	Clock   int64
 	Clock   int64
 }
 }
+
+type BlkpgIoctlArg struct {
+	Op      int32
+	Flags   int32
+	Datalen int32
+	_       [4]byte
+	Data    *byte
+}
+
+type BlkpgPartition struct {
+	Start   int64
+	Length  int64
+	Pno     int32
+	Devname [64]uint8
+	Volname [64]uint8
+	_       [4]byte
+}
+
+const (
+	BLKPG                  = 0x1269
+	BLKPG_ADD_PARTITION    = 0x1
+	BLKPG_DEL_PARTITION    = 0x2
+	BLKPG_RESIZE_PARTITION = 0x3
+)

+ 23 - 0
unix/ztypes_linux_mips.go

@@ -1846,3 +1846,26 @@ type RTCPLLInfo struct {
 	Negmult int32
 	Negmult int32
 	Clock   int32
 	Clock   int32
 }
 }
+
+type BlkpgIoctlArg struct {
+	Op      int32
+	Flags   int32
+	Datalen int32
+	Data    *byte
+}
+
+type BlkpgPartition struct {
+	Start   int64
+	Length  int64
+	Pno     int32
+	Devname [64]uint8
+	Volname [64]uint8
+	_       [4]byte
+}
+
+const (
+	BLKPG                  = 0x20001269
+	BLKPG_ADD_PARTITION    = 0x1
+	BLKPG_DEL_PARTITION    = 0x2
+	BLKPG_RESIZE_PARTITION = 0x3
+)

+ 24 - 0
unix/ztypes_linux_mips64.go

@@ -1853,3 +1853,27 @@ type RTCPLLInfo struct {
 	Negmult int32
 	Negmult int32
 	Clock   int64
 	Clock   int64
 }
 }
+
+type BlkpgIoctlArg struct {
+	Op      int32
+	Flags   int32
+	Datalen int32
+	_       [4]byte
+	Data    *byte
+}
+
+type BlkpgPartition struct {
+	Start   int64
+	Length  int64
+	Pno     int32
+	Devname [64]uint8
+	Volname [64]uint8
+	_       [4]byte
+}
+
+const (
+	BLKPG                  = 0x20001269
+	BLKPG_ADD_PARTITION    = 0x1
+	BLKPG_DEL_PARTITION    = 0x2
+	BLKPG_RESIZE_PARTITION = 0x3
+)

+ 24 - 0
unix/ztypes_linux_mips64le.go

@@ -1853,3 +1853,27 @@ type RTCPLLInfo struct {
 	Negmult int32
 	Negmult int32
 	Clock   int64
 	Clock   int64
 }
 }
+
+type BlkpgIoctlArg struct {
+	Op      int32
+	Flags   int32
+	Datalen int32
+	_       [4]byte
+	Data    *byte
+}
+
+type BlkpgPartition struct {
+	Start   int64
+	Length  int64
+	Pno     int32
+	Devname [64]uint8
+	Volname [64]uint8
+	_       [4]byte
+}
+
+const (
+	BLKPG                  = 0x20001269
+	BLKPG_ADD_PARTITION    = 0x1
+	BLKPG_DEL_PARTITION    = 0x2
+	BLKPG_RESIZE_PARTITION = 0x3
+)

+ 23 - 0
unix/ztypes_linux_mipsle.go

@@ -1846,3 +1846,26 @@ type RTCPLLInfo struct {
 	Negmult int32
 	Negmult int32
 	Clock   int32
 	Clock   int32
 }
 }
+
+type BlkpgIoctlArg struct {
+	Op      int32
+	Flags   int32
+	Datalen int32
+	Data    *byte
+}
+
+type BlkpgPartition struct {
+	Start   int64
+	Length  int64
+	Pno     int32
+	Devname [64]uint8
+	Volname [64]uint8
+	_       [4]byte
+}
+
+const (
+	BLKPG                  = 0x20001269
+	BLKPG_ADD_PARTITION    = 0x1
+	BLKPG_DEL_PARTITION    = 0x2
+	BLKPG_RESIZE_PARTITION = 0x3
+)

+ 24 - 0
unix/ztypes_linux_ppc64.go

@@ -1861,3 +1861,27 @@ type RTCPLLInfo struct {
 	Negmult int32
 	Negmult int32
 	Clock   int64
 	Clock   int64
 }
 }
+
+type BlkpgIoctlArg struct {
+	Op      int32
+	Flags   int32
+	Datalen int32
+	_       [4]byte
+	Data    *byte
+}
+
+type BlkpgPartition struct {
+	Start   int64
+	Length  int64
+	Pno     int32
+	Devname [64]uint8
+	Volname [64]uint8
+	_       [4]byte
+}
+
+const (
+	BLKPG                  = 0x20001269
+	BLKPG_ADD_PARTITION    = 0x1
+	BLKPG_DEL_PARTITION    = 0x2
+	BLKPG_RESIZE_PARTITION = 0x3
+)

+ 24 - 0
unix/ztypes_linux_ppc64le.go

@@ -1861,3 +1861,27 @@ type RTCPLLInfo struct {
 	Negmult int32
 	Negmult int32
 	Clock   int64
 	Clock   int64
 }
 }
+
+type BlkpgIoctlArg struct {
+	Op      int32
+	Flags   int32
+	Datalen int32
+	_       [4]byte
+	Data    *byte
+}
+
+type BlkpgPartition struct {
+	Start   int64
+	Length  int64
+	Pno     int32
+	Devname [64]uint8
+	Volname [64]uint8
+	_       [4]byte
+}
+
+const (
+	BLKPG                  = 0x20001269
+	BLKPG_ADD_PARTITION    = 0x1
+	BLKPG_DEL_PARTITION    = 0x2
+	BLKPG_RESIZE_PARTITION = 0x3
+)

+ 24 - 0
unix/ztypes_linux_s390x.go

@@ -1878,3 +1878,27 @@ type RTCPLLInfo struct {
 	Negmult int32
 	Negmult int32
 	Clock   int64
 	Clock   int64
 }
 }
+
+type BlkpgIoctlArg struct {
+	Op      int32
+	Flags   int32
+	Datalen int32
+	_       [4]byte
+	Data    *byte
+}
+
+type BlkpgPartition struct {
+	Start   int64
+	Length  int64
+	Pno     int32
+	Devname [64]uint8
+	Volname [64]uint8
+	_       [4]byte
+}
+
+const (
+	BLKPG                  = 0x1269
+	BLKPG_ADD_PARTITION    = 0x1
+	BLKPG_DEL_PARTITION    = 0x2
+	BLKPG_RESIZE_PARTITION = 0x3
+)