Skip to content
Advertisement

Tag: c++

More explanation on `statfs64`

According to documentation, the structure fields explanation follows: Does “total file nodes in file system” mean how much existing files we have? Does it include directories and links? What does mean “free file nodes in fs”? What is f_spare? In some Linux forks (for example, in Android) I see that f_spare size is 4, and additional field f_flags is defined.

get process inode using netlink

I want to try and correlate an IP packet (using libpcap) to a process. I have had some limited success using the relevant /proc/net/ files but found that on some of the machines i’m using, this file can be many thousands of lines and parsing it is not efficient (caching has alleviated some performance problems). I read that using sock_diag

Searching a text file backwards from the end

I’m trying to find the string containing the substring in a text file by starting at the end. The file has tens of millions of lines. (The requirement is to read from End of the File. I cannot use sed/awk/grep etc) The below program does the job but it takes a long time. How can I make it run faster?

Retrieve logged on user name or id in the process running under root

I need to run from a privileged (root) application another application with current logged on user. getenv(“USER”) and getenv(“LOGNAME”) return “root” in the privileged application. Effective and current user ids are 0. I found something close to my needs, user-1000.slice, but I would like to avoid using fscanf on the file /proc/self/cgroup. The code bellow outputs 1000 as desired. Is

how to get rid of the “unknown” section in the perf

what I did is: then I get a tiny part of “unknown”, like looks this is due to libc ‘malloc’ call. then I write a program on the same machine to test it. then I did the same thing as above, there is no “unknown” section. how to explain/fix this? Answer The [unknown] block in the perf report output refers

Will process load into memory with 4 or 8 alignment rule

I just learnt about 4 or 8 memory alignment and came about this question. Will Memory alignment happen in virtual memory space or absolute addresss? I guess the answer is virtual memory spaceļ¼Œ and the os will load the process to the position that the absolute address ends with ‘0X00’ or ‘0X0’. If not, please show me why. Thanks a

Parent/Child and pipes in C, child-parent comunication

I have a parent program that sends a integer to a child, and the child program multiplies the number by two and gives back to the parent. In a main program I create a pipe and fork() and execl() the child, after a switch I pass the value through pip to child in child i can get the value, but

Advertisement