当前位置: 首页>>代码示例>>C++>>正文


C++ Inode::InitCheck方法代码示例

本文整理汇总了C++中Inode::InitCheck方法的典型用法代码示例。如果您正苦于以下问题:C++ Inode::InitCheck方法的具体用法?C++ Inode::InitCheck怎么用?C++ Inode::InitCheck使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Inode的用法示例。


在下文中一共展示了Inode::InitCheck方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: new

static status_t
ext2_get_vnode(fs_volume* _volume, ino_t id, fs_vnode* _node, int* _type,
	uint32* _flags, bool reenter)
{
	Volume* volume = (Volume*)_volume->private_volume;

	if (id < 2 || id > volume->NumInodes()) {
		ERROR("invalid inode id %" B_PRIdINO " requested!\n", id);
		return B_BAD_VALUE;
	}

	Inode* inode = new(std::nothrow) Inode(volume, id);
	if (inode == NULL)
		return B_NO_MEMORY;

	status_t status = inode->InitCheck();
	if (status != B_OK)
		delete inode;

	if (status == B_OK) {
		_node->private_node = inode;
		_node->ops = &gExt2VnodeOps;
		*_type = inode->Mode();
		*_flags = 0;
	} else
		ERROR("get_vnode: InitCheck() failed. Error: %s\n", strerror(status));

	return status;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:29,代码来源:kernel_interface.cpp

示例2: new

static status_t
btrfs_get_vnode(fs_volume* _volume, ino_t id, fs_vnode* _node, int* _type,
	uint32* _flags, bool reenter)
{
	Volume* volume = (Volume*)_volume->private_volume;

	Inode* inode = new(std::nothrow) Inode(volume, id);
	if (inode == NULL)
		return B_NO_MEMORY;

	status_t status = inode->InitCheck();
	if (status != B_OK)
		delete inode;

	if (status == B_OK) {
		_node->private_node = inode;
		_node->ops = &gBtrfsVnodeOps;
		*_type = inode->Mode();
		*_flags = 0;
	} else
		ERROR("get_vnode: InitCheck() failed. Error: %s\n", strerror(status));

	return status;
}
开发者ID:DonCN,项目名称:haiku,代码行数:24,代码来源:kernel_interface.cpp

示例3: disk

int
main(int argc, char **argv)
{
	puts("Copyright (c) 2001-2010 pinc Software.");

	if (argc < 2 || !strcmp(argv[1], "--help")) {
		char *filename = strrchr(argv[0],'/');
		fprintf(stderr,"usage: %s [-srib] <device> [allocation_group start]\n"
				"\t-s\tdump superblock\n"
				"\t-r\tdump root node\n"
				"       the following options need the allocation_group/start "
					"parameters:\n"
				"\t-i\tdump inode\n"
				"\t-b\tdump b+tree\n"
				"\t-v\tvalidate b+tree\n"
				"\t-h\thexdump\n"
				"\t-o\tshow disk offsets\n",
				filename ? filename + 1 : argv[0]);
		return -1;
	}

	bool dumpRootNode = false;
	bool dumpInode = false;
	bool dumpSuperBlock = false;
	bool dumpBTree = false;
	bool validateBTree = false;
	bool dumpHex = false;
	bool showOffsets = false;

	while (*++argv) {
		char *arg = *argv;
		if (*arg == '-') {
			while (*++arg && isalpha(*arg)) {
				switch (*arg) {
					case 's':
						dumpSuperBlock = true;
						break;
					case 'r':
						dumpRootNode = true;
						break;
					case 'i':
						dumpInode = true;
						break;
					case 'b':
						dumpBTree = true;
						break;
					case 'v':
						validateBTree = true;
						break;
					case 'h':
						dumpHex = true;
						break;
					case 'o':
						showOffsets = true;
						break;
				}
			}
		} else
			break;
	}

	Disk disk(argv[0]);
	if (disk.InitCheck() < B_OK)
	{
		fprintf(stderr, "Could not open device or file: %s\n", strerror(disk.InitCheck()));
		return -1;
	}
	putchar('\n');

	if (!dumpSuperBlock && !dumpRootNode && !dumpInode && !dumpBTree
		&& !dumpHex) {
		printf("  Name:\t\t\t\"%s\"\n", disk.SuperBlock()->name);
		printf("    (disk is %s)\n\n",
			disk.ValidateSuperBlock() == B_OK ? "valid" : "invalid!!");
		printf("  Block Size:\t\t%" B_PRIu32 " bytes\n", disk.BlockSize());
		printf("  Number of Blocks:\t%12" B_PRIdOFF "\t%10g MB\n",
			disk.NumBlocks(), disk.NumBlocks() * disk.BlockSize()
				/ (1024.0*1024));
		if (disk.BlockBitmap() != NULL) {
			printf("  Used Blocks:\t\t%12" B_PRIdOFF "\t%10g MB\n",
				disk.BlockBitmap()->UsedBlocks(),
				disk.BlockBitmap()->UsedBlocks() * disk.BlockSize()
					/ (1024.0*1024));
			printf("  Free Blocks:\t\t%12" B_PRIdOFF "\t%10g MB\n",
				disk.BlockBitmap()->FreeBlocks(),
				disk.BlockBitmap()->FreeBlocks() * disk.BlockSize()
					/ (1024.0*1024));
		}
		int32 size
			= (disk.AllocationGroups() * disk.SuperBlock()->blocks_per_ag);
		printf("  Bitmap Size:\t\t%" B_PRIu32 " bytes (%" B_PRId32 " blocks, %"
			B_PRId32 " per allocation group)\n", disk.BlockSize() * size, size,
			disk.SuperBlock()->blocks_per_ag);
		printf("  Allocation Groups:\t%" B_PRIu32 "\n\n",
			disk.AllocationGroups());
		dump_block_run("  Log:\t\t\t", disk.Log());
		printf("    (was %s)\n\n", disk.SuperBlock()->flags == SUPER_BLOCK_CLEAN
			? "cleanly unmounted" : "not unmounted cleanly!");
		dump_block_run("  Root Directory:\t", disk.Root());
		putchar('\n');
//.........这里部分代码省略.........
开发者ID:AmirAbrams,项目名称:haiku,代码行数:101,代码来源:bfsinfo.cpp

示例4: if

void
checkFiles(Disk &disk,BPlusTree &tree,char *attribute)
{
	block_run *runs = (block_run *)malloc(gCount * sizeof(block_run));
	if (runs == NULL)
	{
		fprintf(stderr,"  Not enough memory!\n");
		return;
	}
	// copy hashtable to array
	block_run *run = NULL;
	int32 index = 0;
	gHashtable.Rewind();
	while (gHashtable.GetNextEntry((void **)&run) == B_OK)
	{
		runs[index++] = *run;
	}

	// sort array to speed up disk access
	qsort(runs,index,sizeof(block_run),(int (*)(const void *,const void *))compareBlockRuns);

	bool sizeIndex = !strcmp(attribute,"size");
	bool nameIndex = !strcmp(attribute,"name");
	bool modifiedIndex = !strcmp(attribute,"last_modified");

	char key[B_FILE_NAME_LENGTH];
	uint16 keyLength = 0;

	Inode *inode = NULL;

	for (int32 i = 0;i < index;i++)
	{
		if (i % 50 == 0)
			printf("  %7ld%s1A\n",i,gEscape);

		delete inode;
		inode = Inode::Factory(&disk,runs[i]);
		if (inode == NULL || inode->InitCheck() < B_OK)
		{
			fprintf(stderr,"  inode at (%ld, %d) is corrupt!\n",runs[i].allocation_group,runs[i].start);
			delete inode;
			continue;
		}

		// check indices not based on standard attributes
		if (sizeIndex)
		{
			if (inode->IsDirectory())
				continue;

			memcpy(key,&inode->InodeBuffer()->data.size,sizeof(off_t));
			keyLength = sizeof(off_t);
		}
		else if (nameIndex)
		{
			strcpy(key,inode->Name());
			keyLength = strlen(key);
		}
		else if (modifiedIndex)
		{
			if (inode->IsDirectory())
				continue;

			memcpy(key,&inode->InodeBuffer()->last_modified_time,sizeof(off_t));
			keyLength = sizeof(off_t);
		}
		else	// iterate through all attributes to find the right one (damn slow, sorry...)
		{
			inode->RewindAttributes();
			char name[B_FILE_NAME_LENGTH];
			uint32 type;
			void *data;
			size_t length;
			bool found = false;
			while (inode->GetNextAttribute(name,&type,&data,&length) == B_OK)
			{
				if (!strcmp(name,attribute))
				{
					strncpy(key,(char *)data,B_FILE_NAME_LENGTH - 1);
					key[B_FILE_NAME_LENGTH - 1] = '\0';
					keyLength = length > B_FILE_NAME_LENGTH ? B_FILE_NAME_LENGTH : length;
					found = true;
					break;
				}
			}
			if (!found)
				continue;
		}

		off_t value;
		if (tree.Find((uint8 *)key,keyLength,&value) < B_OK)
		{
			if (*inode->Name())
				fprintf(stderr,"  inode at (%ld, %d) name \"%s\" is not in index!\n",runs[i].allocation_group,runs[i].start,inode->Name());
			else
			{
				// inode is obviously deleted!
				block_run parent = inode->Parent();
				Directory *directory = (Directory *)Inode::Factory(&disk,parent);
				if (directory != NULL && directory->InitCheck() == B_OK)
//.........这里部分代码省略.........
开发者ID:AmirAbrams,项目名称:haiku,代码行数:101,代码来源:chkindex.cpp


注:本文中的Inode::InitCheck方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。