From owner-freebsd-fs@FreeBSD.ORG Sat Aug 5 15:17:53 2006 Return-Path: X-Original-To: freebsd-fs@freebsd.org Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0D9E316A4DD for ; Sat, 5 Aug 2006 15:17:53 +0000 (UTC) (envelope-from pelt22@gmail.com) Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.239]) by mx1.FreeBSD.org (Postfix) with ESMTP id 511B443D46 for ; Sat, 5 Aug 2006 15:17:52 +0000 (GMT) (envelope-from pelt22@gmail.com) Received: by wx-out-0506.google.com with SMTP id i27so233087wxd for ; Sat, 05 Aug 2006 08:17:51 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=c3AP91apU3SgWutZVr3I5OyhDwIb4pzirrTOUogSaJ/9QSA4vgBAGTprWSFAei959Un6koJi78pKZIreQrJNOhI3UdJSRcbB/Xva8TtIEUH33XPHdqSi+MVL+xZDLrz3j60yOx+HA5h2XmUKsQf5ZpTj208v0wK//FRFXaVp5as= Received: by 10.70.100.1 with SMTP id x1mr6120403wxb; Sat, 05 Aug 2006 08:17:51 -0700 (PDT) Received: by 10.70.99.1 with HTTP; Sat, 5 Aug 2006 08:17:51 -0700 (PDT) Message-ID: Date: Sat, 5 Aug 2006 17:17:51 +0200 From: "Michiel Pelt" To: freebsd-fs@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: VOP_LOOKUP of .. in msdosfs X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Aug 2006 15:17:53 -0000 Hi, I am developing a filesystem which doesn't have a . and .. in the root. So I emulate them, just like msdosfs does. I looked at the msdosfs code. Correct me if I am wrong, but I think there is something wrong with it. The msdosfs_lookup function in msdosfs_lookup.c has code dealing with the rootdirectory at the label foundroot:. At line 523 (release 6.1 code) of the release code is this piece of code: pdp = vdp; if (flags & ISDOTDOT) { VOP_UNLOCK(pdp, 0, td); error = deget(pmp, cluster, blkoff, &tdp); vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, td); if (error) return (error); *vpp = DETOV(tdp); } This code has been copied from ffs code, but fails for msdosfs. For starters the introduction of the 'pdp' pointer has no function whatsoever. Consider a lookup for .. in the root. In msdosfs the /. and /.. directories are represented by one and the same vnode (see deget() in msdosfs_denode.c). The deget gets and locks the vnode that was unlocked by VOP_UNLOCK. The vn_lock that follows fails with a panic because the vnode is already locked. So why does this not happen in practice? Because the ISDOTDOT case is handled by vfs_lookup and never reaches VOP_LOOKUP. I did get the error because I forgot to set the VV_ROOT flag in the vnode returned by VFS_ROOT ;-(. Best Regards Michiel