问题
I am writing a kernel module that hijacks several system calls. Several of the system calls take paths as parameters. For my purposes, I need to work with full paths, but since these parameters are passed as strings, it could be anything like "documents"
, "/home/main/../bob"
, or "../lib"
. I need to get the real paths of these references, but I don't know which function to use or which information I need (e.g., the current working directory, etc.).
The kernel obviously has some way of making paths normalized so it can perform operations necessary for SELinux, IMA, and a bunch of other things. How can I do that?
来源:https://stackoverflow.com/questions/39089860/get-canonical-path-from-pathname