获取内核代码中的当前工作目录 [英] Getting current working directory within kernel code
问题描述
open
将会使用这些信息。 你能告诉我如何获取字符串中当前的工作目录路径?
您可以看看 getcwd
系统调用是如何实现的,看看如何做到这一点。
该系统调用在 fs / dcache.c
并调用:
get_fs_root_and_pwd(current-> fs,& root,& pwd);
根
和 pwd
是结构路径
变量,
该函数定义为内联函数 include / linux / fs_struct.h
,其中还包含:
static inline void get_fs_pwd(struct fs_struct * fs,struct path * pwd)
这似乎是你之后。
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 getcwd
syscall is implemented to see how to do that.
That syscall is in fs/dcache.c
and calls:
get_fs_root_and_pwd(current->fs, &root, &pwd);
root
and pwd
are struct path
variables,
That function is defined as an inline function in include/linux/fs_struct.h
, which also contains:
static inline void get_fs_pwd(struct fs_struct *fs, struct path *pwd)
and that seems to be what you are after.
这篇关于获取内核代码中的当前工作目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!