Subject: Re: What should stat("",&fs) return?
To: John F. Woods <jfw@funhouse.COM>
From: Chris G Demetriou <Chris_G_Demetriou@UX2.SP.CS.CMU.EDU>
List: current-users
Date: 05/30/1996 12:21:11
> As to what it *should* return: if there are any standards documents to which
> NetBSD claims conformance that specify ENOENT, then that's what it should
> return. If the standards *don't* specify, then I personally prefer the
> approach currently taken.
So, I actually came up with patch to fix this, and int's included
below. I've been running with it now for ... oh, a few minutes, and
things seem to be working. If things keep working normally, i'll
submit it as a PR.
Unfortunately (or, fortunately, depending on the way you look at it),
this change fixes all code that invokes pathname resolution at the
same time... There's no other nice way to do it, nor is it clear that
it _should_ be done syscall by syscall... but it's a lot of code that
could be broken in one swell foop.
chris
===================================================================
Index: vfs_lookup.c
===================================================================
RCS file: /a/cvsroot/src/sys/kern/vfs_lookup.c,v
retrieving revision 1.17
diff -c -r1.17 vfs_lookup.c
*** vfs_lookup.c 1996/02/09 19:00:59 1.17
--- vfs_lookup.c 1996/05/30 16:19:15
***************
*** 111,117 ****
else
error = copyinstr(ndp->ni_dirp, cnp->cn_pnbuf,
MAXPATHLEN, &ndp->ni_pathlen);
! if (error) {
free(cnp->cn_pnbuf, M_NAMEI);
ndp->ni_vp = NULL;
return (error);
--- 111,124 ----
else
error = copyinstr(ndp->ni_dirp, cnp->cn_pnbuf,
MAXPATHLEN, &ndp->ni_pathlen);
! /*
! * If there was an error copying the file name, time to give up.
! * Also, POSIX specifies that empty pathnames are invalid and
! * attempts to use them should yield ENOENT.
! */
! if (error || ndp->ni_pathlen == 1) {
! if (!error && ndp->ni_pathlen == 1)
! error = ENOENT;
free(cnp->cn_pnbuf, M_NAMEI);
ndp->ni_vp = NULL;
return (error);