vfs: rename is a no-op when same path.
The old behavior was introduced by the commit f40c5e3211
(05 Nov 2009),
while the new behavior is specified by POSIX: https://pubs.opengroup.org/onlinepubs/9699919799/functions/rename.html
The new behavior permits to rename an empty folder to itself without error, which was
encountered here: https://github.com/ocaml/ocaml/blob/trunk/testsuite/tests/lib-sys/rename.ml#L85
Fixes #18851.
Change-Id: Ie4e2999b695b8bb3ee69b1e3ae487323d8315d5e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7527
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
parent
2812960782
commit
935c0c739c
@ -6584,10 +6584,12 @@ common_rename(int fd, char* path, int newFD, char* newPath, bool kernel)
|
||||
if (fromVnode->device != toVnode->device)
|
||||
return B_CROSS_DEVICE_LINK;
|
||||
|
||||
if (fromVnode.Get() == toVnode.Get() && !strcmp(fromName, toName))
|
||||
return B_OK;
|
||||
|
||||
if (fromName[0] == '\0' || toName[0] == '\0'
|
||||
|| !strcmp(fromName, ".") || !strcmp(fromName, "..")
|
||||
|| !strcmp(toName, ".") || !strcmp(toName, "..")
|
||||
|| (fromVnode.Get() == toVnode.Get() && !strcmp(fromName, toName))) {
|
||||
|| !strcmp(toName, ".") || !strcmp(toName, "..")) {
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user