Today, we review some Linux commands and a little bit C programming.
The first command reviewed is STRACE, which is used to trace system calls and signals.
For example, we can use “strace ls foo” to check ls command on file foo under current directory.
Below is the partial result.
The second command introduced is stat, which is to display some file information. Below example displayed some information about file foo.
The third is to create a C program to do the same function like stat does. Below has the details:
In this version, structure variable “buf” is used. Here if we use pointer variable in structure type, we will need to allocate memory first, otherwise we will have “bad address” exception under strace command. Below has the pointer version.
Now, it comes to the result:
In conclusion, Linux system programming is not that complex as it seems. Get more reading and practice, we will have more understanding about Linux OS.
标签:review,some,Below,command,file,Linux From: https://www.cnblogs.com/zwang562020/p/16600010.html