previous: >>108779335
#define __NR_remap_file_pages 216
https://man7.org/linux/man-pages/man2/remap_file_pages.2.html
tl;dr:
remaps file pages (lol)
relatively useless, but it still exists. what a shocker, lol
kind of fun in that you can make it print out some stuff in dmesg
pr_warn_once("%s (%d) uses deprecated remap_file_pages() syscall. See Documentation/mm/remap_file_pages.rst.\n",
current->comm, current->pid);
from https://elixir.bootlin.com/linux/v7.0.5/source/mm/mmap.c#L1096
i guess i can give you the code to do it, too, since i'm so nice and amazing. apologies in advance for any formatting errors; i'm a dirty phoneposter
#define _GNU_SOURCE
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <unistd.h>
int main()
{
const int rw = PROT_READ | PROT_WRITE;
const int sa = MAP_SHARED | MAP_ANONYMOUS;
const size_t ps = getpagesize();
int ret = -1;
void *map = MAP_FAILED;
map = mmap(NULL, ps, rw, sa, -1, 0);
if (map == MAP_FAILED)
{
printf("mmap failed: %d (%s)\n", errno, strerror(errno));
return -1;
}
ret = remap_file_pages(map, ps, 0, 0, 0);
if (ret != 0)
{
printf("remap_file_pages failed: %d (%s)\n", errno, strerror(errno));
return -1;
}
return 0;
}
amusingly, you'll notice that despite being named remap_file_pages, this function worked on the shared anonymous mapping that i created. does anyone know the reason why this is? i'll hold off on giving the answer for now, in the hope that it might generate some discussion. but i'm happy to do so if people are unable to figure it out, though i have full confidence that /g/ is smart enough to manage this
relevant resources:
man man
man syscalls
https://man7.org/linux/man-pages/
https://linux.die.net/man/
https://elixir.bootlin.com/linux/
https://elixir.bootlin.com/musl/
https://elixir.bootlin.com/glibc/