【linux读取sys调用不会得到EOF】教程文章相关的互联网学习教程文章

在Linux / ARM中跟踪库调用的工具

我正在寻找一种工具,可以跟踪Linux / ARM中共享库中函数的调用.基本上,我希望能够指定一个命令行,并让该工具生成一个被调用的库函数和传递的参数的记录.我想可以使用某种形式的功能挂钩. 我知道ltrace,它提供了我所需要的功能.但是,ltrace对我不起作用: >在追踪更复杂的程序时经常会出现段错误.>非常慢. 我正在寻找一个更强大的替代方案.速度很快,但不是我的主要关注点.首先,我想有一种跟踪库调用的方法,可以分析任何(非回避)程序...

linux – 从Java调用Syscalls【代码】

有没有办法直接从Java调用syscalls,还是首先调用本机方法?解决方法:您需要使用本机方法,但您不需要自己实现它. Java在JNI上有一个名为JNA (Java Native Access)的变体,它允许您直接访问共享库而不需要包含它们的JNI接口,因此您可以使用它直接与glibc接口:import com.sun.jna.Library; import com.sun.jna.Native;public class Test {public interface CStdLib extends Library {int syscall(int number, Object... args);}public...

linux – 当子进程在创建后立即调用exec()或exit()时,为什么要使用vfork()?

操作系统概念和APUE说With vfork(), the parent processis suspended, and the child process uses the address space of the parent.Because vfork() does not use copy-on-write, if the child process changesany pages of the parent’s address space, the altered pages will be visible to theparent once it resumes. Therefore, vfork() must be used with caution to ensurethat the child process does not modify the ...

Linux中的库调用和系统调用有什么区别?

我想知道在Linux中库调用和系统调用之间有什么区别.任何能够很好地理解两者背后概念的指针都将不胜感激.解决方法:“库调用”并不是真正的事情.您可以调用链接到共享库的函数.这只意味着在运行时查找库路径以确定要调用的函数的位置. 系统调用是内核处理的低级内核调用.

linux – 系统调用“tuxcall”做了什么?【代码】

在include / x86_64-linux-gnu / asm / unistd_64.h中,我看到一个名为tuxcall的系统调用,#define __NR_tuxcall 184除了说它是一个未实现的系统调用之外,在man tuxcall中没有任何关于它的内容.它做了什么?是从未实施过,还是在古代做过什么?解决方法:tuxcall是the tux system call的占位符,用户空间工具使用它与TUX内核模块进行通信,后者实现了TUX web server.这是一个完全在内核中运行的Web服务器;它由Ingo Molnar维护,直到Linux的...

如何使用ftrace跟踪系统调用事件而不显示Linux内核中的任何其他函数?【代码】

例如,要监控所有mkdir调用,我能想到的最好的是:#!/bin/sh set -euxd=debug/tracingmkdir -p debug if ! mountpoint -q debug; thenmount -t debugfs nodev debug fi# Stop tracing. echo 0 > "${d}/tracing_on"# Clear previous traces. echo > "${d}/trace"# Enable tracing mkdir echo sys_enter_mkdir > "${d}/set_event"# Set tracer type. echo function > "${d}/current_tracer"# Filter only sys_mkdir as a workaround. e...

linux – 打开系统调用失败【代码】

在我调用open()系统调用之后fd = open(dir, O_RDONLY, 0); printf("fd=%d\n", fd); if (fd < 0)perror("open");我得到fd = -2并且perror(“打开”)打印“成功”!!! 这是什么意思,为什么会发生? 好的,我决定以不同的方式测试我的代码,如下所示:if ((fd = open(dir, O_RDONLY, 0)) >= 0) {/* do smthg */ } else {perror("open");printf("fd=%d\n", fd); }我认为我建议的代码的最后一部分与errno值的中间函数交替没有冲突,但我仍然...

在linux中没有超过6个参数的系统调用是真的吗?【代码】

在unistd.h中有_syscall0~_syscall6:_syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6)我的结论是对还是不对?解决方法:看起来该功能接受7个参数(0-6),但这个网页说6 从这里:http://www.win.tue.nl/~aeb/linux/lk/lk-4.htmlEarlier versions of Linux could handleonly four or five system callparameters, and therefore the systemcalls select() (5 parameters) andmmap() (6 parame...

