* @brief 向磁盘写入扇区。 * * @param pdrv 物理驱动器编号。 * @param buff 源数据缓冲区指针。 * @param sector 起始逻辑块地址。 * @param count 要写入的扇区数。 * @return DRESULT 操作结果;RES_OK 表示成功。 */
| 82 | * @return DRESULT 操作结果;RES_OK 表示成功。 |
| 83 | */ |
| 84 | auto disk_write(BYTE pdrv, const BYTE* buff, LBA_t sector, UINT count) |
| 85 | -> DRESULT { |
| 86 | auto* dev = fatfs::FatFsFileSystem::GetBlockDevice(pdrv); |
| 87 | if (dev == nullptr) { |
| 88 | return RES_NOTRDY; |
| 89 | } |
| 90 | auto result = dev->WriteSectors(sector, static_cast<uint32_t>(count), buff); |
| 91 | if (!result) { |
| 92 | klog::Err("disk_write: pdrv={} sector={} count={} failed", |
| 93 | static_cast<unsigned>(pdrv), static_cast<uint64_t>(sector), |
| 94 | static_cast<unsigned>(count)); |
| 95 | return RES_ERROR; |
| 96 | } |
| 97 | return RES_OK; |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * @brief 执行磁盘 I/O 控制操作。 |
nothing calls this directly
no test coverage detected