Blast-Radius Aware AI Code Review for Business-Critical Systems
LiveReview LiveReview Explore LiveReview

mmap_shared - memory map a file for reading and writing

Description

       mmap_shared  opens  filename  for  reading and writing, maps the whole file into memory, closes the file,
       writes the length of the file to filesize and returns a pointer to the mapped file.

       The file is mapped shared.  Changes done to the mapped region are written to  disk  and  are  visible  to
       other processes reading from the file or mapping the same file into memory.

       The file is unmapped by the operating system if the process terminates.  It can also be manually unmapped
       by calling munmap from <sys/mman.h>.

       To write changes to disk immediately, you can use msync from <sys/mman.h>.

       If the file could not be opened or mapped, (void*)0 is returned.

Name

       mmap_shared - memory map a file for reading and writing

See Also

mmap_unmap(3), msync(2)

                                                                                                  mmap_shared(3)

Syntax

#include<libowfat/mmap.h>

       char* mmap_shared(const char* filename,size_t* filesize);

See Also