當前位置: 首頁>>代碼示例>>Golang>>正文


Golang LinuxSpec.Mounts方法代碼示例

本文整理匯總了Golang中github.com/opencontainers/specs.LinuxSpec.Mounts方法的典型用法代碼示例。如果您正苦於以下問題:Golang LinuxSpec.Mounts方法的具體用法?Golang LinuxSpec.Mounts怎麽用?Golang LinuxSpec.Mounts使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/opencontainers/specs.LinuxSpec的用法示例。


在下文中一共展示了LinuxSpec.Mounts方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: testFsTypeSupport

func testFsTypeSupport(fstest string) {

	//set file path
	configjsonFilePath := "./../../source/config.json"
	guestProgrammeFileName := ""
	outputFileName := "mount_fstypesupport_out"
	//setup the guest enviroment
	err := hostsetup.SetupEnv(guestProgrammeFileName, outputFileName)
	if err != nil {
		log.Fatalf("[Specstest] mount filesystem support test: hostsetup.SetupEnv error, %v", err)
	}
	fmt.Println("Host enviroment setting up for runc is already!")

	//read the config.json and edit and convert
	var linuxspec *specs.LinuxSpec
	linuxspec, err = configconvert.ConfigToLinuxSpec(configjsonFilePath)
	if err != nil {
		log.Fatalf("[Specstest] mount filesystem support test: reading config error, %v", err)
	}
	linuxspec.Spec.Root.Path = "./rootfs_rootconfig"
	mountsorigin := specs.Mount{"proc", "proc", "/proc", ""}
	mountsadd := specs.Mount{fstest, "/tmp/test", "/testfs", ""}
	mountsnew := []specs.Mount{mountsorigin, mountsadd}
	linuxspec.Mounts = mountsnew
	err = configconvert.LinuxSpecToConfig(configjsonFilePath, linuxspec)
	if err != nil {
		log.Fatalf("[Specstest] mount filesystem support test:writing config error, %v", err)
	}
	fmt.Println("Host enviroment for runc is already!")

}
開發者ID:hqhq,項目名稱:oct,代碼行數:31,代碼來源:mount_fstype_host.go

示例2: addBindMounts

func addBindMounts(spec *specs.LinuxSpec, rspec *specs.LinuxRuntimeSpec, context *cli.Context) error {
	for _, b := range context.StringSlice("bind") {
		var source, dest string
		options := "ro"
		bparts := strings.SplitN(b, ":", 3)
		switch len(bparts) {
		case 2:
			source, dest = bparts[0], bparts[1]
		case 3:
			source, dest, options = bparts[0], bparts[1], bparts[2]
		default:
			return fmt.Errorf("--bind should have format src:dest:[options]")
		}
		name := filepath.Base(source)
		mntName := fmt.Sprintf("%sbind", name)
		spec.Mounts = append(spec.Mounts, specs.MountPoint{Name: mntName, Path: dest})
		defaultOptions := []string{"bind"}
		rspec.Mounts[mntName] = specs.Mount{
			Type:    "bind",
			Source:  source,
			Options: append(defaultOptions, options),
		}
	}
	return nil
}
開發者ID:zenlinTechnofreak,項目名稱:ocitools-bak,代碼行數:25,代碼來源:generate.go

示例3: setMount

func setMount(fsName string, fsType string, fsSrc string, fsDes string, fsOpt []string) (specs.LinuxSpec, specs.LinuxRuntimeSpec) {
	var linuxSpec specs.LinuxSpec = specsinit.SetLinuxspecMinimum()
	var linuxRuntimeSpec specs.LinuxRuntimeSpec = specsinit.SetLinuxruntimeMinimum()
	configMountTest := specs.MountPoint{fsName, fsDes}
	runtimeMountTest := specs.Mount{fsType, fsSrc, fsOpt}
	linuxSpec.Mounts = append(linuxSpec.Mounts, configMountTest)
	linuxRuntimeSpec.Mounts[fsName] = runtimeMountTest
	return linuxSpec, linuxRuntimeSpec
}
開發者ID:WeiZhang555,項目名稱:oct,代碼行數:9,代碼來源:specmount_v0.1.1.go

示例4: addMountPoint

func addMountPoint(spec *specs.LinuxSpec, rspec *specs.LinuxRuntimeSpec, context *cli.Context) error {
	for _, mps := range context.StringSlice("mountpoint-add") {
		mp := strings.Split(mps, ":")
		if len(mp) == 2 {
			newmp := specs.MountPoint{mp[0], mp[1]}
			spec.Mounts = append(spec.Mounts, newmp)
		} else {
			return fmt.Errorf("mountpoint-add error: %s", mps)
		}
	}
	return nil
}
開發者ID:zenlinTechnofreak,項目名稱:ocitools-bak,代碼行數:12,代碼來源:generate.go

示例5: addTmpfsMounts

func addTmpfsMounts(spec *specs.LinuxSpec, context *cli.Context) error {
	for _, dest := range context.StringSlice("tmpfs") {
		mnt := specs.Mount{
			Destination: dest,
			Type:        "tmpfs",
			Source:      "tmpfs",
			Options:     []string{"nosuid", "nodev", "mode=755"},
		}
		spec.Mounts = append(spec.Mounts, mnt)
	}
	return nil
}
開發者ID:wangkirin,項目名稱:ocitools,代碼行數:12,代碼來源:generate.go

示例6: SetBind

