fatfs/src/ff.c
static FRESULT validate (	/* Returns FR_OK or FR_INVALID_OBJECT */
	FFOBJID* obj,			/* Pointer to the FFOBJID, the 1st member in the FIL/DIR object, to check validity */
	FATFS** rfs				/* Pointer to pointer to the owner filesystem object to return */
)
{
	FRESULT res = FR_INVALID_OBJECT;


	if (obj && obj->fs && obj->fs->fs_type && obj->id == obj->fs->id) {	/* Test if the object is valid */
#if FF_FS_REENTRANT
		if (lock_fs(obj->fs)) {	/* Obtain the filesystem object */
			if (!(disk_status(obj->fs->pdrv) & STA_NOINIT)) { /* Test if the phsical drive is kept initialized */
				res = FR_OK;
			} else {
				unlock_fs(obj->fs, FR_OK);
			}
		} else {
			res = FR_TIMEOUT;
		}
#else
		if (!(disk_status(obj->fs->pdrv) & STA_NOINIT)) { /* Test if the phsical drive is kept initialized */
			res = FR_OK;
		}
#endif
	}
	*rfs = (res == FR_OK) ? obj->fs : 0;	/* Corresponding filesystem object */
	return res;
}
/*-----------------------------------------------------------------------*/
/* Check if the file/directory object is valid or not                    */
/*-----------------------------------------------------------------------*/
Check if the file/directory object is valid or not
Check if the file / directory object is valid or not
static FRESULT validate (	
	FFOBJID* obj,			
	FATFS** rfs				
)
{
	FRESULT res = FR_INVALID_OBJECT;
	if (obj && obj->fs && obj->fs->fs_type && obj->id == obj->fs->id) {	
#if FF_FS_REENTRANT
		if (lock_fs(obj->fs)) {	
			if (!(disk_status(obj->fs->pdrv) & STA_NOINIT)) { 
				res = FR_OK;
			} else {
				unlock_fs(obj->fs, FR_OK);
			}
		} else {
			res = FR_TIMEOUT;
		}
#else
		if (!(disk_status(obj->fs->pdrv) & STA_NOINIT)) { 
			res = FR_OK;
		}
#endif
	}
	*rfs = (res == FR_OK) ? obj->fs : 0;	
	return res;
}
static FRESULT validate ( FFOBJID * obj , FATFS * * rfs ) { FRESULT res = FR_INVALID_OBJECT ; if ( obj && obj -> fs && obj -> fs -> fs_type && obj -> id == obj -> fs -> id ) { #if FF_FS_REENTRANT if ( lock_fs ( obj -> fs ) ) { if ( ! ( disk_status ( obj -> fs -> pdrv ) & STA_NOINIT ) ) { res = FR_OK ; } else { unlock_fs ( obj -> fs , FR_OK ) ; } } else { res = FR_TIMEOUT ; } #else if ( ! ( disk_status ( obj -> fs -> pdrv ) & STA_NOINIT ) ) { res = FR_OK ; } #endif } * rfs = ( res == FR_OK ) ? obj -> fs : 0 ; return res ; }
Check if the file/directory object is valid or not
Check if the file / directory object is valid or not
/* Returns FR_OK or FR_INVALID_OBJECT */ /* Pointer to the FFOBJID, the 1st member in the FIL/DIR object, to check validity */ /* Pointer to pointer to the owner filesystem object to return */ /* Test if the object is valid */ /* Obtain the filesystem object */ /* Test if the phsical drive is kept initialized */ /* Test if the phsical drive is kept initialized */ /* Corresponding filesystem object */