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; }