> I want to make a kernel module to do something. In this module, I will 
redirect syscalls. After my open syscall, I want to add some self-defined data 
to some files. User programs know nothing about this.
> What shall I do?
> 
> I have read information about openat(2), but I do not know what  can I learn 
from openat(2).
> Would you show me some details? Thank you very much!


If you do not want to write a rootkit, then there's no point in packing
such things into the kernel. You'd have to write your own filesystem
for that - far too much effort which isn't justified. I won't help you
there.

You could better implement something like this rather by LD_PRELOAD'ing
a library that reimplements the file interfaces, does your stuff and
then passes through to libc. Note that just "overriding" open() won't
do - you have to reimplement all, because of the requirement to keep
the file pointer (next offset to be read/written) updated ...

You're looking for a source example of this mechanism ?
Get the "shadowfs" library:

        http://svn.clifford.at/shadowfs/trunk/README

I haven't tried this on Solaris, but LD_PRELOAD on Solaris/*BSD/Linux
works the same way so I see no technical reason why that lib couldn't
do on Solaris. Let us know how you get along with it.

Btw, for the flamewar folks: Does the ability to LD_PRELOAD a GPL-
licensed library automatically force all programs on a system to
comply to the GPL ?
;-)


Best wishes,
FrankH.

_______________________________________________
opensolaris-discuss mailing list
[email protected]

Reply via email to