[DragonFlyBSD - Bug #3282] unexpected errno value from fopen()
jpipkin
bugtracker-admin at leaf.dragonflybsd.org
Wed Jun 24 15:48:58 PDT 2026
Issue #3282 has been updated by jpipkin.
File sys.kern.vfs_nlookup.c.diff added
Attached is a patch that fixes this. The interesting part is at:
--
@@ -921,7 +921,7 @@ nlookup(struct nlookupdata *nd)
--
Note that a comment before the relevant section of code says:
--
Also handle invalid '.' or '..' components terminating a path
for a create/rename/delete. The standard requires this and pax
pretty stupidly depends on it.
--
It's not clear exactly what pax depends on - just an error or EEXIST specifically - but it appears to behave normally with this change as far as I can tell. That said, I only tested a few simple cases with pax. Perhaps someone knows more about this.
Note also that attempting to open(2)/fopen(3) directories other than "." already produce the expected EISDIR. I believe they are covered by the following code from vn_open() in sys/kern/vfs_vnops.c:
--
280 if ((fmode & O_CREAT) == 0) {
281 if (fmode & (FWRITE | O_TRUNC)) {
282 if (vp->v_type == VDIR) {
283 error = EISDIR;
284 goto bad;
285 }
--
Perhaps someone with commit access can take a look at this.
----------------------------------------
Bug #3282: unexpected errno value from fopen()
http://bugs.dragonflybsd.org/issues/3282#change-14666
* Author: bhaible
* Status: New
* Priority: Normal
* Category: Kernel
* Target version: 6.4
* Start date: 2021-06-14
----------------------------------------
fopen(".", "w") fails with errno = EEXIST.
Per POSIX https://pubs.opengroup.org/onlinepubs/9699919799/functions/fopen.html
one would expect one of EISDIR, EINVAL, EACCES.
How to reproduce: Run this program.
<pre>
#include <errno.h>
#include <stdio.h>
int main ()
{
FILE *fp = fopen (".", "w");
if (fp == NULL)
{
perror ("fopen");
}
}
</pre>
---Files--------------------------------
sys.kern.vfs_nlookup.c.diff (6.7 KB)
--
You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://bugs.dragonflybsd.org/my/account
More information about the Bugs
mailing list