![uname:它使用什么ioctl?](https://linux22.com/image/219974/uname%EF%BC%9A%E5%AE%83%E4%BD%BF%E7%94%A8%E4%BB%80%E4%B9%88ioctl%EF%BC%9F.png)
有谁知道是直接打电话还是间接uname()
打电话ioctl()
?我查看了来源,但没有看到它确实如此。我也用过strace
,没有看到内核调用。
谢谢
strace uname
execve("/usr/bin/uname", ["uname"], 0x7fffe60bef30 /* 35 vars */) = 0
brk(NULL) = 0x559dc7796000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=161332, ...}) = 0
mmap(NULL, 161332, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fd0c9384000
close(3) = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260A\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1820400, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd0c9382000
mmap(NULL, 1832960, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fd0c91c2000
mprotect(0x7fd0c91e4000, 1654784, PROT_NONE) = 0
mmap(0x7fd0c91e4000, 1339392, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x7fd0c91e4000
mmap(0x7fd0c932b000, 311296, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x169000) = 0x7fd0c932b000
mmap(0x7fd0c9378000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b5000) = 0x7fd0c9378000
mmap(0x7fd0c937e000, 14336, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fd0c937e000
close(3) = 0
arch_prctl(ARCH_SET_FS, 0x7fd0c9383540) = 0
mprotect(0x7fd0c9378000, 16384, PROT_READ) = 0
mprotect(0x559dc6f13000, 4096, PROT_READ) = 0
mprotect(0x7fd0c93d3000, 4096, PROT_READ) = 0
munmap(0x7fd0c9384000, 161332) = 0
brk(NULL) = 0x559dc7796000
brk(0x559dc77b7000) = 0x559dc77b7000
openat(AT_FDCWD, "/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=3031632, ...}) = 0
mmap(NULL, 3031632, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fd0c8edd000
close(3) = 0
uname({sysname="Linux", nodename="debian", ...}) = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
write(1, "Linux\n", 6Linux
) = 6
close(1) = 0
close(2) = 0
exit_group(0) = ?
+++ exited with 0 +++
答案1
答案2
从你的strace:
uname({sysname="Linux", nodename="debian", ...}) = 0
根本没有ioctl。uname
它本身是一个系统调用(在 Linux 上),它采用一个结构体的地址,并用系统信息填充该结构体。
man 2 uname
有更多详细信息。