Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Jan 2003 08:37:23 -0800
From:      David Schultz <dschultz@uclink.Berkeley.EDU>
To:        Pawel Jakub Dawidek <P.Dawidek@prioris.mini.pw.edu.pl>
Cc:        Terry Lambert <tlambert2@mindspring.com>, freebsd-hackers@FreeBSD.ORG
Subject:   Re: Caching [sugestion].
Message-ID:  <20030106163723.GA721@HAL9000.homeunix.com>
In-Reply-To: <20030106074005.GB6825@prioris.mini.pw.edu.pl>
References:  <20030105215024.GB99855@prioris.mini.pw.edu.pl> <3E18B97A.32ABAE7@mindspring.com> <20030106074005.GB6825@prioris.mini.pw.edu.pl>

next in thread | previous in thread | raw e-mail | index | archive | help
Thus spake Pawel Jakub Dawidek <P.Dawidek@prioris.mini.pw.edu.pl>:
> On Sun, Jan 05, 2003 at 03:02:18PM -0800, Terry Lambert wrote:
> +> This is a much larger problem than you make it out to be.
> 
> Yes, right, using vnodes is bad idea, sorry.
> 
> I'll describe my problem precisely.
> I'm writing kld module where it have to be done.
> I got two choices:
> 	- getting path from cache, but this don't give me 100% sure
> 	  that I'll get this path (even if it exists),
> 	- (ugly to) catch syscalls:
> 		+ open(),
> 		+ chdir(),
> 		+ fchdir(),
> 		+ execve(),
> 	  add two my functions to at_exit() and at_fork() and
> 	  (this is ugly as fuck) remember and switch functions
> 	  that are called on descriptor close
> 	  (p->p_fd->fd_ofiles[X]->f_ops->fo_close()).
[...]
> So I'm not able to create policy rules based on filenames.

You still haven't explained exactly what you're trying to do, but
you may wish to look into Niels Provos' Systrace.  It should give
you a good example of how to do system call interposition in the
kernel, and it has been ported to all three BSDs.

	http://www.citi.umich.edu/u/provos/systrace/

It sounds like you're trying to do something complicated with
chdir, and that could make things harder.  First of all, you
should be comparing vnodes instead of pathnames when possible, in
order to avoid canonicalization bugs.  Second, it only makes sense
to ask for the path of a directory vnode, since ordinary files can
have multiple hard links.  For directories, you can get the full
path by walking up the '..' pointers, sort of like vn_fullpath(),
except that you have to do a lookup if something is missing from
the cache.  I expect locking would be a pain as well.

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?20030106163723.GA721>