I am creating share memory keys using ftok(). I want to create 500 share memory keys.As per man page of ftok() it is mentioned that low order 8 bits are significant. Does it mean that we can only generate 256 maximum share memory keys? If yes, Then how to generate more than 256 keys? Because in argument ftok() is defined
Tag: c++
Understanding the strcmp function of gnu libc
Here is the strcmp function that i found in the glibc: This is a pretty simple function where the body of while initiates c1 and c2 with the value of *s1 and *s2 and continues till either c1 is nul or the values of c1 and c2 are equal, then returns the difference between c1 and c2. What i didn’t
Finding mapped memory from inside a process
Setup: Ubuntu 18×64 x86_64 application Arbitrary code execution from inside the application I’m trying to write code which should be able to find structures in memory even with ASLR enabled. Sadly, I couldn’t find any static references to those regions, so I’m guessing I have to use the bruteforce way and scan the process memory. What I tried to do
LMDB: Open large databases in a limited memory system
I have a program that is projected to use a few GB of lmdb diskspace (it’s a blockchain, and we’re moving away from leveldb due to its lack of ACID, which I need for some future plans). Is it possible to run that program with that database on a Raspberry Pi without adding more swap (with >1 GB memory)? (considering
Understanding read syscall
I’m reading man read manual page and discovered that it was possible to read less then the desired number of bytes passed in as a parameter: It is not an error if this number is smaller than the number of bytes requested; this may happen for example because fewer bytes are actually available right now (maybe because we were close
Makefile, add headers located in parent directory (Not allowed to move inside!)
prog.c myheader1.h myheader2.h Looking for solution on how to add a header from parent directory I found this question. But it didn’t work for me and I am still getting error of not finding the header file. No rule to make target ‘myheader1.h’, needed by ‘prog.o’. Stop. makefile What am I doing incorrect? and how to add the second header
Timing/Clocks in the Linux Kernel
I am writing a device driver and want to benchmark a few pieces of code to get a feel for where I could be experiencing some bottlenecks. As a result, I want to time a few segments of code. In userspace, I’m used to using clock_gettime() with CLOCK_MONOTONIC. Looking at the kernel sources (note that I am running kernel 4.4,
Linux C program: How to find the library to which a function belongs
Say at runtime, I want to find out where a function “printf” is defined. How would I do this? My first attempt was to print out the address of “printf” and compare it against the virtual address mapping of the process: my program: output: However, this says the function is defined in my own program! Shouldnt it be a call
C – in recursive function remove() dont work
obviating if the recursive function is well constructed or not, when i call the function on a directory Folder/file.txt. this code should delete file.txt, but when it reaches to remove dont work, and i dont know for what… Answer Reading the man page on readdir, it returns in d_name a file name, not a complete path, but remove and rmdir
fork() – have parent process do work without waiting for child process
I’m making a shell in C for a school project that is capable of running processes in parallel if it is commanded to do so. This is the loop of the shell application that waits for commands: Please do disregard the constants being incremented and decremented. Now, this only works partially. Whenever I give it a command to create another