예제 #1
0
파일: walk.go 프로젝트: wxdublin/Dominator
func addSymlink(directory *filesystem.Directory, fileSystem, oldFS *FileSystem,
	name string, directoryPathName string, stat *syscall.Stat_t) error {
	inode, isNewInode := fileSystem.getSymlinkInode(stat)
	var symlink filesystem.Symlink
	symlink.Name = name
	symlink.InodeNumber = stat.Ino
	symlink.SetInode(inode)
	if isNewInode {
		err := scanSymlink(&symlink, fileSystem, directoryPathName)
		if err != nil {
			return err
		}
		if oldFS != nil && oldFS.SymlinkInodeTable != nil {
			if oldInode, found := oldFS.SymlinkInodeTable[stat.Ino]; found {
				if filesystem.CompareSymlinkInodes(inode, oldInode, nil) {
					inode = oldInode
					symlink.SetInode(inode)
					fileSystem.SymlinkInodeTable[stat.Ino] = inode
				}
			}
		}
	}
	directory.SymlinkList = append(directory.SymlinkList, &symlink)
	return nil
}
예제 #2
0
파일: walk.go 프로젝트: datatonic/Dominator
func addSymlink(dirent *filesystem.DirectoryEntry,
	fileSystem, oldFS *FileSystem,
	directoryPathName string, stat *syscall.Stat_t) error {
	if inode, ok := fileSystem.InodeTable[stat.Ino]; ok {
		if inode, ok := inode.(*filesystem.SymlinkInode); ok {
			dirent.SetInode(inode)
			return nil
		}
		return errors.New("Inode changed type: " + dirent.Name)
	}
	inode := makeSymlinkInode(stat)
	err := scanSymlinkInode(inode, fileSystem,
		path.Join(directoryPathName, dirent.Name))
	if err != nil {
		return err
	}
	if oldFS != nil && oldFS.InodeTable != nil {
		if oldInode, found := oldFS.InodeTable[stat.Ino]; found {
			if oldInode, ok := oldInode.(*filesystem.SymlinkInode); ok {
				if filesystem.CompareSymlinkInodes(inode, oldInode, nil) {
					inode = oldInode
				}
			}
		}
	}
	dirent.SetInode(inode)
	fileSystem.InodeTable[stat.Ino] = inode
	return nil
}
예제 #3
0
func compareSymlink(request *subproto.UpdateRequest, state *state,
	subEntry interface{}, requiredSymlink *filesystem.Symlink,
	parentName string) {
	debugFilename := path.Join(parentName, requiredSymlink.Name)
	if subSymlink, ok := subEntry.(*filesystem.Symlink); ok {
		if requiredInode, ok :=
			state.subInodeToRequiredInode[subSymlink.InodeNumber]; ok {
			if requiredInode != requiredSymlink.InodeNumber {
				fmt.Printf("Different links: %s...\n", debugFilename) // HACK
			}
		} else {
			state.subInodeToRequiredInode[subSymlink.InodeNumber] =
				requiredSymlink.InodeNumber
		}
		if filesystem.CompareSymlinkInodes(subSymlink.Inode(),
			requiredSymlink.Inode(), os.Stdout) {
			return
		}
		fmt.Printf("Different symlink: %s...\n", debugFilename) // HACK
	} else {
		fmt.Printf("Add symlink: %s...\n", debugFilename) // HACK
	}
	// TODO(rgooch): Delete entry and replace.
}