1 /* SPDX-License-Identifier: GPL-2.0 */
8 #define MLOCK_ONFAULT 1
12 #define MCL_ONFAULT (MCL_FUTURE << 1)
15 static int mlock2_(void *start
, size_t len
, int flags
)
18 return syscall(__NR_mlock2
, start
, len
, flags
);
25 static FILE *seek_to_smaps_entry(unsigned long addr
)
30 unsigned long start
, end
;
37 file
= fopen("/proc/self/smaps", "r");
39 perror("fopen smaps");
43 while (getline(&line
, &size
, file
) > 0) {
44 if (sscanf(line
, "%lx-%lx %s %lx %s %lu %s\n",
45 &start
, &end
, perms
, &offset
, dev
, &inode
, path
) < 6)
48 if (start
<= addr
&& addr
< end
)