fatfs/src/ff.c
static FRESULT sync_fs (	/* Returns FR_OK or FR_DISK_ERR */
	FATFS* fs		/* Filesystem object */
)
{
	FRESULT res;


	res = sync_window(fs);
	if (res == FR_OK) {
		if (fs->fs_type == FS_FAT32 && fs->fsi_flag == 1) {	/* FAT32: Update FSInfo sector if needed */
			/* Create FSInfo structure */
			mem_set(fs->win, 0, sizeof fs->win);
			st_word(fs->win + BS_55AA, 0xAA55);
			st_dword(fs->win + FSI_LeadSig, 0x41615252);
			st_dword(fs->win + FSI_StrucSig, 0x61417272);
			st_dword(fs->win + FSI_Free_Count, fs->free_clst);
			st_dword(fs->win + FSI_Nxt_Free, fs->last_clst);
			/* Write it into the FSInfo sector */
			fs->winsect = fs->volbase + 1;
			disk_write(fs->pdrv, fs->win, fs->winsect, 1);
			fs->fsi_flag = 0;
		}
		/* Make sure that no pending write process in the lower layer */
		if (disk_ioctl(fs->pdrv, CTRL_SYNC, 0) != RES_OK) res = FR_DISK_ERR;
	}

	return res;
}
/*-----------------------------------------------------------------------*/
/* Synchronize filesystem and data on the storage                        */
/*-----------------------------------------------------------------------*/
Synchronize filesystem and data on the storage
Synchronize filesystem and data on the storage
static FRESULT sync_fs (	
	FATFS* fs		
)
{
	FRESULT res;
	res = sync_window(fs);
	if (res == FR_OK) {
		if (fs->fs_type == FS_FAT32 && fs->fsi_flag == 1) {	
			mem_set(fs->win, 0, sizeof fs->win);
			st_word(fs->win + BS_55AA, 0xAA55);
			st_dword(fs->win + FSI_LeadSig, 0x41615252);
			st_dword(fs->win + FSI_StrucSig, 0x61417272);
			st_dword(fs->win + FSI_Free_Count, fs->free_clst);
			st_dword(fs->win + FSI_Nxt_Free, fs->last_clst);
			fs->winsect = fs->volbase + 1;
			disk_write(fs->pdrv, fs->win, fs->winsect, 1);
			fs->fsi_flag = 0;
		}
		if (disk_ioctl(fs->pdrv, CTRL_SYNC, 0) != RES_OK) res = FR_DISK_ERR;
	}
	return res;
}
static FRESULT sync_fs ( FATFS * fs ) { FRESULT res ; res = sync_window ( fs ) ; if ( res == FR_OK ) { if ( fs -> fs_type == FS_FAT32 && fs -> fsi_flag == 1 ) { mem_set ( fs -> win , 0 , sizeof fs -> win ) ; st_word ( fs -> win + BS_55AA , 0xAA55 ) ; st_dword ( fs -> win + FSI_LeadSig , 0x41615252 ) ; st_dword ( fs -> win + FSI_StrucSig , 0x61417272 ) ; st_dword ( fs -> win + FSI_Free_Count , fs -> free_clst ) ; st_dword ( fs -> win + FSI_Nxt_Free , fs -> last_clst ) ; fs -> winsect = fs -> volbase + 1 ; disk_write ( fs -> pdrv , fs -> win , fs -> winsect , 1 ) ; fs -> fsi_flag = 0 ; } if ( disk_ioctl ( fs -> pdrv , CTRL_SYNC , 0 ) != RES_OK ) res = FR_DISK_ERR ; } return res ; }
Synchronize filesystem and data on the storage
Synchronize filesystem and data on the storage
/* Returns FR_OK or FR_DISK_ERR */ /* Filesystem object */ /* FAT32: Update FSInfo sector if needed */ /* Create FSInfo structure */ /* Write it into the FSInfo sector */ /* Make sure that no pending write process in the lower layer */