diff --git a/demos/STM32/RT-VFS-FATFS/main.c b/demos/STM32/RT-VFS-FATFS/main.c index 0a53780e1..44808d8b1 100644 --- a/demos/STM32/RT-VFS-FATFS/main.c +++ b/demos/STM32/RT-VFS-FATFS/main.c @@ -57,6 +57,7 @@ static msg_t scan_nodes(BaseSequentialStream *chp, char *path) { vfs_directory_node_t *dirp; static vfs_node_info_t ni; + chprintf(chp, "%s\r\n", path); res = vfsOpenDirectory(path, &dirp); if (res == VFS_RET_SUCCESS) { size_t i = strlen(path); @@ -70,15 +71,15 @@ static msg_t scan_nodes(BaseSequentialStream *chp, char *path) { fn = ni.name; if (ni.attr & VFS_NODE_ATTR_ISDIR) { - *(path + i) = '/'; - strcpy(path + i + 1U, fn); + strcat(path + i, fn); + strcat(path + i, "/"); res = scan_nodes(chp, path); if (res != VFS_RET_SUCCESS) { break; } } else { - chprintf(chp, "%s/%s\r\n", path, fn); + chprintf(chp, "%s%s\r\n", path, fn); } } diff --git a/os/vfs/src/vfssystem.c b/os/vfs/src/vfssystem.c index 8e15f5a8d..14a09d7f0 100644 --- a/os/vfs/src/vfssystem.c +++ b/os/vfs/src/vfssystem.c @@ -234,7 +234,8 @@ static msg_t node_dir_next(void *instance, vfs_node_info_t *nip) { if (rdnp->index < VFS_CFG_MAX_DRIVERS) { nip->attr = VFS_NODE_ATTR_ISDIR | VFS_NODE_ATTR_READONLY; nip->size = (vfs_offset_t)0; - strcpy(nip->name, rdnp->driver->rootname); + strcpy(nip->name, + ((vfs_root_driver_t *)rdnp->driver)->drivers[rdnp->index]->rootname); rdnp->index++; @@ -256,8 +257,8 @@ static msg_t node_dir_next(void *instance, vfs_node_info_t *nip) { */ void vfsInit(void) { - vfs.vmt = &root_driver_vmt; - + vfs.vmt = &root_driver_vmt; + vfs.rootname = ""; vfs.next_driver = &vfs.drivers[0]; chPoolObjectInit(&vfs.dir_nodes_pool,