本文整理汇总了Golang中file-structures/block/file2.BlockDevice.BlockSize方法的典型用法代码示例。如果您正苦于以下问题:Golang BlockDevice.BlockSize方法的具体用法?Golang BlockDevice.BlockSize怎么用?Golang BlockDevice.BlockSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类file-structures/block/file2.BlockDevice
的用法示例。
在下文中一共展示了BlockDevice.BlockSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: new_list_block
func new_list_block(file file.BlockDevice, new_list bool) (self *list_block, err error) {
key, err := file.Allocate()
if err != nil {
return nil, err
}
bytes := make(bs.ByteSlice, file.BlockSize())
data := bytes[LIST_HEADER_LEN:]
var header *list_header
if new_list {
header = &list_header{
next: 0,
head: key,
tail: key,
insert_point: key + LIST_HEADER_LEN,
block_count: 1,
list_length: 0,
}
} else {
header = &list_header{next: 0}
}
self = &list_block{
file: file,
key: key,
bytes: bytes,
data: data,
header: header,
}
return self, nil
}
示例2: allocBlock
func allocBlock(file file.BlockDevice) (blk *block, err error) {
key, err := file.Allocate()
if err != nil {
return nil, err
}
size := file.BlockSize()
bytes := make(bs.ByteSlice, size)
return load_block(key, bytes), nil
}
示例3: allocBlock
func allocBlock(file file.BlockDevice) (blk *block, err error) {
key, err := file.Allocate()
if err != nil {
return nil, err
}
size := file.BlockSize()
offset := size - METADATASIZE
bytes := make(bs.ByteSlice, size)
blk = &block{
key: key,
block: bytes,
data: bytes[:offset],
metadata: bytes[offset:],
}
// fmt.Println("allocated", key)
return blk, nil
}
示例4: datasize
func datasize(file file.BlockDevice) int64 {
return int64(file.BlockSize()) - METADATASIZE
}