Commit 55188db2 by 流生

fix issue6 to convert volumeId to VolumeId

parent 32b48cc3
...@@ -41,8 +41,8 @@ ...@@ -41,8 +41,8 @@
"services/ecs", "services/ecs",
] ]
pruneopts = "NUT" pruneopts = "NUT"
revision = "02bfe7fbce66b3b7cd16b8640a95b5316e5ab4ed" revision = "7a807875136654e7ca7fcdd5511cd72b14cc25ba"
version = "1.60.131" version = "1.60.132"
[[projects]] [[projects]]
digest = "1:918521e77b229a961b2011082ee9c026d5077cab825be142f6e9771b61d03238" digest = "1:918521e77b229a961b2011082ee9c026d5077cab825be142f6e9771b61d03238"
...@@ -77,15 +77,15 @@ ...@@ -77,15 +77,15 @@
version = "v4.5.0" version = "v4.5.0"
[[projects]] [[projects]]
digest = "1:a1b2a5e38f79688ee8250942d5fa960525fceb1024c855c7bc76fa77b0f3cca2" digest = "1:633dde05baa7afd3544cfe4ac16fe3c5450b868cfc6b1558621ee39ebf2273ea"
name = "github.com/gogo/protobuf" name = "github.com/gogo/protobuf"
packages = [ packages = [
"proto", "proto",
"sortkeys", "sortkeys",
] ]
pruneopts = "NUT" pruneopts = "NUT"
revision = "ba06b47c162d49f2af050fb4c75bcbc86a159d5c" revision = "0ca988a254f991240804bf9821f3450d87ccbb1b"
version = "v1.2.1" version = "v1.3.0"
[[projects]] [[projects]]
digest = "1:796f9c63c68774a89eade387a8476e45ec2b34f5649b0726983204202c3649d6" digest = "1:796f9c63c68774a89eade387a8476e45ec2b34f5649b0726983204202c3649d6"
...@@ -378,14 +378,14 @@ ...@@ -378,14 +378,14 @@
[[projects]] [[projects]]
branch = "master" branch = "master"
digest = "1:25afefcce84027a47ec93143dba3fd60e4d0e7b66ada0e16b0b54b7fafc5091c" digest = "1:3589c63c3a3f0a6236ad09f8b227a2c4b28791001d4b934e8f33ac8b107391ef"
name = "golang.org/x/sys" name = "golang.org/x/sys"
packages = [ packages = [
"unix", "unix",
"windows", "windows",
] ]
pruneopts = "NUT" pruneopts = "NUT"
revision = "19e00faab6ad547203cd66b19e1281807329cf65" revision = "9109b7679e13aa34a54834cfb4949cac4b96e576"
[[projects]] [[projects]]
digest = "1:8d8faad6b12a3a4c819a3f9618cb6ee1fa1cfc33253abeeea8b55336721e3405" digest = "1:8d8faad6b12a3a4c819a3f9618cb6ee1fa1cfc33253abeeea8b55336721e3405"
......
...@@ -94,7 +94,7 @@ spec: ...@@ -94,7 +94,7 @@ spec:
- mountPath: /credentials - mountPath: /credentials
name: cloud-credentials name: cloud-credentials
initContainers: initContainers:
- image: registry.cn-hangzhou.aliyuncs.com/acs/velero-plugin-alibabacloud:v1.1 - image: registry.cn-hangzhou.aliyuncs.com/acs/velero-plugin-alibabacloud:v1.2
imagePullPolicy: IfNotPresent imagePullPolicy: IfNotPresent
name: velero-plugin-alibabacloud name: velero-plugin-alibabacloud
volumeMounts: volumeMounts:
......
...@@ -23,11 +23,24 @@ import ( ...@@ -23,11 +23,24 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"archive/tar"
"bufio"
"bytes"
"compress/gzip"
"fmt"
"github.com/heptio/velero/pkg/cloudprovider" "github.com/heptio/velero/pkg/cloudprovider"
"io/ioutil"
"math/rand"
"path/filepath"
"regexp"
"strings"
) )
const ( const (
regionKey = "region" RegionKey = "region"
OriginStr = "volumeId"
TargetStr = "VolumeId"
Workspace = "/tmp/velero-restore/"
) )
type bucketGetter interface { type bucketGetter interface {
...@@ -144,12 +157,12 @@ func (o *ObjectStore) PutObject(bucket, key string, body io.Reader) error { ...@@ -144,12 +157,12 @@ func (o *ObjectStore) PutObject(bucket, key string, body io.Reader) error {
if err != nil { if err != nil {
return err return err
} }
if o.encryptionKeyID != "" { if o.encryptionKeyID != "" {
err = bucketObj.PutObject(key, body, err = bucketObj.PutObject(key, body,
oss.ServerSideEncryption("KMS"), oss.ServerSideEncryption("KMS"),
oss.ServerSideEncryptionKeyID(o.encryptionKeyID)) oss.ServerSideEncryptionKeyID(o.encryptionKeyID))
} else { } else {
err = bucketObj.PutObject(key, body) err = bucketObj.PutObject(key, body)
} }
...@@ -172,8 +185,16 @@ func (o *ObjectStore) GetObject(bucket, key string) (io.ReadCloser, error) { ...@@ -172,8 +185,16 @@ func (o *ObjectStore) GetObject(bucket, key string) (io.ReadCloser, error) {
return nil, err return nil, err
} }
return bucketObj.GetObject(key) if strings.HasSuffix(key, ".tar.gz") {
body, err := bucketObj.GetObject(key)
if err != nil {
return nil, err
}
return CheckAndConvertVolumeId(body)
}
return bucketObj.GetObject(key)
} }
// ListCommonPrefixes interface // ListCommonPrefixes interface
...@@ -204,7 +225,6 @@ func (o *ObjectStore) ListCommonPrefixes(bucket, prefix, delimiter string) ([]st ...@@ -204,7 +225,6 @@ func (o *ObjectStore) ListCommonPrefixes(bucket, prefix, delimiter string) ([]st
// ListObjects list objects of a bucket // ListObjects list objects of a bucket
func (o *ObjectStore) ListObjects(bucket, prefix string) ([]string, error) { func (o *ObjectStore) ListObjects(bucket, prefix string) ([]string, error) {
bucketObj, err := o.getBucket(bucket) bucketObj, err := o.getBucket(bucket)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -249,3 +269,238 @@ func (o *ObjectStore) CreateSignedURL(bucket, key string, ttl time.Duration) (st ...@@ -249,3 +269,238 @@ func (o *ObjectStore) CreateSignedURL(bucket, key string, ttl time.Duration) (st
return bucketObj.SignURL(key, oss.HTTPGet, int64(ttl.Seconds())) return bucketObj.SignURL(key, oss.HTTPGet, int64(ttl.Seconds()))
} }
// CheckAndConvertVolumeId convert volumeId to VolumeId in persistentvolumes json files
func CheckAndConvertVolumeId(body io.ReadCloser) (io.ReadCloser, error) {
randStr := CreateCaptcha()
tmpWorkspace := filepath.Join(Workspace, randStr)
tmpFileName := fmt.Sprintf("%s.tar.gz", randStr)
if _, err := CheckPathExistsAndCreate(tmpWorkspace); err != nil {
return nil, err
}
if err := os.Chdir(tmpWorkspace); err != nil {
return nil, err
}
fd, err := os.OpenFile(tmpFileName, os.O_WRONLY|os.O_CREATE, 0660)
if err != nil {
return nil, err
}
defer fd.Close()
if _, err := io.Copy(fd, body); err != nil {
return nil, err
}
if err := DeCompress(tmpFileName, ""); err != nil {
return nil, err
}
if err := os.Remove(tmpFileName); err != nil {
return nil, err
}
tmpFiles := make([]string, 0)
err = filepath.Walk(tmpWorkspace,
func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if f, _ := os.Stat(path); !f.IsDir() {
if strings.Index(path, "resources/persistentvolumes/cluster") > 0 {
tmpFiles = append(tmpFiles, path)
}
}
return nil
})
if err != nil {
return nil, err
}
for _, f := range tmpFiles {
fmt.Println(f)
if err := ReplaceVolumeId(f); err != nil {
return nil, err
}
}
if err := Compress(".", tmpFileName); err != nil {
return nil, err
}
f1, err := ioutil.ReadFile(tmpFileName)
if err != nil {
return nil, err
}
f2 := ioutil.NopCloser(bytes.NewReader(f1))
if err := os.RemoveAll(tmpWorkspace); err != nil {
return nil, err
}
return f2, nil
}
// CheckPathExistsAndCreate
func CheckPathExistsAndCreate(path string) (bool, error) {
_, err := os.Stat(path)
if err == nil {
return true, nil
}
if os.IsNotExist(err) {
err = os.MkdirAll(path, os.ModePerm)
if err != nil {
return false, err
} else {
return true, nil
}
}
return false, nil
}
// CreateCaptcha
func CreateCaptcha() string {
return fmt.Sprintf("%08v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(1000000))
}
// DeCompress
func DeCompress(tarFile, dest string) error {
srcFile, err := os.Open(tarFile)
if err != nil {
return err
}
defer srcFile.Close()
gr, err := gzip.NewReader(srcFile)
if err != nil {
return err
}
defer gr.Close()
tr := tar.NewReader(gr)
for {
hdr, err := tr.Next()
if err != nil {
if err == io.EOF {
break
} else {
return err
}
}
filename := dest + hdr.Name
file, err := CreateFile(filename)
if err != nil {
return err
}
io.Copy(file, tr)
}
return nil
}
// CreateFile
func CreateFile(name string) (*os.File, error) {
err := os.MkdirAll(string([]rune(name)[0:strings.LastIndex(name, "/")]), 0755)
if err != nil {
return nil, err
}
return os.Create(name)
}
// ReplaceVolumeId
func ReplaceVolumeId(filePath string) error {
f, err := os.OpenFile(filePath, os.O_RDONLY, 0644)
if err != nil {
return err
}
defer f.Close()
reader := bufio.NewReader(f)
output := make([]byte, 0)
for {
line, _, err := reader.ReadLine()
if err != nil {
if err == io.EOF {
break
}
return err
}
if ok, _ := regexp.Match(OriginStr, line); ok {
reg := regexp.MustCompile(OriginStr)
newByte := reg.ReplaceAll(line, []byte(TargetStr))
output = append(output, newByte...)
output = append(output, []byte("\n")...)
} else {
output = append(output, line...)
output = append(output, []byte("\n")...)
}
}
if err := writeToFile(filePath, output); err != nil {
return err
}
return nil
}
// writeToFile
func writeToFile(filePath string, outPut []byte) error {
f, err := os.OpenFile(filePath, os.O_WRONLY|os.O_TRUNC, 0600)
defer f.Close()
if err != nil {
return err
}
writer := bufio.NewWriter(f)
_, err = writer.Write(outPut)
if err != nil {
return err
}
writer.Flush()
return nil
}
// Compress
func Compress(src, dst string) error {
fw, err := os.Create(dst)
if err != nil {
return err
}
defer fw.Close()
gw := gzip.NewWriter(fw)
defer gw.Close()
tw := tar.NewWriter(gw)
defer tw.Close()
return filepath.Walk(src, func(fileName string, fi os.FileInfo, err error) error {
if err != nil {
return err
}
if strings.Index(fileName, dst) > -1 {
return nil
}
hdr, err := tar.FileInfoHeader(fi, "")
if err != nil {
return err
}
hdr.Name = strings.TrimPrefix(fileName, string(filepath.Separator))
if err := tw.WriteHeader(hdr); err != nil {
return err
}
if !fi.Mode().IsRegular() {
return nil
}
fr, err := os.Open(fileName)
defer fr.Close()
if err != nil {
return err
}
if _, err := io.Copy(tw, fr); err != nil {
return err
}
return nil
})
}
...@@ -50,7 +50,7 @@ func NewVolumeSnapshotter(logger logrus.FieldLogger) *VolumeSnapshotter { ...@@ -50,7 +50,7 @@ func NewVolumeSnapshotter(logger logrus.FieldLogger) *VolumeSnapshotter {
// Init init ecs client with os env // Init init ecs client with os env
func (b *VolumeSnapshotter) Init(config map[string]string) error { func (b *VolumeSnapshotter) Init(config map[string]string) error {
if err := cloudprovider.ValidateVolumeSnapshotterConfigKeys(config, regionKey); err != nil { if err := cloudprovider.ValidateVolumeSnapshotterConfigKeys(config, RegionKey); err != nil {
return err return err
} }
...@@ -58,9 +58,9 @@ func (b *VolumeSnapshotter) Init(config map[string]string) error { ...@@ -58,9 +58,9 @@ func (b *VolumeSnapshotter) Init(config map[string]string) error {
return err return err
} }
region := config[regionKey] region := config[RegionKey]
if region == "" { if region == "" {
return errors.Errorf("missing %s in Alibaba Cloud configuration", regionKey) return errors.Errorf("missing %s in Alibaba Cloud configuration", RegionKey)
} }
accessKeyID := os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_ID") accessKeyID := os.Getenv("ALIBABA_CLOUD_ACCESS_KEY_ID")
...@@ -296,10 +296,14 @@ func getEBSDiskID(pv *v1.PersistentVolume) (string, error) { ...@@ -296,10 +296,14 @@ func getEBSDiskID(pv *v1.PersistentVolume) (string, error) {
return "", err return "", err
} }
options := pv.Spec.FlexVolume.Options options := pv.Spec.FlexVolume.Options
if options == nil || options["VolumeId"] == "" { if options == nil || (options["VolumeId"] == "" && options["volumeId"] == "") {
return "", errors.New("spec.FlexVolume.Options['VolumeId'] not found") return "", errors.New("spec.FlexVolume.Options['VolumeId'] or spec.FlexVolume.Options['volumeId'] not found")
} } else if options["VolumeId"] != "" {
return options["VolumeId"], nil return options["VolumeId"], nil
} else {
return options["volumeId"], nil
}
} }
return "", nil return "", nil
} }
......
...@@ -527,6 +527,7 @@ func ExtensionDescs(pb Message) ([]*ExtensionDesc, error) { ...@@ -527,6 +527,7 @@ func ExtensionDescs(pb Message) ([]*ExtensionDesc, error) {
// SetExtension sets the specified extension of pb to the specified value. // SetExtension sets the specified extension of pb to the specified value.
func SetExtension(pb Message, extension *ExtensionDesc, value interface{}) error { func SetExtension(pb Message, extension *ExtensionDesc, value interface{}) error {
if epb, ok := pb.(extensionsBytes); ok { if epb, ok := pb.(extensionsBytes); ok {
ClearExtension(pb, extension)
newb, err := encodeExtension(extension, value) newb, err := encodeExtension(extension, value)
if err != nil { if err != nil {
return err return err
......
...@@ -154,6 +154,10 @@ func EncodeInternalExtension(m extendableProto, data []byte) (n int, err error) ...@@ -154,6 +154,10 @@ func EncodeInternalExtension(m extendableProto, data []byte) (n int, err error)
return EncodeExtensionMap(m.extensionsWrite(), data) return EncodeExtensionMap(m.extensionsWrite(), data)
} }
func EncodeInternalExtensionBackwards(m extendableProto, data []byte) (n int, err error) {
return EncodeExtensionMapBackwards(m.extensionsWrite(), data)
}
func EncodeExtensionMap(m map[int32]Extension, data []byte) (n int, err error) { func EncodeExtensionMap(m map[int32]Extension, data []byte) (n int, err error) {
o := 0 o := 0
for _, e := range m { for _, e := range m {
...@@ -169,6 +173,23 @@ func EncodeExtensionMap(m map[int32]Extension, data []byte) (n int, err error) { ...@@ -169,6 +173,23 @@ func EncodeExtensionMap(m map[int32]Extension, data []byte) (n int, err error) {
return o, nil return o, nil
} }
func EncodeExtensionMapBackwards(m map[int32]Extension, data []byte) (n int, err error) {
o := 0
end := len(data)
for _, e := range m {
if err := e.Encode(); err != nil {
return 0, err
}
n := copy(data[end-len(e.enc):], e.enc)
if n != len(e.enc) {
return 0, io.ErrShortBuffer
}
end -= n
o += n
}
return o, nil
}
func GetRawExtension(m map[int32]Extension, id int32) ([]byte, error) { func GetRawExtension(m map[int32]Extension, id int32) ([]byte, error) {
e := m[id] e := m[id]
if err := e.Encode(); err != nil { if err := e.Encode(); err != nil {
......
...@@ -948,13 +948,19 @@ func isProto3Zero(v reflect.Value) bool { ...@@ -948,13 +948,19 @@ func isProto3Zero(v reflect.Value) bool {
return false return false
} }
// ProtoPackageIsVersion2 is referenced from generated protocol buffer files const (
// to assert that that code is compatible with this version of the proto package. // ProtoPackageIsVersion3 is referenced from generated protocol buffer files
const GoGoProtoPackageIsVersion2 = true // to assert that that code is compatible with this version of the proto package.
GoGoProtoPackageIsVersion3 = true
// ProtoPackageIsVersion1 is referenced from generated protocol buffer files
// to assert that that code is compatible with this version of the proto package. // ProtoPackageIsVersion2 is referenced from generated protocol buffer files
const GoGoProtoPackageIsVersion1 = true // to assert that that code is compatible with this version of the proto package.
GoGoProtoPackageIsVersion2 = true
// ProtoPackageIsVersion1 is referenced from generated protocol buffer files
// to assert that that code is compatible with this version of the proto package.
GoGoProtoPackageIsVersion1 = true
)
// InternalMessageInfo is a type used internally by generated .pb.go files. // InternalMessageInfo is a type used internally by generated .pb.go files.
// This type is not intended to be used by non-generated code. // This type is not intended to be used by non-generated code.
......
...@@ -400,6 +400,15 @@ func GetProperties(t reflect.Type) *StructProperties { ...@@ -400,6 +400,15 @@ func GetProperties(t reflect.Type) *StructProperties {
return sprop return sprop
} }
type (
oneofFuncsIface interface {
XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{})
}
oneofWrappersIface interface {
XXX_OneofWrappers() []interface{}
}
)
// getPropertiesLocked requires that propertiesMu is held. // getPropertiesLocked requires that propertiesMu is held.
func getPropertiesLocked(t reflect.Type) *StructProperties { func getPropertiesLocked(t reflect.Type) *StructProperties {
if prop, ok := propertiesMap[t]; ok { if prop, ok := propertiesMap[t]; ok {
...@@ -441,13 +450,15 @@ func getPropertiesLocked(t reflect.Type) *StructProperties { ...@@ -441,13 +450,15 @@ func getPropertiesLocked(t reflect.Type) *StructProperties {
// Re-order prop.order. // Re-order prop.order.
sort.Sort(prop) sort.Sort(prop)
type oneofMessage interface { if isOneofMessage {
XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{})
}
if om, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); isOneofMessage && ok {
var oots []interface{} var oots []interface{}
_, _, _, oots = om.XXX_OneofFuncs() switch m := reflect.Zero(reflect.PtrTo(t)).Interface().(type) {
case oneofFuncsIface:
_, _, _, oots = m.XXX_OneofFuncs()
case oneofWrappersIface:
oots = m.XXX_OneofWrappers()
}
if len(oots) > 0 {
// Interpret oneof metadata. // Interpret oneof metadata.
prop.OneofTypes = make(map[string]*OneofProperties) prop.OneofTypes = make(map[string]*OneofProperties)
for _, oot := range oots { for _, oot := range oots {
...@@ -474,6 +485,7 @@ func getPropertiesLocked(t reflect.Type) *StructProperties { ...@@ -474,6 +485,7 @@ func getPropertiesLocked(t reflect.Type) *StructProperties {
prop.OneofTypes[oop.Prop.OrigName] = oop prop.OneofTypes[oop.Prop.OrigName] = oop
} }
} }
}
// build required counts // build required counts
// build tags // build tags
......
...@@ -389,8 +389,13 @@ func (u *marshalInfo) computeMarshalInfo() { ...@@ -389,8 +389,13 @@ func (u *marshalInfo) computeMarshalInfo() {
// get oneof implementers // get oneof implementers
var oneofImplementers []interface{} var oneofImplementers []interface{}
// gogo: isOneofMessage is needed for embedded oneof messages, without a marshaler and unmarshaler // gogo: isOneofMessage is needed for embedded oneof messages, without a marshaler and unmarshaler
if m, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); ok && isOneofMessage { if isOneofMessage {
switch m := reflect.Zero(reflect.PtrTo(t)).Interface().(type) {
case oneofFuncsIface:
_, _, _, oneofImplementers = m.XXX_OneofFuncs() _, _, _, oneofImplementers = m.XXX_OneofFuncs()
case oneofWrappersIface:
oneofImplementers = m.XXX_OneofWrappers()
}
} }
// normal fields // normal fields
...@@ -519,10 +524,6 @@ func (fi *marshalFieldInfo) computeOneofFieldInfo(f *reflect.StructField, oneofI ...@@ -519,10 +524,6 @@ func (fi *marshalFieldInfo) computeOneofFieldInfo(f *reflect.StructField, oneofI
} }
} }
type oneofMessage interface {
XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{})
}
// wiretype returns the wire encoding of the type. // wiretype returns the wire encoding of the type.
func wiretype(encoding string) uint64 { func wiretype(encoding string) uint64 {
switch encoding { switch encoding {
......
...@@ -530,6 +530,25 @@ func (mi *mergeInfo) computeMergeInfo() { ...@@ -530,6 +530,25 @@ func (mi *mergeInfo) computeMergeInfo() {
} }
case reflect.Struct: case reflect.Struct:
switch { switch {
case isSlice && !isPointer: // E.g. []pb.T
mergeInfo := getMergeInfo(tf)
zero := reflect.Zero(tf)
mfi.merge = func(dst, src pointer) {
// TODO: Make this faster?
dstsp := dst.asPointerTo(f.Type)
dsts := dstsp.Elem()
srcs := src.asPointerTo(f.Type).Elem()
for i := 0; i < srcs.Len(); i++ {
dsts = reflect.Append(dsts, zero)
srcElement := srcs.Index(i).Addr()
dstElement := dsts.Index(dsts.Len() - 1).Addr()
mergeInfo.merge(valToPointer(dstElement), valToPointer(srcElement))
}
if dsts.IsNil() {
dsts = reflect.MakeSlice(f.Type, 0, 0)
}
dstsp.Elem().Set(dsts)
}
case !isPointer: case !isPointer:
mergeInfo := getMergeInfo(tf) mergeInfo := getMergeInfo(tf)
mfi.merge = func(dst, src pointer) { mfi.merge = func(dst, src pointer) {
......
...@@ -371,14 +371,17 @@ func (u *unmarshalInfo) computeUnmarshalInfo() { ...@@ -371,14 +371,17 @@ func (u *unmarshalInfo) computeUnmarshalInfo() {
} }
// Find any types associated with oneof fields. // Find any types associated with oneof fields.
// TODO: XXX_OneofFuncs returns more info than we need. Get rid of some of it?
fn := reflect.Zero(reflect.PtrTo(t)).MethodByName("XXX_OneofFuncs")
// gogo: len(oneofFields) > 0 is needed for embedded oneof messages, without a marshaler and unmarshaler // gogo: len(oneofFields) > 0 is needed for embedded oneof messages, without a marshaler and unmarshaler
if fn.IsValid() && len(oneofFields) > 0 { if len(oneofFields) > 0 {
res := fn.Call(nil)[3] // last return value from XXX_OneofFuncs: []interface{} var oneofImplementers []interface{}
for i := res.Len() - 1; i >= 0; i-- { switch m := reflect.Zero(reflect.PtrTo(t)).Interface().(type) {
v := res.Index(i) // interface{} case oneofFuncsIface:
tptr := reflect.ValueOf(v.Interface()).Type() // *Msg_X _, _, _, oneofImplementers = m.XXX_OneofFuncs()
case oneofWrappersIface:
oneofImplementers = m.XXX_OneofWrappers()
}
for _, v := range oneofImplementers {
tptr := reflect.TypeOf(v) // *Msg_X
typ := tptr.Elem() // Msg_X typ := tptr.Elem() // Msg_X
f := typ.Field(0) // oneof implementers have one field f := typ.Field(0) // oneof implementers have one field
...@@ -407,11 +410,12 @@ func (u *unmarshalInfo) computeUnmarshalInfo() { ...@@ -407,11 +410,12 @@ func (u *unmarshalInfo) computeUnmarshalInfo() {
u.setTag(fieldNum, of.field, unmarshal, 0, name) u.setTag(fieldNum, of.field, unmarshal, 0, name)
} }
} }
} }
} }
// Get extension ranges, if any. // Get extension ranges, if any.
fn = reflect.Zero(reflect.PtrTo(t)).MethodByName("ExtensionRangeArray") fn := reflect.Zero(reflect.PtrTo(t)).MethodByName("ExtensionRangeArray")
if fn.IsValid() { if fn.IsValid() {
if !u.extensions.IsValid() && !u.oldExtensions.IsValid() && !u.bytesExtensions.IsValid() { if !u.extensions.IsValid() && !u.oldExtensions.IsValid() && !u.bytesExtensions.IsValid() {
panic("a message with extensions, but no extensions field in " + t.Name()) panic("a message with extensions, but no extensions field in " + t.Name())
......
...@@ -6,7 +6,19 @@ ...@@ -6,7 +6,19 @@
package unix package unix
import "runtime" import (
"runtime"
"unsafe"
)
// ioctl itself should not be exposed directly, but additional get/set
// functions for specific types are permissible.
// IoctlSetInt performs an ioctl operation which sets an integer value
// on fd, using the specified request number.
func IoctlSetInt(fd int, req uint, value int) error {
return ioctl(fd, req, uintptr(value))
}
// IoctlSetWinsize performs an ioctl on fd with a *Winsize argument. // IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
// //
...@@ -14,7 +26,7 @@ import "runtime" ...@@ -14,7 +26,7 @@ import "runtime"
func IoctlSetWinsize(fd int, req uint, value *Winsize) error { func IoctlSetWinsize(fd int, req uint, value *Winsize) error {
// TODO: if we get the chance, remove the req parameter and // TODO: if we get the chance, remove the req parameter and
// hardcode TIOCSWINSZ. // hardcode TIOCSWINSZ.
err := ioctlSetWinsize(fd, req, value) err := ioctl(fd, req, uintptr(unsafe.Pointer(value)))
runtime.KeepAlive(value) runtime.KeepAlive(value)
return err return err
} }
...@@ -24,7 +36,30 @@ func IoctlSetWinsize(fd int, req uint, value *Winsize) error { ...@@ -24,7 +36,30 @@ func IoctlSetWinsize(fd int, req uint, value *Winsize) error {
// The req value will usually be TCSETA or TIOCSETA. // The req value will usually be TCSETA or TIOCSETA.
func IoctlSetTermios(fd int, req uint, value *Termios) error { func IoctlSetTermios(fd int, req uint, value *Termios) error {
// TODO: if we get the chance, remove the req parameter. // TODO: if we get the chance, remove the req parameter.
err := ioctlSetTermios(fd, req, value) err := ioctl(fd, req, uintptr(unsafe.Pointer(value)))
runtime.KeepAlive(value) runtime.KeepAlive(value)
return err return err
} }
// IoctlGetInt performs an ioctl operation which gets an integer value
// from fd, using the specified request number.
//
// A few ioctl requests use the return value as an output parameter;
// for those, IoctlRetInt should be used instead of this function.
func IoctlGetInt(fd int, req uint) (int, error) {
var value int
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return value, err
}
func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
var value Winsize
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return &value, err
}
func IoctlGetTermios(fd int, req uint) (*Termios, error) {
var value Termios
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return &value, err
}
...@@ -350,49 +350,12 @@ func (w WaitStatus) Signal() Signal { ...@@ -350,49 +350,12 @@ func (w WaitStatus) Signal() Signal {
func (w WaitStatus) Continued() bool { return w&0x01000000 != 0 } func (w WaitStatus) Continued() bool { return w&0x01000000 != 0 }
func (w WaitStatus) CoreDump() bool { return w&0x200 != 0 } func (w WaitStatus) CoreDump() bool { return w&0x80 == 0x80 }
func (w WaitStatus) TrapCause() int { return -1 } func (w WaitStatus) TrapCause() int { return -1 }
//sys ioctl(fd int, req uint, arg uintptr) (err error) //sys ioctl(fd int, req uint, arg uintptr) (err error)
// ioctl itself should not be exposed directly, but additional get/set
// functions for specific types are permissible.
// IoctlSetInt performs an ioctl operation which sets an integer value
// on fd, using the specified request number.
func IoctlSetInt(fd int, req uint, value int) error {
return ioctl(fd, req, uintptr(value))
}
func ioctlSetWinsize(fd int, req uint, value *Winsize) error {
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
}
func ioctlSetTermios(fd int, req uint, value *Termios) error {
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
}
// IoctlGetInt performs an ioctl operation which gets an integer value
// from fd, using the specified request number.
func IoctlGetInt(fd int, req uint) (int, error) {
var value int
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return value, err
}
func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
var value Winsize
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return &value, err
}
func IoctlGetTermios(fd int, req uint) (*Termios, error) {
var value Termios
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return &value, err
}
// fcntl must never be called with cmd=F_DUP2FD because it doesn't work on AIX // fcntl must never be called with cmd=F_DUP2FD because it doesn't work on AIX
// There is no way to create a custom fcntl and to keep //sys fcntl easily, // There is no way to create a custom fcntl and to keep //sys fcntl easily,
// Therefore, the programmer must call dup2 instead of fcntl in this case. // Therefore, the programmer must call dup2 instead of fcntl in this case.
......
...@@ -339,43 +339,6 @@ func Kill(pid int, signum syscall.Signal) (err error) { return kill(pid, int(sig ...@@ -339,43 +339,6 @@ func Kill(pid int, signum syscall.Signal) (err error) { return kill(pid, int(sig
//sys ioctl(fd int, req uint, arg uintptr) (err error) //sys ioctl(fd int, req uint, arg uintptr) (err error)
// ioctl itself should not be exposed directly, but additional get/set
// functions for specific types are permissible.
// IoctlSetInt performs an ioctl operation which sets an integer value
// on fd, using the specified request number.
func IoctlSetInt(fd int, req uint, value int) error {
return ioctl(fd, req, uintptr(value))
}
func ioctlSetWinsize(fd int, req uint, value *Winsize) error {
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
}
func ioctlSetTermios(fd int, req uint, value *Termios) error {
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
}
// IoctlGetInt performs an ioctl operation which gets an integer value
// from fd, using the specified request number.
func IoctlGetInt(fd int, req uint) (int, error) {
var value int
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return value, err
}
func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
var value Winsize
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return &value, err
}
func IoctlGetTermios(fd int, req uint) (*Termios, error) {
var value Termios
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return &value, err
}
func Uname(uname *Utsname) error { func Uname(uname *Utsname) error {
mib := []_C_int{CTL_KERN, KERN_OSTYPE} mib := []_C_int{CTL_KERN, KERN_OSTYPE}
n := unsafe.Sizeof(uname.Sysname) n := unsafe.Sizeof(uname.Sysname)
......
...@@ -150,43 +150,6 @@ func setattrlistTimes(path string, times []Timespec, flags int) error { ...@@ -150,43 +150,6 @@ func setattrlistTimes(path string, times []Timespec, flags int) error {
//sys ioctl(fd int, req uint, arg uintptr) (err error) //sys ioctl(fd int, req uint, arg uintptr) (err error)
// ioctl itself should not be exposed directly, but additional get/set
// functions for specific types are permissible.
// IoctlSetInt performs an ioctl operation which sets an integer value
// on fd, using the specified request number.
func IoctlSetInt(fd int, req uint, value int) error {
return ioctl(fd, req, uintptr(value))
}
func ioctlSetWinsize(fd int, req uint, value *Winsize) error {
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
}
func ioctlSetTermios(fd int, req uint, value *Termios) error {
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
}
// IoctlGetInt performs an ioctl operation which gets an integer value
// from fd, using the specified request number.
func IoctlGetInt(fd int, req uint) (int, error) {
var value int
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return value, err
}
func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
var value Winsize
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return &value, err
}
func IoctlGetTermios(fd int, req uint) (*Termios, error) {
var value Termios
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return &value, err
}
func sysctlUname(mib []_C_int, old *byte, oldlen *uintptr) error { func sysctlUname(mib []_C_int, old *byte, oldlen *uintptr) error {
err := sysctl(mib, old, oldlen, nil, 0) err := sysctl(mib, old, oldlen, nil, 0)
if err != nil { if err != nil {
......
...@@ -201,43 +201,6 @@ func setattrlistTimes(path string, times []Timespec, flags int) error { ...@@ -201,43 +201,6 @@ func setattrlistTimes(path string, times []Timespec, flags int) error {
//sys ioctl(fd int, req uint, arg uintptr) (err error) //sys ioctl(fd int, req uint, arg uintptr) (err error)
// ioctl itself should not be exposed directly, but additional get/set
// functions for specific types are permissible.
// IoctlSetInt performs an ioctl operation which sets an integer value
// on fd, using the specified request number.
func IoctlSetInt(fd int, req uint, value int) error {
return ioctl(fd, req, uintptr(value))
}
func ioctlSetWinsize(fd int, req uint, value *Winsize) error {
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
}
func ioctlSetTermios(fd int, req uint, value *Termios) error {
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
}
// IoctlGetInt performs an ioctl operation which gets an integer value
// from fd, using the specified request number.
func IoctlGetInt(fd int, req uint) (int, error) {
var value int
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return value, err
}
func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
var value Winsize
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return &value, err
}
func IoctlGetTermios(fd int, req uint) (*Termios, error) {
var value Termios
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return &value, err
}
func Uname(uname *Utsname) error { func Uname(uname *Utsname) error {
mib := []_C_int{CTL_KERN, KERN_OSTYPE} mib := []_C_int{CTL_KERN, KERN_OSTYPE}
n := unsafe.Sizeof(uname.Sysname) n := unsafe.Sizeof(uname.Sysname)
......
...@@ -71,6 +71,17 @@ func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { ...@@ -71,6 +71,17 @@ func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
// ioctl itself should not be exposed directly, but additional get/set // ioctl itself should not be exposed directly, but additional get/set
// functions for specific types are permissible. // functions for specific types are permissible.
// IoctlRetInt performs an ioctl operation specified by req on a device
// associated with opened file descriptor fd, and returns a non-negative
// integer that is returned by the ioctl syscall.
func IoctlRetInt(fd int, req uint) (int, error) {
ret, _, err := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), 0)
if err != 0 {
return 0, err
}
return int(ret), nil
}
// IoctlSetPointerInt performs an ioctl operation which sets an // IoctlSetPointerInt performs an ioctl operation which sets an
// integer value on fd, using the specified request number. The ioctl // integer value on fd, using the specified request number. The ioctl
// argument is called with a pointer to the integer value, rather than // argument is called with a pointer to the integer value, rather than
...@@ -80,52 +91,18 @@ func IoctlSetPointerInt(fd int, req uint, value int) error { ...@@ -80,52 +91,18 @@ func IoctlSetPointerInt(fd int, req uint, value int) error {
return ioctl(fd, req, uintptr(unsafe.Pointer(&v))) return ioctl(fd, req, uintptr(unsafe.Pointer(&v)))
} }
// IoctlSetInt performs an ioctl operation which sets an integer value
// on fd, using the specified request number.
func IoctlSetInt(fd int, req uint, value int) error {
return ioctl(fd, req, uintptr(value))
}
func ioctlSetWinsize(fd int, req uint, value *Winsize) error {
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
}
func ioctlSetTermios(fd int, req uint, value *Termios) error {
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
}
func IoctlSetRTCTime(fd int, value *RTCTime) error { func IoctlSetRTCTime(fd int, value *RTCTime) error {
err := ioctl(fd, RTC_SET_TIME, uintptr(unsafe.Pointer(value))) err := ioctl(fd, RTC_SET_TIME, uintptr(unsafe.Pointer(value)))
runtime.KeepAlive(value) runtime.KeepAlive(value)
return err return err
} }
// IoctlGetInt performs an ioctl operation which gets an integer value
// from fd, using the specified request number.
func IoctlGetInt(fd int, req uint) (int, error) {
var value int
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return value, err
}
func IoctlGetUint32(fd int, req uint) (uint32, error) { func IoctlGetUint32(fd int, req uint) (uint32, error) {
var value uint32 var value uint32
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return value, err return value, err
} }
func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
var value Winsize
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return &value, err
}
func IoctlGetTermios(fd int, req uint) (*Termios, error) {
var value Termios
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return &value, err
}
func IoctlGetRTCTime(fd int) (*RTCTime, error) { func IoctlGetRTCTime(fd int) (*RTCTime, error) {
var value RTCTime var value RTCTime
err := ioctl(fd, RTC_RD_TIME, uintptr(unsafe.Pointer(&value))) err := ioctl(fd, RTC_RD_TIME, uintptr(unsafe.Pointer(&value)))
......
...@@ -187,43 +187,6 @@ func setattrlistTimes(path string, times []Timespec, flags int) error { ...@@ -187,43 +187,6 @@ func setattrlistTimes(path string, times []Timespec, flags int) error {
//sys ioctl(fd int, req uint, arg uintptr) (err error) //sys ioctl(fd int, req uint, arg uintptr) (err error)
// ioctl itself should not be exposed directly, but additional get/set
// functions for specific types are permissible.
// IoctlSetInt performs an ioctl operation which sets an integer value
// on fd, using the specified request number.
func IoctlSetInt(fd int, req uint, value int) error {
return ioctl(fd, req, uintptr(value))
}
func ioctlSetWinsize(fd int, req uint, value *Winsize) error {
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
}
func ioctlSetTermios(fd int, req uint, value *Termios) error {
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
}
// IoctlGetInt performs an ioctl operation which gets an integer value
// from fd, using the specified request number.
func IoctlGetInt(fd int, req uint) (int, error) {
var value int
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return value, err
}
func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
var value Winsize
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return &value, err
}
func IoctlGetTermios(fd int, req uint) (*Termios, error) {
var value Termios
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return &value, err
}
func IoctlGetPtmget(fd int, req uint) (*Ptmget, error) { func IoctlGetPtmget(fd int, req uint) (*Ptmget, error) {
var value Ptmget var value Ptmget
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
......
...@@ -178,43 +178,6 @@ func setattrlistTimes(path string, times []Timespec, flags int) error { ...@@ -178,43 +178,6 @@ func setattrlistTimes(path string, times []Timespec, flags int) error {
//sys ioctl(fd int, req uint, arg uintptr) (err error) //sys ioctl(fd int, req uint, arg uintptr) (err error)
// ioctl itself should not be exposed directly, but additional get/set
// functions for specific types are permissible.
// IoctlSetInt performs an ioctl operation which sets an integer value
// on fd, using the specified request number.
func IoctlSetInt(fd int, req uint, value int) error {
return ioctl(fd, req, uintptr(value))
}
func ioctlSetWinsize(fd int, req uint, value *Winsize) error {
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
}
func ioctlSetTermios(fd int, req uint, value *Termios) error {
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
}
// IoctlGetInt performs an ioctl operation which gets an integer value
// from fd, using the specified request number.
func IoctlGetInt(fd int, req uint) (int, error) {
var value int
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return value, err
}
func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
var value Winsize
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return &value, err
}
func IoctlGetTermios(fd int, req uint) (*Termios, error) {
var value Termios
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return &value, err
}
//sys ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) //sys ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error)
func Ppoll(fds []PollFd, timeout *Timespec, sigmask *Sigset_t) (n int, err error) { func Ppoll(fds []PollFd, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
......
...@@ -553,40 +553,10 @@ func Minor(dev uint64) uint32 { ...@@ -553,40 +553,10 @@ func Minor(dev uint64) uint32 {
//sys ioctl(fd int, req uint, arg uintptr) (err error) //sys ioctl(fd int, req uint, arg uintptr) (err error)
func IoctlSetInt(fd int, req uint, value int) (err error) {
return ioctl(fd, req, uintptr(value))
}
func ioctlSetWinsize(fd int, req uint, value *Winsize) (err error) {
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
}
func ioctlSetTermios(fd int, req uint, value *Termios) (err error) {
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
}
func IoctlSetTermio(fd int, req uint, value *Termio) (err error) { func IoctlSetTermio(fd int, req uint, value *Termio) (err error) {
return ioctl(fd, req, uintptr(unsafe.Pointer(value))) return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
} }
func IoctlGetInt(fd int, req uint) (int, error) {
var value int
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return value, err
}
func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
var value Winsize
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return &value, err
}
func IoctlGetTermios(fd int, req uint) (*Termios, error) {
var value Termios
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
return &value, err
}
func IoctlGetTermio(fd int, req uint) (*Termio, error) { func IoctlGetTermio(fd int, req uint) (*Termio, error) {
var value Termio var value Termio
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
......
...@@ -1408,6 +1408,10 @@ const ( ...@@ -1408,6 +1408,10 @@ const (
NLM_F_ROOT = 0x100 NLM_F_ROOT = 0x100
NOFLSH = 0x80 NOFLSH = 0x80
NSFS_MAGIC = 0x6e736673 NSFS_MAGIC = 0x6e736673
NS_GET_NSTYPE = 0xb703
NS_GET_OWNER_UID = 0xb704
NS_GET_PARENT = 0xb702
NS_GET_USERNS = 0xb701
OCFS2_SUPER_MAGIC = 0x7461636f OCFS2_SUPER_MAGIC = 0x7461636f
OCRNL = 0x8 OCRNL = 0x8
OFDEL = 0x80 OFDEL = 0x80
......
...@@ -1408,6 +1408,10 @@ const ( ...@@ -1408,6 +1408,10 @@ const (
NLM_F_ROOT = 0x100 NLM_F_ROOT = 0x100
NOFLSH = 0x80 NOFLSH = 0x80
NSFS_MAGIC = 0x6e736673 NSFS_MAGIC = 0x6e736673
NS_GET_NSTYPE = 0xb703
NS_GET_OWNER_UID = 0xb704
NS_GET_PARENT = 0xb702
NS_GET_USERNS = 0xb701
OCFS2_SUPER_MAGIC = 0x7461636f OCFS2_SUPER_MAGIC = 0x7461636f
OCRNL = 0x8 OCRNL = 0x8
OFDEL = 0x80 OFDEL = 0x80
......
...@@ -1406,6 +1406,10 @@ const ( ...@@ -1406,6 +1406,10 @@ const (
NLM_F_ROOT = 0x100 NLM_F_ROOT = 0x100
NOFLSH = 0x80 NOFLSH = 0x80
NSFS_MAGIC = 0x6e736673 NSFS_MAGIC = 0x6e736673
NS_GET_NSTYPE = 0xb703
NS_GET_OWNER_UID = 0xb704
NS_GET_PARENT = 0xb702
NS_GET_USERNS = 0xb701
OCFS2_SUPER_MAGIC = 0x7461636f OCFS2_SUPER_MAGIC = 0x7461636f
OCRNL = 0x8 OCRNL = 0x8
OFDEL = 0x80 OFDEL = 0x80
......
...@@ -1409,6 +1409,10 @@ const ( ...@@ -1409,6 +1409,10 @@ const (
NLM_F_ROOT = 0x100 NLM_F_ROOT = 0x100
NOFLSH = 0x80 NOFLSH = 0x80
NSFS_MAGIC = 0x6e736673 NSFS_MAGIC = 0x6e736673
NS_GET_NSTYPE = 0xb703
NS_GET_OWNER_UID = 0xb704
NS_GET_PARENT = 0xb702
NS_GET_USERNS = 0xb701
OCFS2_SUPER_MAGIC = 0x7461636f OCFS2_SUPER_MAGIC = 0x7461636f
OCRNL = 0x8 OCRNL = 0x8
OFDEL = 0x80 OFDEL = 0x80
......
...@@ -1406,6 +1406,10 @@ const ( ...@@ -1406,6 +1406,10 @@ const (
NLM_F_ROOT = 0x100 NLM_F_ROOT = 0x100
NOFLSH = 0x80 NOFLSH = 0x80
NSFS_MAGIC = 0x6e736673 NSFS_MAGIC = 0x6e736673
NS_GET_NSTYPE = 0x2000b703
NS_GET_OWNER_UID = 0x2000b704
NS_GET_PARENT = 0x2000b702
NS_GET_USERNS = 0x2000b701
OCFS2_SUPER_MAGIC = 0x7461636f OCFS2_SUPER_MAGIC = 0x7461636f
OCRNL = 0x8 OCRNL = 0x8
OFDEL = 0x80 OFDEL = 0x80
......
...@@ -1406,6 +1406,10 @@ const ( ...@@ -1406,6 +1406,10 @@ const (
NLM_F_ROOT = 0x100 NLM_F_ROOT = 0x100
NOFLSH = 0x80 NOFLSH = 0x80
NSFS_MAGIC = 0x6e736673 NSFS_MAGIC = 0x6e736673
NS_GET_NSTYPE = 0x2000b703
NS_GET_OWNER_UID = 0x2000b704
NS_GET_PARENT = 0x2000b702
NS_GET_USERNS = 0x2000b701
OCFS2_SUPER_MAGIC = 0x7461636f OCFS2_SUPER_MAGIC = 0x7461636f
OCRNL = 0x8 OCRNL = 0x8
OFDEL = 0x80 OFDEL = 0x80
......
...@@ -1406,6 +1406,10 @@ const ( ...@@ -1406,6 +1406,10 @@ const (
NLM_F_ROOT = 0x100 NLM_F_ROOT = 0x100
NOFLSH = 0x80 NOFLSH = 0x80
NSFS_MAGIC = 0x6e736673 NSFS_MAGIC = 0x6e736673
NS_GET_NSTYPE = 0x2000b703
NS_GET_OWNER_UID = 0x2000b704
NS_GET_PARENT = 0x2000b702
NS_GET_USERNS = 0x2000b701
OCFS2_SUPER_MAGIC = 0x7461636f OCFS2_SUPER_MAGIC = 0x7461636f
OCRNL = 0x8 OCRNL = 0x8
OFDEL = 0x80 OFDEL = 0x80
......
...@@ -1406,6 +1406,10 @@ const ( ...@@ -1406,6 +1406,10 @@ const (
NLM_F_ROOT = 0x100 NLM_F_ROOT = 0x100
NOFLSH = 0x80 NOFLSH = 0x80
NSFS_MAGIC = 0x6e736673 NSFS_MAGIC = 0x6e736673
NS_GET_NSTYPE = 0x2000b703
NS_GET_OWNER_UID = 0x2000b704
NS_GET_PARENT = 0x2000b702
NS_GET_USERNS = 0x2000b701
OCFS2_SUPER_MAGIC = 0x7461636f OCFS2_SUPER_MAGIC = 0x7461636f
OCRNL = 0x8 OCRNL = 0x8
OFDEL = 0x80 OFDEL = 0x80
......
...@@ -1407,6 +1407,10 @@ const ( ...@@ -1407,6 +1407,10 @@ const (
NLM_F_ROOT = 0x100 NLM_F_ROOT = 0x100
NOFLSH = 0x80000000 NOFLSH = 0x80000000
NSFS_MAGIC = 0x6e736673 NSFS_MAGIC = 0x6e736673
NS_GET_NSTYPE = 0x2000b703
NS_GET_OWNER_UID = 0x2000b704
NS_GET_PARENT = 0x2000b702
NS_GET_USERNS = 0x2000b701
OCFS2_SUPER_MAGIC = 0x7461636f OCFS2_SUPER_MAGIC = 0x7461636f
OCRNL = 0x8 OCRNL = 0x8
OFDEL = 0x80 OFDEL = 0x80
......
...@@ -1407,6 +1407,10 @@ const ( ...@@ -1407,6 +1407,10 @@ const (
NLM_F_ROOT = 0x100 NLM_F_ROOT = 0x100
NOFLSH = 0x80000000 NOFLSH = 0x80000000
NSFS_MAGIC = 0x6e736673 NSFS_MAGIC = 0x6e736673
NS_GET_NSTYPE = 0x2000b703
NS_GET_OWNER_UID = 0x2000b704
NS_GET_PARENT = 0x2000b702
NS_GET_USERNS = 0x2000b701
OCFS2_SUPER_MAGIC = 0x7461636f OCFS2_SUPER_MAGIC = 0x7461636f
OCRNL = 0x8 OCRNL = 0x8
OFDEL = 0x80 OFDEL = 0x80
......
...@@ -1406,6 +1406,10 @@ const ( ...@@ -1406,6 +1406,10 @@ const (
NLM_F_ROOT = 0x100 NLM_F_ROOT = 0x100
NOFLSH = 0x80 NOFLSH = 0x80
NSFS_MAGIC = 0x6e736673 NSFS_MAGIC = 0x6e736673
NS_GET_NSTYPE = 0xb703
NS_GET_OWNER_UID = 0xb704
NS_GET_PARENT = 0xb702
NS_GET_USERNS = 0xb701
OCFS2_SUPER_MAGIC = 0x7461636f OCFS2_SUPER_MAGIC = 0x7461636f
OCRNL = 0x8 OCRNL = 0x8
OFDEL = 0x80 OFDEL = 0x80
......
...@@ -1406,6 +1406,10 @@ const ( ...@@ -1406,6 +1406,10 @@ const (
NLM_F_ROOT = 0x100 NLM_F_ROOT = 0x100
NOFLSH = 0x80 NOFLSH = 0x80
NSFS_MAGIC = 0x6e736673 NSFS_MAGIC = 0x6e736673
NS_GET_NSTYPE = 0xb703
NS_GET_OWNER_UID = 0xb704
NS_GET_PARENT = 0xb702
NS_GET_USERNS = 0xb701
OCFS2_SUPER_MAGIC = 0x7461636f OCFS2_SUPER_MAGIC = 0x7461636f
OCRNL = 0x8 OCRNL = 0x8
OFDEL = 0x80 OFDEL = 0x80
......
...@@ -1410,6 +1410,10 @@ const ( ...@@ -1410,6 +1410,10 @@ const (
NLM_F_ROOT = 0x100 NLM_F_ROOT = 0x100
NOFLSH = 0x80 NOFLSH = 0x80
NSFS_MAGIC = 0x6e736673 NSFS_MAGIC = 0x6e736673
NS_GET_NSTYPE = 0x2000b703
NS_GET_OWNER_UID = 0x2000b704
NS_GET_PARENT = 0x2000b702
NS_GET_USERNS = 0x2000b701
OCFS2_SUPER_MAGIC = 0x7461636f OCFS2_SUPER_MAGIC = 0x7461636f
OCRNL = 0x8 OCRNL = 0x8
OFDEL = 0x80 OFDEL = 0x80
......
...@@ -666,7 +666,7 @@ func OpenCurrentProcessToken() (Token, error) { ...@@ -666,7 +666,7 @@ func OpenCurrentProcessToken() (Token, error) {
return 0, e return 0, e
} }
var t Token var t Token
e = OpenProcessToken(p, TOKEN_QUERY, &t) e = OpenProcessToken(p, TOKEN_QUERY|TOKEN_DUPLICATE, &t)
if e != nil { if e != nil {
return 0, e return 0, e
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment