@@ -2228,7 +2228,7 @@ FRESULT find_volume ( /* FR_OK(0): successful, !=0: any error occurred */
22282228 * rfs = fs ; /* Return pointer to the file system object */
22292229
22302230 if (fs -> fs_type ) { /* If the volume has been mounted */
2231- stat = disk_status (fs -> drv );
2231+ disk_ioctl (fs -> drv , IOCTL_STATUS , & stat );
22322232 if (!(stat & STA_NOINIT )) { /* and the physical drive is kept initialized */
22332233 if (!_FS_READONLY && wmode && (stat & STA_PROTECT )) /* Check write protection if needed */
22342234 return FR_WRITE_PROTECTED ;
@@ -2240,7 +2240,7 @@ FRESULT find_volume ( /* FR_OK(0): successful, !=0: any error occurred */
22402240 /* Following code attempts to mount the volume. (analyze BPB and initialize the fs object) */
22412241
22422242 fs -> fs_type = 0 ; /* Clear the file system object */
2243- stat = disk_initialize (fs -> drv ); /* Initialize the physical drive */
2243+ disk_ioctl (fs -> drv , IOCTL_INIT , & stat ); /* Initialize the physical drive */
22442244 if (stat & STA_NOINIT ) /* Check if the initialization succeeded */
22452245 return FR_NOT_READY ; /* Failed to initialize due to no medium or hard error */
22462246 if (!_FS_READONLY && wmode && (stat & STA_PROTECT )) /* Check disk write protection if needed */
@@ -2372,10 +2372,15 @@ FRESULT validate ( /* FR_OK(0): The object is valid, !=0: Invalid */
23722372 void * obj /* Pointer to the object FIL/DIR to check validity */
23732373)
23742374{
2375+ DSTATUS stat ;
23752376 FIL * fil = (FIL * )obj ; /* Assuming offset of .fs and .id in the FIL/DIR structure is identical */
23762377
23772378
2378- if (!fil || !fil -> fs || !fil -> fs -> fs_type || fil -> fs -> id != fil -> id || (disk_status (fil -> fs -> drv ) & STA_NOINIT ))
2379+ if (!fil || !fil -> fs || !fil -> fs -> fs_type || fil -> fs -> id != fil -> id )
2380+ return FR_INVALID_OBJECT ;
2381+
2382+ disk_ioctl (fil -> fs -> drv , IOCTL_STATUS , & stat );
2383+ if (stat & STA_NOINIT )
23792384 return FR_INVALID_OBJECT ;
23802385
23812386 ENTER_FF (fil -> fs ); /* Lock file system */
@@ -4091,7 +4096,7 @@ FRESULT f_mkfs (
40914096 part = LD2PT (vol ); /* Partition (0:auto detect, 1-4:get from partition table)*/
40924097
40934098 /* Get disk statics */
4094- stat = disk_initialize (pdrv );
4099+ disk_ioctl (pdrv , IOCTL_INIT , & stat );
40954100 if (stat & STA_NOINIT ) return FR_NOT_READY ;
40964101 if (stat & STA_PROTECT ) return FR_WRITE_PROTECTED ;
40974102#if _MAX_SS != _MIN_SS /* Get disk sector size */
@@ -4317,7 +4322,7 @@ FRESULT f_fdisk (
43174322 DWORD sz_disk , sz_part , s_part ;
43184323
43194324
4320- stat = disk_initialize (pdrv );
4325+ disk_ioctl (pdrv , IOCTL_INIT , & stat );
43214326 if (stat & STA_NOINIT ) return FR_NOT_READY ;
43224327 if (stat & STA_PROTECT ) return FR_WRITE_PROTECTED ;
43234328 if (disk_ioctl (pdrv , GET_SECTOR_COUNT , & sz_disk )) return FR_DISK_ERR ;
0 commit comments