login 31b7b49d8c
new: FAT32删除文件的功能 (#73)
* new: 将sys_rmdir更改为sys_unlink,.且完成删除文件操作的vfs部分

* new: fat32删除文件

*bugfix: 解决创建文件时的bug
2022-11-02 15:42:44 +08:00

28 lines
845 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include <common/sys/types.h>
/**
* @brief 根据簇号计算该簇的起始扇区号LBA地址
*
* @param first_data_sector 数据区的其实扇区号
* @param sec_per_clus 每个簇的扇区数量
* @param cluster 簇号
* @return uint32_t LBA地址
*/
static inline uint32_t __fat32_calculate_LBA(uint32_t first_data_sector, uint32_t sec_per_clus, uint32_t cluster)
{
return first_data_sector + (cluster - 2) * sec_per_clus;
}
/**
* @brief 计算LBA地址所在的簇
*
* @param first_data_sector 数据区的其实扇区号
* @param sec_per_clus 每个簇的扇区数量
* @param LBA LBA地址
* @return uint32_t 所在的簇
*/
static inline uint32_t __fat32_LBA_to_cluster(uint32_t first_data_sector, uint32_t sec_per_clus, uint32_t LBA)
{
return ((LBA - first_data_sector) / sec_per_clus) + 2;
}