fix: 恢复了FATFS设置卷标的功能
Liteos_a FATFS需要提供格式化时设置卷标的功能,该功能在当前系统中缺失。 现在恢复该功能,使用方法与原来一致。即使用set_label设置卷标文本后,调用format对设备格式化。 Close #I3Y5G8 Signed-off-by: Far <yesiyuan2@huawei.com>
This commit is contained in:
parent
43bdf2f1d3
commit
9515d53dcc
|
@ -1776,6 +1776,45 @@ static int fatfs_set_part_info(los_part *part)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static FRESULT fatfs_setlabel(los_part *part)
|
||||
{
|
||||
QWORD start_sector = 0;
|
||||
BYTE fmt = 0;
|
||||
FATFS fs;
|
||||
FRESULT result;
|
||||
|
||||
#ifdef LOSCFG_FS_FAT_VIRTUAL_PARTITION
|
||||
fs.vir_flag = FS_PARENT;
|
||||
fs.parent_fs = &fs;
|
||||
fs.vir_amount = DISK_ERROR;
|
||||
fs.vir_avail = FS_VIRDISABLE;
|
||||
#endif
|
||||
if (disk_ioctl(fs.pdrv, GET_SECTOR_SIZE, &(fs.ssize)) != RES_OK) {
|
||||
return -EIO;
|
||||
}
|
||||
fs.win = (BYTE *)ff_memalloc(fs.ssize);
|
||||
if (fs.win == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
result = find_fat_partition(&fs, part, &fmt, &start_sector);
|
||||
if (result != FR_OK) {
|
||||
free(fs.win);
|
||||
return -fatfs_2_vfs(result);
|
||||
}
|
||||
|
||||
result = init_fatobj(&fs, fmt, start_sector);
|
||||
if (result != FR_OK) {
|
||||
free(fs.win);
|
||||
return -fatfs_2_vfs(result);
|
||||
}
|
||||
|
||||
result = set_volumn_label(&fs, FatLabel);
|
||||
free(fs.win);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int fatfs_mkfs (struct Vnode *device, int sectors, int option)
|
||||
{
|
||||
BYTE *work_buff = NULL;
|
||||
|
@ -1811,19 +1850,22 @@ int fatfs_mkfs (struct Vnode *device, int sectors, int option)
|
|||
return -fatfs_2_vfs(result);
|
||||
}
|
||||
|
||||
result = fatfs_setlabel(part);
|
||||
if (result == FR_OK) {
|
||||
#ifdef LOSCFG_FS_FAT_CACHE
|
||||
ret = OsSdSync(part->disk_id);
|
||||
if (ret != 0) {
|
||||
return -EIO;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
ret = fatfs_set_part_info(part);
|
||||
if (ret != 0) {
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return -fatfs_2_vfs(result);
|
||||
}
|
||||
|
||||
int fatfs_mkdir(struct Vnode *parent, const char *name, mode_t mode, struct Vnode **vpp)
|
||||
|
|
|
@ -113,6 +113,8 @@ extern "C" {
|
|||
#define FMT_ANY 0x07
|
||||
#define FMT_ERASE 0x08
|
||||
|
||||
extern char FatLabel[LABEL_LEN];
|
||||
|
||||
int fatfs_2_vfs(int result);
|
||||
int fatfs_lookup(struct Vnode *parent, const char *name, int len, struct Vnode **vpp);
|
||||
int fatfs_create(struct Vnode *parent, const char *name, int mode, struct Vnode **vpp);
|
||||
|
|
Loading…
Reference in New Issue