libc: handle O_CREAT|O_NOFOLLOW in open correctly

We return ELOOP if the file already exists on
open(...,O_CREAT|O_NOFOLLOW).

Fixes #2458
This commit is contained in:
Alexander Senier 2017-07-03 00:31:24 +02:00 committed by Christian Helmuth
parent 51dcf5f7f8
commit 87c19cb11a

View File

@ -196,7 +196,12 @@ Libc::File_descriptor *Libc::Vfs_plugin::open(char const *path, int flags,
case Result::OPEN_ERR_EXISTS:
/* file has been created by someone else in the meantime */
break;
if (flags & O_NOFOLLOW) {
errno = ELOOP;
return 0;
}
errno = EEXIST;
return 0;
case Result::OPEN_ERR_NO_PERM: errno = EPERM; return 0;
case Result::OPEN_ERR_UNACCESSIBLE: errno = ENOENT; return 0;