public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* About making libc remove function POSIX-compliant
@ 2021-09-04 19:43 Théo Beaudet
  0 siblings, 0 replies; only message in thread
From: Théo Beaudet @ 2021-09-04 19:43 UTC (permalink / raw)
  To: newlib

Hi

This email is about the `int remove(const char *path)` function found
in `stdio.h` not being correct according to the POSIX standard and
thus breaking libstdc++ and libc++ (and possibly others, but I checked
these two) C++17's std::filesystem::remove (and by extension
std::filesystem::remove_all) function that rely on it, as it can only
remove files and not directories.

https://pubs.opengroup.org/onlinepubs/9699919799/functions/remove.html
states that
> If path does not name a directory, remove(path) shall be equivalent to unlink(path).
> If path names a directory, remove(path) shall be equivalent to rmdir(path).

Currently, the function `remove`/`_remove_r` found at `newlib / libc /
stdio / remove.c` calls `_unlink_r`, and only that.
I spent some time searching using the git web view on the
sourceware.org website, and while `_unlink_r` is provided by `newlib /
libc / reent / unlinkr.c` and depends on the libgloss library to be
fully implemented (from what I see), there is no _rmdir_r equivalent.

And so I wanted to ask this question:
If it is desirable to be POSIX-compliant, where should this
modification go? In newlib directly as a modification to `remove`,
requiring a new function everywhere (namely `rmdir`) ? Or in libgloss
as a change to the unlink implementation for platforms that want it?
Finally, who would want to make this change?

--
Thanks.
Théo B.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-04 19:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-04 19:43 About making libc remove function POSIX-compliant Théo Beaudet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).