Quantcast
Channel: Active questions tagged linux-kernel - Stack Overflow
Viewing all articles
Browse latest Browse all 12244

How to implement a system call that could check if itself has been successfully executed without going to the kernel log?

$
0
0

How to check if a system call has successfully executed?

One way is to use command line $ dmesg to look at kernel log. Is there any other way that we can do?

My first thinking is that, we could check the return value of a system call. However, we could not get the return value until the system call has been executed. Therefore, the second approach is shown below:

We could implement a new system call, in which it writes something into a buffer. Then, another system call reads the content of the buffer to check if the previous system call has written to the buffer. (Somehow like pthread_create and pthread_join)Hence, the implementation consists of 2 system calls in total.

What gets me stuck is that, where should we create the buffer? On stack? Or we make it a newly created file? And how to actually implement the two system calls?

Here is a sketch of my implementation written in pseudocode:

syscall_2(...){    if (syscall_1 executes)        return 0;    if (syscall_1 NOT executes)        return -1;}syscall_1(){    do something;    create a buffer;    write something into buffer;    return syscall_2(buffer); // checks what is in buffer}

Viewing all articles
Browse latest Browse all 12244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>