Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Aug 2001 12:00:59 -0700
From:      Terry Lambert <tlambert2@mindspring.com>
To:        Julian Elischer <julian@elischer.org>
Cc:        "Eugene L. Vorokov" <vel@bugz.infotecs.ru>, Sansonetti Laurent <lorenzo@linuxbe.org>, freebsd-hackers@FreeBSD.ORG
Subject:   Re: Getting filename from descriptor or vnode struct
Message-ID:  <3B7D69EB.85E7D950@mindspring.com>
References:  <Pine.BSF.4.21.0108170904480.22899-100000@InterJet.elischer.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Julian Elischer wrote:
> 
> you are going to have to examine the name cache and find the inode of the
> directories in the full path. Most open directories will have their full
> path in the caches..

For the problem he is trying to solve, he should:

1)	Precompute the path to the configuration file, and
	save the ino_t and dev_t for the thing.

2)	Compare this tuple against the result of VOP_LOOKUP
	or VOP_READDIR operations, and hide the results if
	it matches.

NB: Life would be easier for multiple configuration files
if you picked a configuration directory, instead, and hid
that, rather than individual files, making it an O(1), not
an O(n) operation.

In other words, look it up forwards once, instead of looking
it up reverse many times.

You should also be aware that the "hiding" you are doing
will not "save you" from mounts overlaying your names, so,
if you care about consistancy, you should probably open the
target file/directory at the start, and cache a reference
to it for the duration, so that it can't cache out from
under the kernel code you are writing (e.g. if you use the
directory approach, you need to to do exactly what a process
does when it gets a current working directory, so look at
that code in the kernel and copy it).

There are other issues of data folding (e.g. you can treat
the directory variantly as a file or directory, in order to
flod it out from the FS, which would then let you reuse the
directory name from user space, and be none the wiser), but
that's a topic for later, after you get your initial code
working.

-- Terry

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?3B7D69EB.85E7D950>