kernel space realpath()
Hi,
I am new to kernel development. I am developing now a kernel module to create log of all file operations under a certain specified directory. I intercept the system calls that may do modifications to this directory contents and create the logfile. My problem is that a system call like sys_unlink takes a path that could be relative, and could contain ".." or ".". It might also contain components that are symlinks to other directories. So I want to get the real path of that file given its relative path name.
Is there anyway to do that ?
I appreciate your help.
Best regards
Ramy
Quoted 9 lines · Ramy M. Hassan
I am new to kernel development. I am developing now a kernel module to create log of all file operations under a certain specified directory. I intercept the system calls that may do modifications to this directory contents and create the logfile. My problem is that a system call like
sys_unlinktakes a path that could be relative, and could contain ".." or ".". It might also contain components that are symlinks to other directories. So I want to get the real path of that file given its relative path name.
Is there anyway to do that ?
Isn't this exactly what the LSM project does? See http://lsm.immunix.org/
Signature · 3 lines
"It's not Hollywood. War is real, war is primarily not about defeat or victory, it is about death. I've seen thousands and thousands of dead bodies. Do you think I want to have an academic debate on this subject?" -- Robert Fisk
Quoted 11 lines · * Matthew Wilcox ([email protected]) wrote:
Quoted 9 lines · Ramy M. Hassan
I am new to kernel development. I am developing now a kernel module to create log of all file operations under a certain specified directory. I intercept the system calls that may do modifications to this directory contents and create the logfile. My problem is that a system call like
sys_unlinktakes a path that could be relative, and could contain ".." or ".". It might also contain components that are symlinks to other directories. So I want to get the real path of that file given its relative path name.
Is there anyway to do that ?
Quoted 1 line
Isn't this exactly what the LSM project does? See http://lsm.immunix.org/
Actually, LSM works with dentry/vfsmount pairs not raw pathnames, but yes, there are filesystem level hooks that allow one to do things like this.
Signature · 1 line
Linux Security Modules http://lsm.immunix.org http://lsm.bkbits.net
Quoted 10 lines · Ramy M. Hassan
Hi,
I am new to kernel development. I am developing now a kernel module to create log of all file operations under a certain specified directory. I intercept the system calls that may do modifications to this directory contents and create the logfile. My problem is that a system call likesys_unlinktakes a path that could be relative, and could contain ".." or ".". It might also contain components that are symlinks to other directories. So I want to get the real path of that file given its relative path name.
Is there anyway to do that ?
You should take a look at some syscall, that returns path. Like sys_getcwd. It call d_path (resp. __d_path, because it already has all the locks).
-------------------------------------------------------------------------------
Jan 'Bulb' Hudec <[email protected]>
Quoted 2 lines
I am new to kernel development. I am developing now a kernel module to create log of all file operations under a certain specified directory. I
look at http://www.cs.columbia.edu/~ezk/research/fist/
you can achieve what you want, and even more.
Signature · 2 lines
======================================================================== nir.