← index #2929Issue #2598
Off-topic · high · value 1.472
QUERY · ISSUE

VFS FatFS: mkdir with trailing slash fails when it should succeed

openby dpgeorgeopened 2017-03-03updated 2017-03-08

On CPython and unix uPy, os.mkdir('directory/') makes the requested directory. But on bare metal ports using VFS with FatFS it fails with ENOENT because of the trailing slash. I'd say this should be fixed. (And in fact CPy and unix uPy allow any number of trailing slashes).

CANDIDATE · ISSUE

FatFs's os.rename() is not POSIX compliant

closedby pfalconopened 2016-11-05updated 2022-08-08

Trying to do os.rename("old", "new") with FatFs fails if "new" already exists with OSError: [Errno 17] EEXIST. This is not POSIX compliant:

If newpath already exists it will be atomically replaced (subject to a few conditions; see ERRORS below), so that there is no point at which another process attempting to access newpath will find it missing.

(from man 2 rename)

https://docs.python.org/3/library/os.html#os.rename says on this:

Rename the file or directory src to dst. On Unix, if dst exists and is a file, it will be replaced silently if the user has permission. On Windows, if dst already exists, OSError will be raised even if it is a file.

So, we could leave it raising OSError, but that would be emulating Windows, and we should emulate POSIX apparently.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied