当前位置: 首页>>代码示例>>Golang>>正文


Golang syscall.Link函数代码示例

本文整理汇总了Golang中syscall.Link函数的典型用法代码示例。如果您正苦于以下问题:Golang Link函数的具体用法?Golang Link怎么用?Golang Link使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Link函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Mount

func Mount(source string, target string, fstype string, flags uintptr, data string) error {
	// bind mount is treated as hard link
	if err := syscall.Link(source, target); err != nil {
		return err
	}
	return nil
}
开发者ID:m1911,项目名称:hyper,代码行数:7,代码来源:utils_darwin.go

示例2: Link

// Link creates a hard link.
func Link(oldname, newname string) Error {
	e := syscall.Link(oldname, newname)
	if e != 0 {
		return &LinkError{"link", oldname, newname, Errno(e)}
	}
	return nil
}
开发者ID:lougxing,项目名称:golang-china,代码行数:8,代码来源:file.go

示例3: Link

// Link creates newname as a hard link to the oldname file.
// If there is an error, it will be of type *LinkError.
func Link(oldname, newname string) error {
	e := syscall.Link(oldname, newname)
	if e != nil {
		return &LinkError{"link", oldname, newname, e}
	}
	return nil
}
开发者ID:kuangchanglang,项目名称:go,代码行数:9,代码来源:file_unix.go

示例4: updateDisk

// Returns true if there were any operations performed
func updateDisk(files_to_add filesOfCatalog,
	files_to_remove filesOfCatalog,
	catalog_root string) bool {
	changes_made := false

	for catspec, files_by_path := range files_to_add {
		for path, link := range files_by_path {
			tgt_path := filepath.Join(catalog_root, catspec.Catrel, catspec.Arch,
				shortenOsrel(catspec.Osrel), path)
			if link.link_type == hardlink {
				src_path := filepath.Join(catalog_root, "allpkgs", path)
				if !DryRun {
					if err := syscall.Link(src_path, tgt_path); err != nil {
						log.Fatalf("Could not create hardlink from %v to %v: %v",
							src_path, tgt_path, err)
					}
				}
				log.Printf("ln \"%s\"\n   \"%s\"\n", src_path, tgt_path)
				changes_made = true
			} else if link.link_type == symlink {
				// The source path is relative to the target, because it's a symlink
				src_path := *(link.target)
				if !DryRun {
					if err := syscall.Symlink(src_path, tgt_path); err != nil {
						log.Fatalf("Could not symlink %v to %v: %v", src_path, tgt_path, err)
					}
				}
				log.Printf("ln -s \"%s\"\n  \"%s\"\n", src_path, tgt_path)
				changes_made = true
			} else {
				log.Fatalln("Zonk! Wrong link type in %+v", link)
			}
		}
	}

	for catspec, files_by_path := range files_to_remove {
		for path, _ := range files_by_path {
			pkg_path := filepath.Join(catalog_root, catspec.Catrel, catspec.Arch,
				shortenOsrel(catspec.Osrel), path)
			if !DryRun {
				if err := syscall.Unlink(pkg_path); err != nil {
					log.Fatalf("Could not unlink %v: %v", pkg_path, err)
				}
			}
			log.Printf("rm \"%s\"\n", pkg_path)
			changes_made = true
		}
	}
	return changes_made
}
开发者ID:dago,项目名称:opencsw,代码行数:51,代码来源:diskformat.go

示例5: Link

func (constor *Constor) Link(input *fuse.LinkIn, name string, out *fuse.EntryOut) (code fuse.Status) {
	constor.log("%d %d %s", input.Oldnodeid, input.NodeId, name)
	oldpath, err := constor.dentrymap.getPath(input.Oldnodeid)
	if err != nil {
		return fuse.ToStatus(err)
	}
	li := constor.getLayer(oldpath)
	if li != 0 {
		inode, err := constor.inodemap.findInode(input.Oldnodeid)
		if err != nil {
			return fuse.ToStatus(err)
		}
		err = constor.copyup(inode)
		if err != nil {
			return fuse.ToStatus(err)
		}
	}
	newpath, err := constor.dentrymap.getPathName(input.NodeId, name)
	if err != nil {
		return fuse.ToStatus(err)
	}
	oldpathl := Path.Join(constor.layers[0], oldpath)
	newpathl := Path.Join(constor.layers[0], newpath)
	err = syscall.Link(oldpathl, newpathl)
	if err != nil {
		return fuse.ToStatus(err)
	}
	stat := syscall.Stat_t{}
	err = constor.Lstat(oldpath, &stat)
	if err != nil {
		return fuse.ToStatus(err)
	}
	inoitoa := strconv.Itoa(int(stat.Ino))
	inobyte := []byte(inoitoa)
	if err = Lsetxattr(newpathl, INOXATTR, inobyte, 0); err != nil {
		return fuse.ToStatus(err)
	}
	return constor.Lookup((*fuse.InHeader)(unsafe.Pointer(input)), name, out)
}
开发者ID:krishnasrinivas,项目名称:constor,代码行数:39,代码来源:main.go

示例6: Link

// Link implements pathfs.Filesystem.
func (fs *FS) Link(oldPath string, newPath string, context *fuse.Context) (code fuse.Status) {
	if fs.isFiltered(newPath) {
		return fuse.EPERM
	}
	cOldPath, err := fs.getBackingPath(oldPath)
	if err != nil {
		return fuse.ToStatus(err)
	}
	cNewPath, err := fs.getBackingPath(newPath)
	if err != nil {
		return fuse.ToStatus(err)
	}

	// Handle long file name
	cNewName := filepath.Base(cNewPath)
	if nametransform.IsLongContent(cNewName) {
		dirfd, err := os.Open(filepath.Dir(cNewPath))
		if err != nil {
			return fuse.ToStatus(err)
		}
		defer dirfd.Close()
		err = fs.nameTransform.WriteLongName(dirfd, cNewName, newPath)
		if err != nil {
			return fuse.ToStatus(err)
		}
		// TODO Use syscall.Linkat once it is available in Go (it is not in Go
		// 1.6).
		err = syscall.Link(cOldPath, cNewPath)
		if err != nil {
			nametransform.DeleteLongName(dirfd, cNewName)
			return fuse.ToStatus(err)
		}
	}

	return fuse.ToStatus(os.Link(cOldPath, cNewPath))
}
开发者ID:rfjakob,项目名称:gocryptfs,代码行数:37,代码来源:fs.go

示例7: mountSharedDir

// Hardlinks the shared directory. As a side-effect the shared directory and
// task directory must be on the same filesystem.
func (d *AllocDir) mountSharedDir(dir string) error {
	return syscall.Link(d.SharedDir, dir)
}
开发者ID:PagerDuty,项目名称:nomad,代码行数:5,代码来源:alloc_dir_freebsd.go

示例8: Mount

func Mount(src, dst string, readOnly bool) error {
	//return syscall.Symlink(src, dst)
	return syscall.Link(src, dst)
}
开发者ID:hyperhq,项目名称:runv,代码行数:4,代码来源:mount_darwin.go

示例9: Link

func (k *PosixKernel) Link(src, dst string) uint64 {
	return Errno(syscall.Link(src, dst))
}
开发者ID:lunixbochs,项目名称:usercorn,代码行数:3,代码来源:io.go

示例10: mount

func mount(src, dst string) error {
	//return syscall.Symlink(src, dst)
	return syscall.Link(src, dst)
}
开发者ID:justincormack,项目名称:runv,代码行数:4,代码来源:runv_darwin.go


注:本文中的syscall.Link函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。