// GetIndirectFileBlockInfosWithTopBlock returns the block infos
// contained in all the indirect blocks in this file tree, given an
// already-fetched top block.
167632
func (fd *FileData) GetIndirectFileBlockInfosWithTopBlock(
	ctx context.Context, topBlock *FileBlock) ([]BlockInfo, error) {
	return fd.tree.getIndirectBlockInfosWithTopBlock(ctx, topBlock)
}
932147
func GetBlockIndex0Ctx(r *http.Request) int {
	idx, ok := r.Context().Value(ctxBlockIndex0).(int)
	if !ok {
		apiLog.Error("block index0 is not set or is not an int")
		return -1
	}
	return idx
}
1095207
func (s *ChainService) GetBlockHeader(
	blockHash *chainhash.Hash) (*wire.BlockHeader, error) {
	header, _, err := s.BlockHeaders.FetchHeader(blockHash)
	return header, err
}
958137
func (fb *FileBlock) SetIndirectPtrInfo(i int, info BlockInfo) {
	if !fb.IsInd {
		panic("SetIndirectPtrInfo called on a direct file block")
	}
	fb.IPtrs[i].BlockInfo = info
}
853264
func (db *PublicRecord) GetBlockTip() (*ombjson.Block, error) {
	row := db.selectBlockTip.QueryRow()
	return scanBlockHead(row)
}
1026688
func GetInfo(path string) (info Info, err error) {
	s := syscall.Statfs_t{}
	err = syscall.Statfs(path, &s)
	if err != nil {
		return Info{}, err
	}
	reservedBlocks := uint64(s.Bfree) - uint64(s.Bavail)
	info = Info{
		Total:  uint64(s.Bsize) * (uint64(s.Blocks) - reservedBlocks),
		Free:   uint64(s.Bsize) * uint64(s.Bavail),
		Files:  uint64(s.Files),
		Ffree:  uint64(s.Ffree),
		FSType: getFSType(s.Fstypename[:]),
	}
	return info, nil
}
132008
func (db *DirBlock) IndirectPtr(i int) (BlockInfo, Offset) {
	if !db.IsInd {
		panic("IndirectPtr called on a direct directory block")
	}
	iptr := db.IPtrs[i]
	off := StringOffset(iptr.Off)
	return iptr.BlockInfo, &off
}
749686
func FSInfo(file string) (FSInfoData, error) {
	once.Do(loadKmod)
	var info FSInfoData

	out, err := ploopOut("-v-1", "info", file)
	if err == nil {
		info.BlockSize = 1024 // ploop info reports in 1-k blocks
		i := reFSInfo.FindStringSubmatch(out)
		if len(i) != 5 {
			return info, &Err{c: -1,
				s: "Can't parse ploop info output:\n" + out}
		}

		info.Blocks, _ = strconv.ParseUint(i[1], 10, 64)
		blocksUsed, _ := strconv.ParseUint(i[2], 10, 64)
		info.BlocksFree = info.Blocks - blocksUsed

		info.Inodes, _ = strconv.ParseUint(i[3], 10, 64)
		inodesUsed, _ := strconv.ParseUint(i[4], 10, 64)
		info.InodesFree = info.Inodes - inodesUsed
	}

	return info, err
}
684745
func handleStopNotifyBlocks(wsc *wsClient, icmd interface{}) (interface{}, error) {
	wsc.server.ntfnMgr.UnregisterBlockUpdates(wsc)
	return nil, nil
}
71720
func (p *BlockPrefetchClient) GetBestBlock() (*chainhash.Hash, int64, error) {
	return p.f.GetBestBlock()
}
558833
func (cr *ConflictResolver) addChildBlocksIfIndirectFile(
	ctx context.Context, lState *kbfssync.LockState, unmergedChains *crChains,
	currPath data.Path, op op) error {
	// For files with indirect pointers, add all child blocks
	// as refblocks for the re-created file.
	infos, err := cr.fbo.blocks.GetIndirectFileBlockInfos(
		ctx, lState, unmergedChains.mostRecentChainMDInfo, currPath)
	if err != nil {
		return err
	}
	if len(infos) > 0 {
		cr.log.CDebugf(ctx, "Adding child pointers for recreated "+
			"file %s", currPath)
		for _, info := range infos {
			op.AddRefBlock(info.BlockPointer)
		}
	}
	return nil
}
46546
func (api *PrivateDebugAPI) StandardTraceBlockToFile(ctx context.Context, hash common.Hash, config *StdTraceConfig) ([]string, error) {
	block := api.eth.blockchain.GetBlockByHash(hash)
	if block == nil {
		return nil, fmt.Errorf("block %#x not found", hash)
	}
	return api.standardTraceBlockToFile(ctx, block, config)
}
541492
func (bf *BlockFilterer) foundInternal(scopedIndex waddrmgr.ScopedIndex) {
	if _, ok := bf.FoundInternal[scopedIndex.Scope]; !ok {
		bf.FoundInternal[scopedIndex.Scope] = make(map[uint32]struct{})
	}
	bf.FoundInternal[scopedIndex.Scope][scopedIndex.Index] = struct{}{}
}
503302
func GetInfo(path string) (info Info, err error) {
	s := unix.Statvfs_t{}
	if err = unix.Statvfs(path, &s); err != nil {
		return Info{}, err
	}
	reservedBlocks := uint64(s.Bfree) - uint64(s.Bavail)
	info = Info{
		Total:  uint64(s.Frsize) * (uint64(s.Blocks) - reservedBlocks),
		Free:   uint64(s.Frsize) * uint64(s.Bavail),
		Files:  uint64(s.Files),
		Ffree:  uint64(s.Ffree),
		FSType: getFSType(s.Fstr[:]),
	}
	return info, nil
}
1298116
func (a arping) blockUntilInterfaceExists(interfaceName string) {
	// TODO: Timeout waiting for net interface to exist?
	for !a.fs.FileExists(path.Join("/sys/class/net", interfaceName)) {
		time.Sleep(a.interfaceCheckDelay)
	}
}
544533
func blockWhileFileExists(path string, blocker fslock.Blocker) error {
	for {
		if _, err := os.Stat(path); os.IsNotExist(err) {
			break
		} else if err != nil {
			return errors.Annotate(err, "failed to stat %s", path).Err()
		}

		if err := blocker(); err != nil {
			return errors.New("timed out waiting for drain file to disappear")
		}
	}

	return nil
}
581349
func GetBlockHeaderVerbose(client BlockFetcher, idx int64) *dcrjson.GetBlockHeaderVerboseResult {
	blockhash, err := client.GetBlockHash(idx)
	if err != nil {
		log.Errorf("GetBlockHash(%d) failed: %v", idx, err)
		return nil
	}

	blockHeaderVerbose, err := client.GetBlockHeaderVerbose(blockhash)
	if err != nil {
		log.Errorf("GetBlockHeaderVerbose(%v) failed: %v", blockhash, err)
		return nil
	}

	return blockHeaderVerbose
}