Skip to content

Commit 29a3bee

Browse files
committed
Fixed bug in 'os.rename()' function
1 parent eecb962 commit 29a3bee

File tree

8 files changed

+12
-6
lines changed

8 files changed

+12
-6
lines changed

firmware/MaixPy.bin

4 KB
Binary file not shown.

firmware/MaixPy.kfpkg

58 Bytes
Binary file not shown.

firmware/MaixPy_firmware.zip

588 Bytes
Binary file not shown.

firmware/MaixPy_sqlite.bin

0 Bytes
Binary file not shown.

firmware/MaixPy_sqlite.kfpkg

181 Bytes
Binary file not shown.

k210-freertos/mpy_support/standard_lib/uos/littleflash.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,10 +658,12 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(littlefs_vfs_remove_obj, littlefs_vfs_remove);
658658
STATIC mp_obj_t littlefs_vfs_rename(mp_obj_t vfs_in, mp_obj_t path_in, mp_obj_t path_out)
659659
{
660660
littlefs_user_mount_t *self = MP_OBJ_TO_PTR(vfs_in);
661+
char lnew_path[LITTLEFS_CFG_MAX_NAME_LEN] = {'\0'};
662+
char lold_path[LITTLEFS_CFG_MAX_NAME_LEN] = {'\0'};
661663
const char *old_path = mp_obj_str_get_str(path_in);
662664
const char *new_path = mp_obj_str_get_str(path_out);
663-
const char *lold_path = littlefs_local_path(old_path);
664-
const char *lnew_path = littlefs_local_path(new_path);
665+
strcpy(lold_path, littlefs_local_path(old_path));
666+
strcpy(lnew_path, littlefs_local_path(new_path));
665667
int res;
666668

667669
res = lfs_rename(&self->fs->lfs, lold_path, lnew_path);

k210-freertos/mpy_support/standard_lib/uos/vfs_sdcard.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,10 +435,12 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(sdcard_vfs_rmdir_obj, sdcard_vfs_rmdir);
435435
STATIC mp_obj_t sdcard_vfs_rename(mp_obj_t vfs_in, mp_obj_t path_in, mp_obj_t path_out)
436436
{
437437
mp_obj_sdcard_vfs_t *self = MP_OBJ_TO_PTR(vfs_in);
438+
static char local_newpath[FF_MAX_LFN] = {'\0'};
439+
static char local_oldpath[FF_MAX_LFN] = {'\0'};
438440
const char *old_path = mp_obj_str_get_str(path_in);
439441
const char *new_path = mp_obj_str_get_str(path_out);
440-
const char *local_oldpath = sdcard_local_path(old_path, self);
441-
const char *local_newpath = sdcard_local_path(new_path, self);
442+
strcpy(local_oldpath, sdcard_local_path(old_path, self));
443+
strcpy(local_newpath, sdcard_local_path(new_path, self));
442444

443445
FRESULT res = f_rename(local_oldpath, local_newpath);
444446
if (res == FR_EXIST) {

k210-freertos/mpy_support/standard_lib/uos/vfs_spiffs.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,10 +490,12 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(spiffs_vfs_remove_obj, spiffs_vfs_remove);
490490
STATIC mp_obj_t spiffs_vfs_rename(mp_obj_t vfs_in, mp_obj_t path_in, mp_obj_t path_out)
491491
{
492492
spiffs_user_mount_t *self = MP_OBJ_TO_PTR(vfs_in);
493+
char lnew_path[SPIFFS_OBJ_NAME_LEN] = {'\0'};
494+
char lold_path[SPIFFS_OBJ_NAME_LEN] = {'\0'};
493495
const char *old_path = mp_obj_str_get_str(path_in);
494496
const char *new_path = mp_obj_str_get_str(path_out);
495-
const char *lold_path = spiffs_local_path(old_path);
496-
const char *lnew_path = spiffs_local_path(new_path);
497+
strcpy(lold_path, spiffs_local_path(old_path));
498+
strcpy(lnew_path, spiffs_local_path(new_path));
497499
int res;
498500

499501
res = SPIFFS_rename(&(self->fs), lold_path, lnew_path);

0 commit comments

Comments
 (0)