Subject: Re: namei(".") behaviour
To: None <>
From: Juergen Hannken-Illjes <>
List: tech-kern
Date: 07/29/2003 20:18:19
On Tue, Jul 29, 2003 at 06:26:44PM +0200, Juergen Hannken-Illjes wrote:
> 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);

To follow up myself...

With Rev. 1.23 (mycroft) of kern/vfs_lookup.c a check for degenerate name
was removed. This check (in lookup) returned:

    ENOTDIR if the last component was "" and not a directory
    EISDIR  if the last component was "" and mode != LOOKUP

still confused,
Juergen Hannken-Illjes - - TU Braunschweig (Germany)