From owner-freebsd-hackers Sun Aug 15 15:47:20 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from wall.polstra.com (rtrwan160.accessone.com [206.213.115.74]) by hub.freebsd.org (Postfix) with ESMTP id 0DB0A15271 for ; Sun, 15 Aug 1999 15:47:17 -0700 (PDT) (envelope-from jdp@polstra.com) Received: from vashon.polstra.com (vashon.polstra.com [206.213.73.13]) by wall.polstra.com (8.9.3/8.9.1) with ESMTP id PAA02661; Sun, 15 Aug 1999 15:47:40 -0700 (PDT) (envelope-from jdp@polstra.com) Received: (from jdp@localhost) by vashon.polstra.com (8.9.3/8.9.1) id PAA98225; Sun, 15 Aug 1999 15:47:40 -0700 (PDT) (envelope-from jdp@polstra.com) Message-ID: X-Mailer: XFMail 1.3 [p0] on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: Date: Sun, 15 Aug 1999 15:47:40 -0700 (PDT) Organization: Polstra & Co., Inc. From: John Polstra To: Alfred Perlstein Subject: Re: Getting device and inode number from a vnode Cc: hackers@FreeBSD.ORG Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Alfred Perlstein wrote: > On Sun, 15 Aug 1999, John Polstra wrote: >> >> 1. I have a pointer to a vnode and I want to get the corresponding >> dev_t and inode number. Is there a non-sleazy way to do that other >> than calling vn_stat? > > use vn_todev from "vfs_subr.c" ~line 2970 of 2976 if you just > need the dev_t. Thanks. I didn't make it clear in my question, but I want the dev_t of the filesystem containing the file (st_dev rather than st_rdev). > but you may wind up needing the GETATTR call for the inode lookup. OK. >> 2. The first action of vn_stat is to call VOP_GETATTR. VOP_GETATTR(9) >> says, "The file should not be locked on entry." But when stat calls >> vn_stat, the vnode is locked. Which is correct -- or doesn't it >> matter? > > the lookup at the begininngin of the stat() call's side-effect is to > lock the vnode it returns but kern/vnode.src seems to indicate > that the vnode's locking state doesn't matter... Ah, good. That helps. > so does the various states that vnodes are in when called from > vfs_syscalls, such as the lseek syscall. Yes, and fstat doesn't lock it either. > it's slighly confusing, if the vnode is locked for "access" calls > why is it not locked for attribute calls? I'm confused too. :-) John --- John Polstra jdp@polstra.com John D. Polstra & Co., Inc. Seattle, Washington USA "No matter how cynical I get, I just can't keep up." -- Nora Ephron To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message