示例#1
0
文件: resize.c 项目: Excito/parted
/* when converting FAT32 -> FAT16
 * fat_duplicate clusters() duplicated the root directory unnecessarily.
 * Let's free it.
 *
 * This must be called AFTER fat_construct_new_fat().  (otherwise, our
 * changes just get overwritten)
 */
static int
free_root_dir (FatOpContext* ctx)
{
	FatSpecific*		old_fs_info = FAT_SPECIFIC (ctx->old_fs);
	FatSpecific*		new_fs_info = FAT_SPECIFIC (ctx->new_fs);
	FatCluster		old_cluster;
	FatFragment		i;

	PED_ASSERT (old_fs_info->fat_type == FAT_TYPE_FAT32);
	PED_ASSERT (new_fs_info->fat_type == FAT_TYPE_FAT16);

	for (old_cluster = old_fs_info->root_cluster;
	     !fat_table_is_eof (old_fs_info->fat, old_cluster);
	     old_cluster = fat_table_get (old_fs_info->fat, old_cluster)) {
		FatFragment old_frag;
		old_frag = fat_cluster_to_frag (ctx->old_fs, old_cluster);
		for (i = 0; i < new_fs_info->cluster_frags; i++) {
			FatFragment new_frag;
			FatCluster new_clst;
			new_frag = fat_op_context_map_fragment (ctx,
								old_frag + i);
			new_clst = fat_frag_to_cluster (ctx->old_fs, new_frag);
			if (!fat_table_set_avail (new_fs_info->fat, new_clst))
				return 0;
		}
	}

	return 1;
}
示例#2
0
/* returns 1 if there are no more directory entries in the directory being
 * traversed, 0 otherwise.
 */
static int
is_last_buffer (FatTraverseInfo* trav_info) {
	FatSpecific*	fs_info = FAT_SPECIFIC (trav_info->fs);

	if (trav_info->is_legacy_root_dir)
		return 1;
	else
		return fat_table_is_eof (fs_info->fat, trav_info->next_buffer);
}
示例#3
0
int
fat_dir_entry_has_first_cluster (FatDirEntry* dir_entry, PedFileSystem* fs)
{
	FatSpecific*	fs_info = FAT_SPECIFIC (fs);
	FatCluster	first_cluster;

	if (!fat_dir_entry_is_file (dir_entry)
		&& !fat_dir_entry_is_directory (dir_entry))
		return 0;

	first_cluster = fat_dir_entry_get_first_cluster (dir_entry, fs);
	if (first_cluster == 0
		|| fat_table_is_eof (fs_info->fat, first_cluster))
		return 0;

	return 1;
}
示例#4
0
文件: resize.c 项目: Excito/parted
static FatFragment
_get_next_old_frag (FatOpContext* ctx, FatFragment frag)
{
	FatSpecific*	old_fs_info = FAT_SPECIFIC (ctx->old_fs);
	FatCluster	cluster;
	FatCluster	next_cluster;

	if ((frag + 1) % old_fs_info->cluster_frags != 0) {
		if (fat_is_fragment_active (ctx->old_fs, frag + 1))
			return frag + 1;
		else
			return -1;
	} else {
		cluster = fat_frag_to_cluster (ctx->old_fs, frag);
		next_cluster = fat_table_get (old_fs_info->fat, cluster);

		if (fat_table_is_eof (old_fs_info->fat, next_cluster))
			return -1;
		else
			return fat_cluster_to_frag (ctx->old_fs, next_cluster);
	}
}