本文整理汇总了Golang中github.com/Symantec/Dominator/lib/filesystem.FileSystem.InodeToFilenamesTable方法的典型用法代码示例。如果您正苦于以下问题:Golang FileSystem.InodeToFilenamesTable方法的具体用法?Golang FileSystem.InodeToFilenamesTable怎么用?Golang FileSystem.InodeToFilenamesTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/Symantec/Dominator/lib/filesystem.FileSystem
的用法示例。
在下文中一共展示了FileSystem.InodeToFilenamesTable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: copyMissingObjects
func copyMissingObjects(fs *filesystem.FileSystem, imageSClient *srpc.Client,
objectClient *objectclient.ObjectClient, subName string) error {
// Check to see which objects are in the objectserver.
hashes := make([]hash.Hash, 0, fs.NumRegularInodes)
for hash, _ := range fs.HashToInodesTable() {
hashes = append(hashes, hash)
}
objectSizes, err := objectClient.CheckObjects(hashes)
if err != nil {
return err
}
missingHashes := make([]hash.Hash, 0)
for index, size := range objectSizes {
if size < 1 {
missingHashes = append(missingHashes, hashes[index])
}
}
if len(missingHashes) < 1 {
return nil
}
// Get missing objects from sub.
filesForMissingObjects := make([]string, 0, len(missingHashes))
for _, hash := range missingHashes {
if inums, ok := fs.HashToInodesTable()[hash]; !ok {
return fmt.Errorf("no inode for object: %x", hash)
} else if files, ok := fs.InodeToFilenamesTable()[inums[0]]; !ok {
return fmt.Errorf("no file for inode: %d", inums[0])
} else {
filesForMissingObjects = append(filesForMissingObjects, files[0])
}
}
objAdderQueue, err := objectclient.NewObjectAdderQueue(imageSClient)
if err != nil {
return err
}
subClient, err := srpc.DialHTTP("tcp",
fmt.Sprintf("%s:%d", subName, constants.SubPortNumber), 0)
if err != nil {
return fmt.Errorf("error dialing %s", err)
}
defer subClient.Close()
if err := subclient.GetFiles(subClient, filesForMissingObjects,
func(reader io.Reader, size uint64) error {
_, err := objAdderQueue.Add(reader, size)
return err
}); err != nil {
return err
}
return objAdderQueue.Close()
}
示例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()
}