示例#1
0
文件: block.c 项目: AKuHAK2/ps2sdk
// Sets 'blockpos' to point to the next block segment for the inode (and moves onto the
// next block descriptor inode if necessary)
int pfsBlockSeekNextSegment(pfs_cache_t *clink, pfs_blockpos_t *blockpos)
{
	pfs_cache_t *nextSegment;
	int result=0;

	if (blockpos->byte_offset)
	{
		PFS_PRINTF(PFS_DRV_NAME": Panic: This is a bug!\n");
		return -1;
	}

	// If we're at the end of the block descriptor array for the current
	// inode, then move onto the next inode
	if (pfsFixIndex(blockpos->block_segment+1)==0)
	{
		if ((nextSegment=pfsBlockGetNextSegment(pfsCacheUsedAdd(blockpos->inode), &result)) == NULL)
			return result;
		pfsCacheFree(blockpos->inode);
		blockpos->inode=nextSegment;
		if (clink->u.inode->number_data-1 == ++blockpos->block_segment)
			return -EINVAL;
	}

	blockpos->block_offset=0;
	blockpos->block_segment++;
	return result;
}
示例#2
0
文件: inode.c 项目: ps2dev/ps2sdk
int pfsInodeSync(pfs_blockpos_t *blockpos, u64 size, u32 used_segments)
{
	int result=0;
	u32 i;
	u16 count;

	for(i=pfsBlockSyncPos(blockpos, size); i; )
	{
		count=blockpos->inode->u.inode->data[pfsFixIndex(blockpos->block_segment)].count;

		i+=blockpos->block_offset;

		if (i < count){
			blockpos->block_offset=i;
			break;
		}

		i-=count;

		if (blockpos->block_segment + 1 == used_segments)
		{
			blockpos->block_offset=count;
			if (i || blockpos->byte_offset){
				PFS_PRINTF(PFS_DRV_NAME": panic: fp exceeds file.\n");
				return -EINVAL;
			}
		}else{
			blockpos->block_offset=0;
			blockpos->block_segment++;
		}

		if (pfsFixIndex(blockpos->block_segment))
			continue;

		if ((blockpos->inode = pfsBlockGetNextSegment(blockpos->inode, &result)) == 0)
			break;

		i++;
	}

	return result;
}