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


Golang FileSystem.FilenameToInodeTable方法代码示例

本文整理汇总了Golang中github.com/Symantec/Dominator/lib/filesystem.FileSystem.FilenameToInodeTable方法的典型用法代码示例。如果您正苦于以下问题:Golang FileSystem.FilenameToInodeTable方法的具体用法?Golang FileSystem.FilenameToInodeTable怎么用?Golang FileSystem.FilenameToInodeTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/Symantec/Dominator/lib/filesystem.FileSystem的用法示例。


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

示例1: deleteUnneededFiles

func deleteUnneededFiles(srpcClient *srpc.Client, subFS *filesystem.FileSystem,
	imgFS *filesystem.FileSystem, logger *log.Logger) bool {
	startTime := showStart("compute early files to delete")
	pathsToDelete := make([]string, 0)
	imgHashToInodesTable := imgFS.HashToInodesTable()
	imgFilenameToInodeTable := imgFS.FilenameToInodeTable()
	for pathname, inum := range subFS.FilenameToInodeTable() {
		if inode, ok := subFS.InodeTable[inum].(*filesystem.RegularInode); ok {
			if inode.Size > 0 {
				if _, ok := imgHashToInodesTable[inode.Hash]; !ok {
					pathsToDelete = append(pathsToDelete, pathname)
				}
			} else {
				if _, ok := imgFilenameToInodeTable[pathname]; !ok {
					pathsToDelete = append(pathsToDelete, pathname)
				}
			}
		}
	}
	showTimeTaken(startTime)
	if len(pathsToDelete) < 1 {
		return false
	}
	updateRequest := sub.UpdateRequest{
		Wait:          true,
		PathsToDelete: pathsToDelete}
	var updateReply sub.UpdateResponse
	startTime = showStart("Subd.Update() for early files to delete")
	err := client.CallUpdate(srpcClient, updateRequest, &updateReply)
	showTimeTaken(startTime)
	if err != nil {
		logger.Println(err)
	}
	return true
}
开发者ID:keep94,项目名称:Dominator,代码行数:35,代码来源:pushImage.go

示例2: spliceComputedFiles

func spliceComputedFiles(fs *filesystem.FileSystem) error {
	if *computedFiles == "" {
		return nil
	}
	computedFileList, err := loadComputedFiles(*computedFiles)
	if err != nil {
		return errors.New("cannot load computed files list from: " +
			*computedFiles + ": " + err.Error())
	}
	filenameToInodeTable := fs.FilenameToInodeTable()
	inodeToFilenamesTable := fs.InodeToFilenamesTable()
	for _, computedFile := range computedFileList {
		inum, ok := filenameToInodeTable[computedFile.Filename]
		if !ok {
			return errors.New(computedFile.Filename + ": missing from image")
		}
		if filenames, ok := inodeToFilenamesTable[inum]; !ok {
			panic(computedFile.Filename + ": no corresponding list of files")
		} else if len(filenames) != 1 {
			return fmt.Errorf("%s: multiple inodes: %d", computedFile.Filename,
				len(filenames))
		}
		if inode, ok :=
			fs.InodeTable[inum].(*filesystem.ComputedRegularInode); ok {
			inode.Source = computedFile.Source
			continue
		}
		if oldInode, ok := fs.InodeTable[inum].(*filesystem.RegularInode); !ok {
			return fmt.Errorf("%s: type: %T is not a regular inode",
				computedFile.Filename, fs.InodeTable[inum])
		} else {
			newInode := new(filesystem.ComputedRegularInode)
			newInode.Mode = oldInode.Mode
			newInode.Uid = oldInode.Uid
			newInode.Gid = oldInode.Gid
			newInode.Source = computedFile.Source
			fs.InodeTable[inum] = newInode
		}
	}
	fs.ComputeTotalDataBytes()
	clearInodePointers(&fs.DirectoryInode, "")
	return fs.RebuildInodePointers()
}
开发者ID:keep94,项目名称:Dominator,代码行数:43,代码来源:computedFiles.go

示例3: layerImages

func layerImages(baseFS *filesystem.FileSystem,
	layerFS *filesystem.FileSystem) error {
	for filename, layerInum := range layerFS.FilenameToInodeTable() {
		layerInode := layerFS.InodeTable[layerInum]
		if _, ok := layerInode.(*filesystem.DirectoryInode); ok {
			continue
		}
		baseInum, ok := baseFS.FilenameToInodeTable()[filename]
		if !ok {
			return errors.New(filename + " missing in base image")
		}
		baseInode := baseFS.InodeTable[baseInum]
		sameType, sameMetadata, sameData := filesystem.CompareInodes(baseInode,
			layerInode, nil)
		if !sameType {
			return errors.New(filename + " changed type")
		}
		if sameMetadata && sameData {
			continue
		}
		baseFS.InodeTable[baseInum] = layerInode
	}
	return nil
}
开发者ID:keep94,项目名称:Dominator,代码行数:24,代码来源:addReplaceImage.go


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