本文整理汇总了C++中Volume::BlocksPerGroup方法的典型用法代码示例。如果您正苦于以下问题:C++ Volume::BlocksPerGroup方法的具体用法?C++ Volume::BlocksPerGroup怎么用?C++ Volume::BlocksPerGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Volume
的用法示例。
在下文中一共展示了Volume::BlocksPerGroup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: transaction
static status_t
ext2_ioctl(fs_volume* _volume, fs_vnode* _node, void* _cookie, uint32 cmd,
void* buffer, size_t bufferLength)
{
TRACE("ioctl: %" B_PRIu32 "\n", cmd);
Volume* volume = (Volume*)_volume->private_volume;
switch (cmd) {
case 56742:
{
TRACE("ioctl: Test the block allocator\n");
// Test the block allocator
TRACE("ioctl: Creating transaction\n");
Transaction transaction(volume->GetJournal());
TRACE("ioctl: Creating cached block\n");
CachedBlock cached(volume);
uint32 blocksPerGroup = volume->BlocksPerGroup();
uint32 blockSize = volume->BlockSize();
uint32 firstBlock = volume->FirstDataBlock();
fsblock_t start = 0;
uint32 group = 0;
uint32 length;
TRACE("ioctl: blocks per group: %" B_PRIu32 ", block size: %"
B_PRIu32 ", first block: %" B_PRIu32 ", start: %" B_PRIu64
", group: %" B_PRIu32 "\n", blocksPerGroup,
blockSize, firstBlock, start, group);
while (volume->AllocateBlocks(transaction, 1, 2048, group, start,
length) == B_OK) {
TRACE("ioctl: Allocated blocks in group %" B_PRIu32 ": %"
B_PRIu64 "-%" B_PRIu64 "\n", group, start, start + length);
off_t blockNum = start + group * blocksPerGroup - firstBlock;
for (uint32 i = 0; i < length; ++i) {
uint8* block = cached.SetToWritable(transaction, blockNum);
memset(block, 0, blockSize);
blockNum++;
}
TRACE("ioctl: Blocks cleared\n");
transaction.Done();
transaction.Start(volume->GetJournal());
}
TRACE("ioctl: Done\n");
return B_OK;
}
}
return B_DEV_INVALID_IOCTL;
}