Subject: namei(".") behaviour
To: None <tech-kern@netbsd.org>
From: Juergen Hannken-Illjes <hannken@eis.cs.tu-bs.de>
List: tech-kern
Date: 07/29/2003 18:26:44
While looking over the filesystem snapshot code from FreeBSD I discovered a
somewhat strange behaviour of namei():
If called for a DOT directory ("." or "...path/.") it returns with
nd.ni_dvp == nd.ni_vp
Even if called with LOCKPARENT flag both (identical) vnodes are not locked.
This leads to a bunch of code like
if (nd.ni_dvp == nd.ni_vp)
vrele(nd.ni_dvp);
else
vput(nd.ni_dvp);
Is there a reason why the parent directory (nd.ni_dvp) is returned unlocked?
If the parent directory was locked this code would become as simple as
vput(nd.ni_dvp);
--
Juergen Hannken-Illjes - hannken@eis.cs.tu-bs.de - TU Braunschweig (Germany)