Linux通配符(*)是在用户空间还是内核空间实现的?

huangapple go评论147阅读模式
英文:

Linux Wildcard (*) is implemented on User Space or Kernel Space?

问题

通配符在Linux中的实现方式已经发生了变化。过去,通配符是一个位于/etc/glob目录下的二进制文件,或者是C函数glob()的一部分。如今,在任何基于Unix的系统中,通配符已经成为系统的本机功能。但是,当我们输入类似以下命令时,它在哪个空间运行可能令人困惑:

mv * folder
ls *

它是在用户空间还是内核空间运行?

这是上下文链接

英文:

I've researched so far that Wildcards in Linux were a binary located in /etc/glob, or in C functions called glob(). Nowadays it's native in any Unix-based system, but, it's confusing to understand where it runs, when we type something like:

mv * folder
ls *

Is it running in user space or kernel space?

This is the context

答案1

得分: 3

这是在你提供的示例中在 shell 层面完成的,例如 bash、tcsh 等。我假设它们将使用 glob(3) 这个 C 库函数来实现这个目标。这严格属于用户空间。

英文:

This is done at the shell level in the example you give, e.g. bash, tcsh, etc. They will I presume use glob(3), a C library function, to accomplish this. This is strictly user-space.

答案2

得分: 3

Kernel space被用于内核代表用户程序执行(例如系统调用)时吗?或者它是所有内核线程的地址空间(例如调度程序)吗?

是的,两者都是。

我假设他们将使用glob(3),一个系统调用,来完成这个任务。系统调用发生在内核空间。此外,glob(3)还会执行其他系统调用,例如opendir(),也都在内核空间运行。

英文:

> Is Kernel space used when Kernel is executing on the behalf of the user program i.e.
> System Call? Or is it the address space for all the Kernel threads (for example
> scheduler)?
>
>> Yes and yes.

They will I presume use glob(3), a system call, to accomplish this. System calls take place in kernel space. Also glob(3) will make other system calls such as opendir(), also running in kernel space.

答案3

得分: 0

没有名为 glob 的系统调用。bash中的通配符功能是由glob()函数提供的,该函数在 用户空间 中运行。感谢 @Vercingatorix。

要查看系统调用列表,请运行 man syscalls

这个新的回复是为了指出接受的答案是错误的,可能会误导读者。

英文:

There isn't such syscall glob. The wildcard feature in bash is provided by the glob() function, which runs in the user space. Credits for @Vercingatorix

To see a list of syscalls, run man syscalls.

This new reply is for calling out that the accepted answer is wrong and can mislead readers.

huangapple
  • 本文由 发表于 2020年1月4日 01:53:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/59583129.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定