Re: Points to fs architecture

From: Chris Wedgwood
Date: Mon Jul 05 2004 - 17:55:42 EST


On Mon, Jul 05, 2004 at 04:38:58PM -0500, surfing t wrote:

> I want to create a utility that "hooks" into the the filesystem.

OK

> What I want to do is to be able to review all file system
> read/write/seek requests, most of the time without affecting file
> system operation (ie after review the request is passed on to the
> entity that would have received it had my utility not been
> installed, however some of the requests my driver should handle
> itself.

Strictly speaking what you want then is not going to be at the
filesystem layer, since the filesystem layer doesn't generally see
seeks, writes, etc.

It sounds like you want to instrument the system calls, look at the
man pages for 'strace' and similar.

> Basically I just want to "hijack" the system calls that applications
> use to access files and then pass them on to the original system
> call. Is this possible and how do I do it?

The ptrace system call and a little effort will let you do this. You
can also use LD_PRELOAD and over-ride some glibc hooks for the file IO
operations --- there are plenty of things that do this I'm sure
already.


--cw
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/