From owner-freebsd-hackers Tue Jan 22 17:41:17 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by hub.freebsd.org (Postfix) with ESMTP id AC3CC37B402 for ; Tue, 22 Jan 2002 17:41:11 -0800 (PST) Received: from fledge.watson.org (fledge.pr.watson.org [192.0.2.3]) by fledge.watson.org (8.11.6/8.11.5) with SMTP id g0N1evD21233; Tue, 22 Jan 2002 20:40:57 -0500 (EST) (envelope-from robert@fledge.watson.org) Date: Tue, 22 Jan 2002 20:40:57 -0500 (EST) From: Robert Watson X-Sender: robert@fledge.watson.org To: Hyong-Youb Kim Cc: freebsd-hackers@freebsd.org Subject: Re: uniquely identifying a file In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Tue, 22 Jan 2002, Hyong-Youb Kim wrote: > What would be a unique id of a file on a local system? Is the full path > of a file the only way to uniquely identify a file? Is there any place I > can get some info on the funtion textvp_fullpath? Thanks. > > I am a complete newbie in kernel hacking so any comment is welcome. The notion of uniquely identifying files is a bit vague in BSD, due to the lack of clarity on the namespace. Local files in filesystems that can be NFS-exported generally have a notion of a 'file handle' (not to be confused with a file descriptor), which can be managed using a series of fh*() syscalls. However, when you bring distributed systems into the mix, the only way to uniquely identify a file is by name, and even then there are no guarantees about that name pointing to a particular file beyond a particular lookup (note the possibility for various race conditions). Some systems try to introduce such names, but fail. For example, Linux's VFS (in the past, possibly still) has tried to assign unique (device, inode#) pairs to file system objects. This breaks down fairly badly when it connects to distribute systems with large namespaces, such as AFS which has a 96-bit namespace. In fact, it used to be the case (maybe still) that Linux would panic when using Coda or AFS and hit a collision in the hash they used to map the 96 bit FID into a 32 bit inode number. In the kernel, you can use textvp_fullpath to get something human readable, but because names also are with respects to a particular process root, and can't take into account hard links, mountpoints, etc, that has limited use also. The closest I've ever found to a unique name is a vnode pointer: as long as you hold a reference using vref, the pointer will be valid (and possibly useful if there are no forceable unmounts). Can you avoid trying to uniquely identify a file? :-) Robert N M Watson FreeBSD Core Team, TrustedBSD Project robert@fledge.watson.org NAI Labs, Safeport Network Services To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message