errno,strerror和Linux系统调用【代码】

在使用CRT函数(如fopen)之后,我可以使用strerror来获取errno值的文本表示.如果我使用开放的Linux系统调用而不是CRT函数,它也会在失败时设置errno值.将strerror应用于此errno值是否正确?如果没有,是否有一些Linux系统调用,它与strerror相同?解决方法:是 是 在那里是恐怖的if (-1 == open(....)) {perror("Could not open input file");exit(255) }

替换linux内核3中的系统调用

我有兴趣用我将在linux内核3中实现的自定义替换系统调用.我读到sys调用表不再暴露. 有任何想法吗? 任何对此http://www.linuxtopia.org/online_books/linux_kernel/linux_kernel_module_programming_2.6/x978.html示例的引用,但对于内核3将不胜感激:) 谢谢!解决方法:我建议使用kprobes来完成这种工作,你可以轻松打破任何内核地址(或符号……)并在运行时改变执行路径,所有这一切都需要内核模块,如果你需要:) Kprobes通过中断(例如x...

Linux内核systemcall调用“int 0x80”【代码】

我正在研究Linux内核,目前我尝试实现自己的系统调用. 在内核代码中,它看起来如下:asmlinkage long sys_my_syscall() {printk("My system call\n");return 0; }如果我用systemcall()函数调用它可以正常工作,但我找到了另一种方法:int my_syscall(void) {long __res;__asm__ volatile ("movl $312, %%eax;""int $0x80;""movl %%eax, %0;": "=m" (__res):: "%eax");if ((unsigned long) (__res) >= (unsigned long) (-125)) {errno ...

c – 将VS移植到linux:没有用于调用的匹配函数【代码】

我正在尝试移植使用visual studio和linux gcc4.6编译好的代码抛出这个:PieMenu.cpp: In member function ‘void PieMenu::AddButtons()’: error: no matching function for call to ‘std::basic_ifstream<char>::open(const wchar_t*)’PieMenu.cpp:110:44: note: candidate is: /usr/include/c++/4.6/fstream:531:7: note: void std::basic_ifstream<_CharT, _Traits>::open(const char*, std::ios_base::openmode) [with _Cha...

Linux内核系统调用返回-1而不是{-1,-256}【代码】

我是一个内核新手,面临着一个奇怪的问题.我编写了一个概念验证计算器系统调用,虽然它适用于大多数计算,但当SUBTRACTION结果介于-1到-256之间时它返回-1.如果有人可以对可能发生的事情有所了解,那就会很感激.下面是系统调用代码.SYSCALL_DEFINE3(calc, int, a, int, b , char, op) {int res_int;switch(op) {case '+': res_int = a + b;break;case '-': res_int = a - b;break;case '*': res_int = a * b;break;case '/': res_int =...

linux汇编:如何调用syscall?【代码】

我想在汇编中调用一个系统调用.问题是我不能运行ecx,rsp. rsp是64位寄存器,ecx是32位寄存器.我想将缓冲区addr作为此系统调用的参数传递.我能做什么?谢谢.section .data s0: db "Largest basic function number supported:%s\n",0 s0len: equ $-s0section .text global main extern write main: sub rsp, 16 xor eax, eax cpuidmov [rsp], ebx mov [rsp+4], edx mov [rsp+8], ecx mov [rsp+12], word 0x0mov eax, 4 mov ebx, 1...

复制/移动文件并在Linux中使用系统调用的C应用程序【代码】

我很难进行系统调用来取消链接我的C代码中的文件工作.我希望在复制代码后从文件系统中删除该文件.我收到的错误是:declared here extern int unlink (const char *__name) __THROW __nonnull ((1));#include <stdio.h>#include <unistd.h>#include <errno.h>#include <fcntl.h> int main(int argc, char * args []) {int infile, outfile;int numofbytesread;char buffer[20];infile = open(args[1], O_RDONLY, 0700);if (infile =...