Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nocache
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Danil Mikhailov
nocache
Commits
ad8dbb81
Commit
ad8dbb81
authored
Feb 06, 2012
by
Julius Plenz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handle dup(), too
parent
8c589dd5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
nocache.c
nocache.c
+13
-0
No files found.
nocache.c
View file @
ad8dbb81
...
...
@@ -12,6 +12,7 @@
int
(
*
_original_open
)(
const
char
*
pathname
,
int
flags
,
mode_t
mode
);
int
(
*
_original_creat
)(
const
char
*
pathname
,
int
flags
,
mode_t
mode
);
int
(
*
_original_openat
)(
int
dirfd
,
const
char
*
pathname
,
int
flags
,
mode_t
mode
);
int
(
*
_original_dup
)(
int
fd
);
int
(
*
_original_close
)(
int
fd
);
void
init
(
void
)
__attribute__
((
constructor
));
...
...
@@ -28,6 +29,7 @@ int openat64(int dirfd, const char *pathname, int flags, mode_t mode)
__attribute__
((
alias
(
"openat"
)));
int
__openat_2
(
int
dirfd
,
const
char
*
pathname
,
int
flags
,
mode_t
mode
)
__attribute__
((
alias
(
"openat"
)));
int
dup
(
int
oldfd
);
int
close
(
int
fd
);
static
void
store_pageinfo
(
int
fd
);
...
...
@@ -58,6 +60,7 @@ void init(void)
dlsym
(
RTLD_NEXT
,
"creat"
);
_original_openat
=
(
int
(
*
)(
int
,
const
char
*
,
int
,
mode_t
))
dlsym
(
RTLD_NEXT
,
"openat"
);
_original_dup
=
(
int
(
*
)(
int
))
dlsym
(
RTLD_NEXT
,
"dup"
);
_original_close
=
(
int
(
*
)(
int
))
dlsym
(
RTLD_NEXT
,
"close"
);
PAGESIZE
=
getpagesize
();
for
(
i
=
0
;
i
<
_MAX_FDS
;
i
++
)
...
...
@@ -99,6 +102,16 @@ int openat(int dirfd, const char *pathname, int flags, mode_t mode)
return
fd
;
}
int
dup
(
int
oldfd
)
{
int
fd
;
if
((
fd
=
_original_dup
(
oldfd
))
!=
-
1
)
{
fprintf
(
stderr
,
"dup()! old=%d, new=%d
\n
"
,
oldfd
,
fd
);
store_pageinfo
(
fd
);
}
return
fd
;
}
int
close
(
int
fd
)
{
free_unclaimed_pages
(
fd
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment