fat_fs: Add support for variable sector size
Add support for variable sector sizes by exposing _MAX_SS as CONFIG_FS_FATFS_MAX_SS to Kconfig and adding the GET_SECTOR_SIZE IOCTL. Signed-off-by: Markus Fuchs <markus.fuchs@de.sauter-bc.com>
This commit is contained in:
parent
1d1fcc725a
commit
237778d3f1
1
README
1
README
|
@ -23,3 +23,4 @@ _CODE_PAGE as CONFIG_FS_FATFS_CODEPAGE
|
|||
_FS_READONLY as CONFIG_FS_FATFS_READ_ONLY
|
||||
_USE_MKFS as CONFIG_FS_FATFS_MKFS
|
||||
_VOLUMES as CONFIG_FS_FATFS_VOLUMES
|
||||
_MAX_SS as CONFIG_FS_FATFS_MAX_SS
|
||||
|
|
|
@ -201,7 +201,11 @@
|
|||
|
||||
|
||||
#define _MIN_SS 512
|
||||
#if defined(CONFIG_FS_FATFS_MAX_SS)
|
||||
#define _MAX_SS CONFIG_FS_FATFS_MAX_SS
|
||||
#else
|
||||
#define _MAX_SS 512
|
||||
#endif /* defined(CONFIG_FS_FATFS_MAX_SS) */
|
||||
/* These options configure the range of sector size to be supported. (512, 1024,
|
||||
/ 2048 or 4096) Always set both 512 for most systems, all type of memory cards and
|
||||
/ harddisk. But a larger value may be required for on-board flash memory and some
|
||||
|
|
19
zfs_diskio.c
19
zfs_diskio.c
|
@ -97,7 +97,8 @@ DRESULT disk_write(BYTE pdrv, const BYTE *buff, DWORD sector, UINT count)
|
|||
|
||||
DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void *buff)
|
||||
{
|
||||
int ret = RES_OK;
|
||||
int ret = RES_OK;
|
||||
uint32_t sector_size = 0;
|
||||
|
||||
__ASSERT(pdrv < ARRAY_SIZE(pdrv_str), "pdrv out-of-range\n");
|
||||
|
||||
|
@ -113,7 +114,21 @@ DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void *buff)
|
|||
if (disk_access_ioctl(pdrv_str[pdrv],
|
||||
DISK_IOCTL_GET_SECTOR_COUNT, buff) != 0) {
|
||||
ret = RES_ERROR;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GET_SECTOR_SIZE:
|
||||
/* Zephyr's DISK_IOCTL_GET_SECTOR_SIZE returns sector size as a
|
||||
* 32-bit number while FatFS's GET_SECTOR_SIZE is supposed to
|
||||
* return a 16-bit number.
|
||||
*/
|
||||
if ((disk_access_ioctl(pdrv_str[pdrv],
|
||||
DISK_IOCTL_GET_SECTOR_SIZE, §or_size) == 0) &&
|
||||
(sector_size == (uint16_t)sector_size)) {
|
||||
*(uint16_t *)buff = (uint16_t)sector_size;
|
||||
} else {
|
||||
ret = RES_ERROR;
|
||||
}
|
||||
break;
|
||||
|
||||
case GET_BLOCK_SIZE:
|
||||
|
|
Loading…
Reference in New Issue