From owner-freebsd-hackers Fri Apr 18 14:01:49 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id OAA03080 for hackers-outgoing; Fri, 18 Apr 1997 14:01:49 -0700 (PDT) Received: from phaeton.artisoft.com (phaeton.Artisoft.COM [198.17.250.50]) by freefall.freebsd.org (8.8.5/8.8.5) with SMTP id OAA03074 for ; Fri, 18 Apr 1997 14:01:45 -0700 (PDT) Received: (from terry@localhost) by phaeton.artisoft.com (8.6.11/8.6.9) id OAA02785; Fri, 18 Apr 1997 14:01:03 -0700 From: Terry Lambert Message-Id: <199704182101.OAA02785@phaeton.artisoft.com> Subject: Re: O_EXCL To: jmacd@CS.Berkeley.EDU (Josh MacDonald) Date: Fri, 18 Apr 1997 14:01:03 -0700 (MST) Cc: freebsd-hackers@freebsd.org In-Reply-To: <199704180627.XAA15953@paris.CS.Berkeley.EDU> from "Josh MacDonald" at Apr 17, 97 11:27:26 pm X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > In the man page for open, it says that O_EXCL causes symlinks not to > be followed. However, when I was reading the code, I found that its > broken. In the open syscall, it does NDINIT with the FOLLOW flag already > set, and then in vn_open, which is called shortly thereafter with the > nameidata struct, it does: > > if ((fmode & O_EXCL) == 0) > ndp->.... |= FOLLOW;\ > > It looks to me like its broken, and either it should be fixed with the > trivial fix, or the documentation for open fixed. It looks broken because of the explicit compare for zero. An explicit compare for zero (x == 0) is a longer, harder to intutively understand way of saying (!x) that is used because it's somehow stylish (actually, I think it originated at about the same time the compiler started bitching about assignments using the lvalue a a boolean in 'if' statements). So the FOLLOW is set only if the O_EXCL flag is *not* present. Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.