本文整理汇总了Golang中github.com/seccomp/libseccomp-golang.GetNativeArch函数的典型用法代码示例。如果您正苦于以下问题:Golang GetNativeArch函数的具体用法?Golang GetNativeArch怎么用?Golang GetNativeArch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetNativeArch函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: arches
func arches() []types.Arch {
var native, err = libseccomp.GetNativeArch()
if err != nil {
return []types.Arch{}
}
var a = native.String()
switch a {
case "amd64":
return []types.Arch{types.ArchX86_64, types.ArchX86, types.ArchX32}
case "arm64":
return []types.Arch{types.ArchARM, types.ArchAARCH64}
case "mips64":
return []types.Arch{types.ArchMIPS, types.ArchMIPS64, types.ArchMIPS64N32}
case "mips64n32":
return []types.Arch{types.ArchMIPS, types.ArchMIPS64, types.ArchMIPS64N32}
case "mipsel64":
return []types.Arch{types.ArchMIPSEL, types.ArchMIPSEL64, types.ArchMIPSEL64N32}
case "mipsel64n32":
return []types.Arch{types.ArchMIPSEL, types.ArchMIPSEL64, types.ArchMIPSEL64N32}
case "s390x":
return []types.Arch{types.ArchS390, types.ArchS390X}
default:
return []types.Arch{}
}
}
开发者ID:kolyshkin,项目名称:docker,代码行数:25,代码来源:seccomp_default.go
示例2: arches
func arches() []string {
var native, err = libseccomp.GetNativeArch()
if err != nil {
return []string{}
}
var a = native.String()
switch a {
case "amd64":
return []string{"amd64", "x86", "x32"}
case "arm64":
return []string{"arm64", "arm"}
case "mips64":
return []string{"mips64", "mips64n32", "mips"}
case "mips64n32":
return []string{"mips64", "mips64n32", "mips"}
case "mipsel64":
return []string{"mipsel64", "mipsel64n32", "mipsel"}
case "mipsel64n32":
return []string{"mipsel64", "mipsel64n32", "mipsel"}
default:
return []string{a}
}
}
开发者ID:gao-feng,项目名称:docker,代码行数:23,代码来源:seccomp_default.go
示例3: arches
func arches() []specs.Arch {
var native, err = libseccomp.GetNativeArch()
if err != nil {
return []specs.Arch{}
}
var a = native.String()
switch a {
case "amd64":
return []specs.Arch{specs.ArchX86_64, specs.ArchX86, specs.ArchX32}
case "arm64":
return []specs.Arch{specs.ArchAARCH64, specs.ArchARM}
case "mips64":
return []specs.Arch{specs.ArchMIPS, specs.ArchMIPS64, specs.ArchMIPS64N32}
case "mips64n32":
return []specs.Arch{specs.ArchMIPS, specs.ArchMIPS64, specs.ArchMIPS64N32}
case "mipsel64":
return []specs.Arch{specs.ArchMIPSEL, specs.ArchMIPSEL64, specs.ArchMIPSEL64N32}
case "mipsel64n32":
return []specs.Arch{specs.ArchMIPSEL, specs.ArchMIPSEL64, specs.ArchMIPSEL64N32}
default:
return []specs.Arch{}
}
}
开发者ID:ailispaw,项目名称:docker,代码行数:23,代码来源:seccomp_default_linux.go
示例4: DefaultProfile
//.........这里部分代码省略.........
{
Name: "vmsplice",
Action: types.ActAllow,
Args: []*types.Arg{},
},
{
Name: "wait4",
Action: types.ActAllow,
Args: []*types.Arg{},
},
{
Name: "waitid",
Action: types.ActAllow,
Args: []*types.Arg{},
},
{
Name: "waitpid",
Action: types.ActAllow,
Args: []*types.Arg{},
},
{
Name: "write",
Action: types.ActAllow,
Args: []*types.Arg{},
},
{
Name: "writev",
Action: types.ActAllow,
Args: []*types.Arg{},
},
}
var arch string
var native, err = libseccomp.GetNativeArch()
if err == nil {
arch = native.String()
}
switch arch {
case "arm", "arm64":
syscalls = append(syscalls, []*types.Syscall{
{
Name: "breakpoint",
Action: types.ActAllow,
Args: []*types.Arg{},
},
{
Name: "cacheflush",
Action: types.ActAllow,
Args: []*types.Arg{},
},
{
Name: "set_tls",
Action: types.ActAllow,
Args: []*types.Arg{},
},
}...)
case "amd64", "x32":
syscalls = append(syscalls, []*types.Syscall{
{
Name: "arch_prctl",
Action: types.ActAllow,
Args: []*types.Arg{},
},
}...)
fallthrough
case "x86":
开发者ID:lujiwen,项目名称:docker,代码行数:67,代码来源:seccomp_default.go
示例5: setupSeccomp
func setupSeccomp(config *types.Seccomp, rs *specs.Spec) (*specs.Seccomp, error) {
if config == nil {
return nil, nil
}
// No default action specified, no syscalls listed, assume seccomp disabled
if config.DefaultAction == "" && len(config.Syscalls) == 0 {
return nil, nil
}
newConfig := &specs.Seccomp{}
var arch string
var native, err = libseccomp.GetNativeArch()
if err == nil {
arch = native.String()
}
if len(config.Architectures) != 0 && len(config.ArchMap) != 0 {
return nil, errors.New("'architectures' and 'archMap' were specified in the seccomp profile, use either 'architectures' or 'archMap'")
}
// if config.Architectures == 0 then libseccomp will figure out the architecture to use
if len(config.Architectures) != 0 {
for _, a := range config.Architectures {
newConfig.Architectures = append(newConfig.Architectures, specs.Arch(a))
}
}
if len(config.ArchMap) != 0 {
for _, a := range config.ArchMap {
seccompArch, ok := nativeToSeccomp[arch]
if ok {
if a.Arch == seccompArch {
newConfig.Architectures = append(newConfig.Architectures, specs.Arch(a.Arch))
for _, sa := range a.SubArches {
newConfig.Architectures = append(newConfig.Architectures, specs.Arch(sa))
}
break
}
}
}
}
newConfig.DefaultAction = specs.Action(config.DefaultAction)
Loop:
// Loop through all syscall blocks and convert them to libcontainer format after filtering them
for _, call := range config.Syscalls {
if len(call.Excludes.Arches) > 0 {
if stringutils.InSlice(call.Excludes.Arches, arch) {
continue Loop
}
}
if len(call.Excludes.Caps) > 0 {
for _, c := range call.Excludes.Caps {
if stringutils.InSlice(rs.Process.Capabilities, c) {
continue Loop
}
}
}
if len(call.Includes.Arches) > 0 {
if !stringutils.InSlice(call.Includes.Arches, arch) {
continue Loop
}
}
if len(call.Includes.Caps) > 0 {
for _, c := range call.Includes.Caps {
if !stringutils.InSlice(rs.Process.Capabilities, c) {
continue Loop
}
}
}
if call.Name != "" && len(call.Names) != 0 {
return nil, errors.New("'name' and 'names' were specified in the seccomp profile, use either 'name' or 'names'")
}
if call.Name != "" {
newConfig.Syscalls = append(newConfig.Syscalls, createSpecsSyscall(call.Name, call.Action, call.Args))
}
for _, n := range call.Names {
newConfig.Syscalls = append(newConfig.Syscalls, createSpecsSyscall(n, call.Action, call.Args))
}
}
return newConfig, nil
}
开发者ID:HuKeping,项目名称:docker,代码行数:89,代码来源:seccomp.go
注:本文中的github.com/seccomp/libseccomp-golang.GetNativeArch函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论