Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Jan 2002 20:40:57 -0500 (EST)
From:      Robert Watson <rwatson@freebsd.org>
To:        Hyong-Youb Kim <hykim@cs.rice.edu>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: uniquely identifying a file
Message-ID:  <Pine.NEB.3.96L.1020122203629.19062E-100000@fledge.watson.org>
In-Reply-To: <Pine.GSO.4.33.0201221711520.2676-100000@vaud.cs.rice.edu>

next in thread | previous in thread | raw e-mail | index | archive | help

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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.NEB.3.96L.1020122203629.19062E-100000>