Questions tagged [mmap]

mmap is a POSIX-compliant Unix system call that maps files or devices into memory.

mmap() creates a new mapping in the virtual address space of the calling process.

https://en.wikipedia.org/wiki/Mmap

1936 questions
0
votes
1 answer

mmap() in Linux - a part of the file vs the whole file

Would this statement be true or false? I was told conflicting information in regards to mmap() and now I am unsure. A program can memory map only a part of file rather than the whole file in Linux using mmap().
0
votes
2 answers

mmap invalid argument - reading multiple files from command line and writing to one output file

I am writing a C program that takes more than one file from the command line and combines them into one output file. If the output file is not given, it is created. I copy the file content by using mmap. However, when I run the following code, I get…
0
votes
2 answers

getting SEGFAULT when reading an array from shared memory

I'm new to using shared memory and for the first file the implementation is working fine but for the second file it is unable to read some of the structures from the shared memory . I think the problem is in my mmap but not quite sure what…
Kaspercold 1
  • 35
  • 1
  • 6
0
votes
1 answer

Memcpy segmentation fault even when memory is allocated

I'm attempting to copy the data from one file by writing it to memory and then copy it into another using memcpy but I'm stumped. I cannot get it to stop giving me segmentation fault. I have a feeling it has something to do with the allocated…
Zlorpo123
  • 47
  • 1
  • 6
0
votes
1 answer

How to clear mmap Byte Array in python

I am trying to use mmap to share data between two python scripts. I want to clear the buffer after each write. How to it? for example: import mmap from time import sleep while true: a=mmap.mmap(0, 200, 'GlobalSharedMemory') inp =…
mj1261829
  • 1,200
  • 3
  • 26
  • 53
0
votes
1 answer

Linux memory mapped file consuming more disk than expected

Context: I'm using memory mapped file in my code created using ACE_Mem_Map. It is observed that the memory mapped file is consuming more disk space than expected. Scenario: I have a structure containing a char array of 15KB. I have created a memory…
Aman Gupta
  • 21
  • 6
0
votes
1 answer

Why os allocate empty segment before pthread stack?

In my program I create simple pthread to explore how it will look like in memory and what system calls will be called: void *foo() { printf("test"); } int main() { pthread_t a; pthread_create(&a, NULL, foo, NULL); pthread_join(a,…
0
votes
1 answer

mmap() slower than ofstream() for writing large amounts of data

I am currently working on a project which requires writing a large amount of data (i.e. hundreds of gigabytes) to a file by using a server that has 32 cores and 64 GB of RAM. Basically, I am trying to figure out what is the most efficient way to do…
PleaseHelpppp
  • 75
  • 1
  • 6
0
votes
0 answers

mmap flag ‘MAP_FIXED_NOREPLACE’ undeclared even with a supported kernel

I'm trying to build an application which uses the MAP_FIXED_NOREPLACE mmap flag. From the man page, it seems that the flag is supported since linux kernel 4.17. I currently have 5.4.0-53-generic installed on my Ubuntu 18.04.5 system. When I try to…
nsane
  • 1,715
  • 4
  • 21
  • 31
0
votes
0 answers

Modify a struct in shared memory

i'm tryng to create a pointer-based queue in shared memory This my enqueue function void enqueue(queue *q, int k) { _queueNode *temp = mmap(NULL, sizeof(_queueNode), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0); temp->key =…
André Kuljis
  • 90
  • 1
  • 9
0
votes
1 answer

mmap syscall fails with errno 14

I was trying to do a syscall injection with MMAP on another process and it was failing. I noticed the syscall was executing properly, so the problem should be something else. I decided to run the syscall directly through the target program to make…
rdbo
  • 144
  • 10
0
votes
0 answers

Using mremap(..., MREMAP_FIXED) with valgrind

Consider this approach to implement a wrapping buffer: #define _GNU_SOURCE #include #include #include #include static int wrapping_buffer(void) { char *b1, *b2; long size; size =…
uncleremus
  • 317
  • 1
  • 11
0
votes
1 answer

How to read structs properly

I hope someone can help me. I'm trying to read file that consists of some amount of structs from below: struct query { int key; char surname[16]; char name[16]; char patronymic[16]; char subject[16]; int grade; }s; I need to…
0
votes
0 answers

what is the use of using shm_open and mmap together?

After reading the man pages I understood that shm_open and shm_unlink are basically analogous to mmap and munmap, with the difference being that shm is for System V and mmap is for POSIX. Since both can be used for sharing memory, is there an…
qwerty_99
  • 640
  • 5
  • 20
0
votes
1 answer

Why InnoDB does use buffer pool, not mmap entire file?

The InnoDB uses buffer bool of configurable size to store last recently used pages (b+tree blocks). Why not mmap the entire file instead? Yes, this does not work for changed pages, because you want to store them in double write buffer before writing…
pavelkolodin
  • 2,859
  • 3
  • 31
  • 74