本文整理汇总了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
}
示例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
}
示例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
}
示例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
}
示例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)
}
示例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))
}
示例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)
}
示例8: Mount
func Mount(src, dst string, readOnly bool) error {
//return syscall.Symlink(src, dst)
return syscall.Link(src, dst)
}
示例9: Link
func (k *PosixKernel) Link(src, dst string) uint64 {
return Errno(syscall.Link(src, dst))
}
示例10: mount
func mount(src, dst string) error {
//return syscall.Symlink(src, dst)
return syscall.Link(src, dst)
}