Skip to content

Commit 6ee45dd

Browse files
committed
f_rename return value; add a test for rename dir inside itself
1 parent 1208549 commit 6ee45dd

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

extmod/vfs_fat.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,6 @@ STATIC mp_obj_t fat_vfs_rename(mp_obj_t vfs_in, mp_obj_t path_in, mp_obj_t path_
234234
}
235235
if (res == FR_OK) {
236236
return mp_const_none;
237-
} else if (res == FR_NO_PATH) {
238-
mp_raise_OSError(MP_EINVAL);
239237
} else {
240238
mp_raise_OSError_fresult(res);
241239
}

lib/oofatfs/ff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4828,7 +4828,7 @@ FRESULT f_rename (
48284828
strlen(path_new) > strlen(path_old) &&
48294829
path_new[strlen(path_old)] == '/' &&
48304830
strncmp(path_old, path_new, strlen(path_old)) == 0) {
4831-
return FR_NO_PATH;
4831+
return FR_INVALID_NAME;
48324832
}
48334833

48344834
res = find_volume(fs, FA_WRITE); /* Get logical drive of the old object */

tests/extmod/vfs_fat_fileio2.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ def ioctl(self, op, arg):
7070
except OSError as e:
7171
print(e.errno == uerrno.ENOENT)
7272

73+
try:
74+
vfs.rename("foo_dir", "foo_dir/inside_itself")
75+
except OSError as e:
76+
print(e.errno == uerrno.EINVAL)
77+
7378
# file in dir
7479
with open("foo_dir/file-in-dir.txt", "w+t") as f:
7580
f.write("data in file")

tests/extmod/vfs_fat_fileio2.py.exp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
True
22
True
33
True
4+
True
45
b'data in file'
56
True
67
[('sub_file.txt', 32768, 0, 11), ('file.txt', 32768, 0, 12)]

0 commit comments

Comments
 (0)