I am working on a project in which I need to know the current working directory of the executable which called the system call. I think it would be possible as some system calls like open would make use of that information.
Could you please tell how I can get the current working directory path in a string?
You can look at how the
getcwdsyscall is implemented to see how to do that.That syscall is in
fs/dcache.cand calls:rootandpwdarestruct pathvariables,That function is defined as an inline function in
include/linux/fs_struct.h, which also contains:and that seems to be what you are after.