func SetBind(linuxRuntime *specs.LinuxRuntimeSpec, linuxSpec *specs.LinuxSpec) {

	//testtoolfolder := specs.Mount{"bind", resource, "/testtool", "bind"}
	result := os.Getenv("GOPATH")
	if result == "" {
		log.Fatalf("utils.setBind error GOPATH == nil")
	}
	source := result + "/src/github.com/huawei-openlab/oct/tools/runtimeValidator/containerend"
	mountpoint := specs.MountPoint{"bind", "/containerend"}
	linuxSpec.Mounts = append(linuxSpec.Mounts, mountpoint)
	linuxRuntime.Mounts["bind"] = specs.Mount{"bind", source, []string{"bind"}}

	SetRight(source, linuxSpec.Process.User.UID, linuxSpec.Process.User.GID)
}
開發者ID:WeiZhang555,項目名稱:oct,代碼行數:14,代碼來源:bind_v0.1.1.go

示例7: addTmpfsMounts

func addTmpfsMounts(spec *specs.LinuxSpec, rspec *specs.LinuxRuntimeSpec, context *cli.Context) error {
	for _, dest := range context.StringSlice("tmpfs") {
		name := filepath.Base(dest)
		mntName := fmt.Sprintf("%stmpfs", name)
		mnt := specs.MountPoint{Name: mntName, Path: dest}
		spec.Mounts = append(spec.Mounts, mnt)
		rmnt := specs.Mount{
			Type:    "tmpfs",
			Source:  "tmpfs",
			Options: []string{"nosuid", "nodev", "mode=755"},
		}
		rspec.Mounts[mntName] = rmnt
	}
	return nil
}
開發者ID:zenlinTechnofreak,項目名稱:ocitools-bak,代碼行數:15,代碼來源:generate.go

示例8: mountCgroups

func mountCgroups(spec *specs.LinuxSpec, rspec *specs.LinuxRuntimeSpec, context *cli.Context) error {
	mountCgroupOption := context.String("mount-cgroups")
	switch mountCgroupOption {
	case "ro":
	case "rw":
	case "no":
		return nil
	default:
		return fmt.Errorf("--mount-cgroups should be one of (ro,rw,no)")
	}

	spec.Mounts = append(spec.Mounts, specs.MountPoint{Name: "cgroup", Path: "/sys/fs/cgroup"})
	rspec.Mounts["cgroup"] = specs.Mount{
		Type:    "cgroup",
		Source:  "cgroup",
		Options: []string{"nosuid", "noexec", "nodev", "relatime", mountCgroupOption},
	}

	return nil
}
開發者ID:zenlinTechnofreak,項目名稱:ocitools-bak,代碼行數:20,代碼來源:generate.go

示例9: mountCgroups

func mountCgroups(spec *specs.LinuxSpec, context *cli.Context) error {
	mountCgroupOption := context.String("mount-cgroups")
	switch mountCgroupOption {
	case "ro":
	case "rw":
	case "no":
		return nil
	default:
		return fmt.Errorf("--mount-cgroups should be one of (ro,rw,no)")
	}

	mnt := specs.Mount{
		Destination: "/sys/fs/cgroup",
		Type:        "cgroup",
		Source:      "cgroup",
		Options:     []string{"nosuid", "noexec", "nodev", "relatime", mountCgroupOption},
	}
	spec.Mounts = append(spec.Mounts, mnt)

	return nil
}
開發者ID:wangkirin,項目名稱:ocitools,代碼行數:21,代碼來源:generate.go

示例10: addBindMounts

func addBindMounts(spec *specs.LinuxSpec, context *cli.Context) error {
	for _, b := range context.StringSlice("bind") {
		var source, dest string
		options := "ro"
		bparts := strings.SplitN(b, ":", 3)
		switch len(bparts) {
		case 2:
			source, dest = bparts[0], bparts[1]
		case 3:
			source, dest, options = bparts[0], bparts[1], bparts[2]
		default:
			return fmt.Errorf("--bind should have format src:dest:[options]")
		}
		defaultOptions := []string{"bind"}
		mnt := specs.Mount{
			Destination: dest,
			Type:        "bind",
			Source:      source,
			Options:     append(defaultOptions, options),
		}
		spec.Mounts = append(spec.Mounts, mnt)
	}
	return nil
}
開發者ID:wangkirin,項目名稱:ocitools,代碼行數:24,代碼來源:generate.go

示例11: setupSdNotify

// If systemd is supporting sd_notify protocol, this function will add support
// for sd_notify protocol from within the container.
func setupSdNotify(spec *specs.LinuxSpec, rspec *specs.LinuxRuntimeSpec, notifySocket string) {
	mountName := "sdNotify"
	spec.Mounts = append(spec.Mounts, specs.MountPoint{Name: mountName, Path: notifySocket})
	spec.Process.Env = append(spec.Process.Env, fmt.Sprintf("NOTIFY_SOCKET=%s", notifySocket))
	rspec.Mounts[mountName] = specs.Mount{Type: "bind", Source: notifySocket, Options: []string{"bind"}}
}
開發者ID:erictchiu,項目名稱:runc,代碼行數:8,代碼來源:start.go

示例12: setupSdNotify

// If systemd is supporting sd_notify protocol, this function will add support
// for sd_notify protocol from within the container.
func setupSdNotify(spec *specs.LinuxSpec, notifySocket string) {
	spec.Mounts = append(spec.Mounts, specs.Mount{Destination: notifySocket, Type: "bind", Source: notifySocket, Options: []string{"bind"}})
	spec.Process.Env = append(spec.Process.Env, fmt.Sprintf("NOTIFY_SOCKET=%s", notifySocket))
}
開發者ID:pagarme,項目名稱:runc,代碼行數:6,代碼來源:utils.go


注:本文中的github.com/opencontainers/specs.LinuxSpec.Mounts方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。