Search
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
LTTng-modules
All Projects
LTTng
»
LTTng-modules
Overview
Activity
Roadmap
Issues
Gantt
Calendar
News
Repository
Download (934 Bytes)
Bug #1261
ยป open-fault.c
Mathieu Desnoyers
, 02/12/2021 09:52 AM
#include
<sys/types.h>
#include
<sys/stat.h>
#include
<fcntl.h>
#include
<stdint.h>
#include
<syscall.h>
#include
<unistd.h>
#include
<sys/mman.h>
#include
<stdio.h>
#include
<error.h>
#include
<stdlib.h>
#include
<string.h>
#define NAME_FILE "/tmp/filefile1"
#define PATH_STR "/tmp/filefile2"
int
main
()
{
int
ret
;
int
fd
;
char
*
name
;
ssize_t
len
;
fd
=
open
(
NAME_FILE
,
O_RDWR
|
O_CREAT
|
O_TRUNC
,
S_IRUSR
|
S_IWUSR
,
0700
);
if
(
fd
<
0
)
{
perror
(
"open1"
);
abort
();
}
len
=
write
(
fd
,
PATH_STR
,
strlen
(
PATH_STR
)
+
1
);
if
(
len
<
strlen
(
PATH_STR
)
+
1
)
{
abort
();
}
/* mmap the name file which will be used as input string for openat
* filename parameter, triggering a page fault because the pages of this
* mapping are not populated in the page cache.
*/
name
=
mmap
(
NULL
,
4096
,
PROT_READ
|
PROT_WRITE
,
MAP_PRIVATE
,
fd
,
0
);
if
(
name
==
MAP_FAILED
)
{
perror
(
"mmap"
);
abort
();
}
openat
(
42
,
name
,
0
,
0
);
}
(1-1/1)
Loading...