Raw Device I/O
Opened devices can be accessed directly at the sector level, completely bypassing the file system. Such read and write operations on raw devices are accomplished by using FSDev_Rd()
and FSDev_Wr()
to respectively read and write one or more sector at a time. However, doing so may have the unwanted side-effect of corrupting an existing file system on the device and as such, should be done carefully.
Applications wishing to use both the high level file system API of µC/FS and raw device access concurrently may acquire a global lock to a device with FSDev_AccessLock()
. While the application has ownership of a device’s access lock all higher level operations such as the FSFile_
and FSEntry_
type of functions will wait for the lock to be released. The lock can then be released using FSDev_AccessUnlock()
to give back access to the device.
When raw device operations are used to make changes on opened files and volumes it is generally required to invalidate them to prevent µC/FS from performing inconsistent operations on the file system. A call to FSDev_Invalidate() will make every operations on files and volumes opened on a device fail with an FS_ERR_DEV_CHNGD
error. Affected files and volumes will then have to be closed and re-opened to continue, similarly to a removable media change.