[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: GIBdWTkXcAAzSqH.jpg (661 KB, 1757x2048)
661 KB JPG
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/
>>
kys
>>
>>108786358
are there any interesting syscalls left to talk about? this one's boring
>>
>>108786358
>despite being named remap_file_pages, this function worked on the shared anonymous mapping
Are you saying it shouldn't work because this mapping isn't backed by any file? I think it might have to do with https://man7.org/linux/man-pages/man5/tmpfs.5.html
Also wtf is this captcha, am I posting on an anonymous message board or joining Mensa?
>>
>>108786690
>I think it might have to do with https://man7.org/linux/man-pages/man5/tmpfs.5.html
that's pretty close to the right answer!
>>
bampu
>>
>>108786358
Me on the (upper) right and (lower) left.
>>
>>108786647
The real purpose of the threads are to ERP so no worries.
>>
>>108786647
They're all boring.
>>
>>108788706
did you ppl do kexec yet?



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.