Esempio n. 1
0
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
}
Esempio n. 2
0
// 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
}
Esempio n. 3
0
// 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
}
Esempio n. 4
0
// 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
}
Esempio n. 5
0
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)
}
Esempio n. 6
0
// 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))
}
Esempio n. 7
0
// 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)
}
Esempio n. 8
0
func Mount(src, dst string, readOnly bool) error {
	//return syscall.Symlink(src, dst)
	return syscall.Link(src, dst)
}
Esempio n. 9
0
func (k *PosixKernel) Link(src, dst string) uint64 {
	return Errno(syscall.Link(src, dst))
}
Esempio n. 10
0
func mount(src, dst string) error {
	//return syscall.Symlink(src, dst)
	return syscall.Link(src, dst)
}