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.
Tag: c++
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
Calling printf() in assembly causes a ‘floating point exception’
I have the following code: I compile it with nasm -f elf64 1.asm and link it using ld -dynamic-linker /lib/ld-linux-x86-64.so.2 1.o -o 1 -lc. When I execute the binary, I get printf() doesn’t always fail when I call it in assembly code. Removing printf() calls from printax and printbx gives me Update: The exception also disappears if I remove the
Undefined symbols for architecture x86_64: “_read_line”, referenced from: _insert in inventory-82371b.o
Here is the callback with -v and warnings suppressed. Here it is without warnings suppressed. But I don’t believe that they are causing the issue. Here is the code. It is a program for a very simple data base from a text book. I truly believe my problem is with the compiling. It’s been a while since I’ve used gcc
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
Is there any random generator library except rand(), which developer can manually set the seed?
I want to verify that if the seed is same, the resulting pseudo random number is same. Using rand() is the simplest but I’m looking for safer way. I found that using device entropy with /dev/random of linux is very reliable but cannot find how to set exact same seed. I also tried cryptgenrandom of window but cannot find the