You can watch syscall getcwd getcwd
to see how to do it.
This syscall is located in fs/dcache.c
and calls:
get_fs_root_and_pwd(current->fs, &root, &pwd);
root
and pwd
are struct path
variables,
This function is defined as a built-in function in include/linux/fs_struct.h
, which also contains:
static inline void get_fs_pwd(struct fs_struct *fs, struct path *pwd)
and it looks like what you need.
source share