question about vfs_lookup

Eric Anderson anderson at freebsd.org
Thu Feb 22 22:11:50 UTC 2007


On 02/17/07 15:03, Pawel Jakub Dawidek wrote:
> On Fri, Feb 16, 2007 at 11:56:40PM -0600, Eric Anderson wrote:
>> I'm just curious about how this block (starting at line 712) could possibly ever get executed, since right before it there is a condition that would cause a panic.
>>
>> Can anyone explain this please?
> 
> You read KASSERT(9) in a wrong way. The condition used in assertion says
> "don't panic if the condition is true". Here we panic when flag ISLASTCN
> is not set and *ndp->ni_next is not equal to '/'.


That makes a lot more sense now.. Thanks :)

Eric


>> In sys/kern/vfs_lookup.c:
>> 710         KASSERT((cnp->cn_flags & ISLASTCN) || *ndp->ni_next == '/',
>> 711             ("lookup: invalid path state."));
>> 712         if (*ndp->ni_next == '/') {
>> 713                 cnp->cn_nameptr = ndp->ni_next;
>> 714                 while (*cnp->cn_nameptr == '/') {
>> 715                         cnp->cn_nameptr++;
>> 716                         ndp->ni_pathlen--;
>> 717                 }
>> 718                 if (ndp->ni_dvp != dp)
>> 719                         vput(ndp->ni_dvp);
>> 720                 else
>> 721                         vrele(ndp->ni_dvp);
>> 722                 VFS_UNLOCK_GIANT(dvfslocked);
>> 723                 dvfslocked = vfslocked; /* dp becomes dvp in dirloop */
>> 724                 vfslocked = 0;
>> 725                 goto dirloop;
>> 726         }
> 



More information about the freebsd-fs mailing list