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
477e69c8
Commit
477e69c8
authored
Feb 08, 2012
by
Julius Plenz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
little code cleanup
parent
fd9969ec
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
27 deletions
+24
-27
fcntl_helpers.h
fcntl_helpers.h
+8
-0
nocache.c
nocache.c
+16
-27
No files found.
fcntl_helpers.h
0 → 100644
View file @
477e69c8
#ifndef _FCNTL_HELPERS_H
#define _FCNTL_HELPERS_H
extern
int
fadv_dontneed
(
int
fd
,
off_t
offset
,
off_t
len
);
extern
int
fadv_noreuse
(
int
fd
,
off_t
offset
,
off_t
len
);
extern
int
valid_fd
(
int
fd
);
extern
void
sync_if_writable
(
int
fd
);
extern
int
fcntl_dupfd
(
int
fd
,
int
arg
);
#endif
nocache.c
View file @
477e69c8
...
...
@@ -9,18 +9,16 @@
#include <string.h>
#include <pthread.h>
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_dup2
)(
int
newfd
,
int
oldfd
);
int
(
*
_original_close
)(
int
fd
);
#include "fcntl_helpers.h"
static
void
init
(
void
)
__attribute__
((
constructor
));
static
void
destroy
(
void
)
__attribute__
((
destructor
));
static
void
init_mutex
(
void
);
static
void
handle_stdout
(
void
);
static
void
store_pageinfo
(
int
fd
);
static
void
free_unclaimed_pages
(
int
fd
);
int
open
(
const
char
*
pathname
,
int
flags
,
mode_t
mode
);
int
open64
(
const
char
*
pathname
,
int
flags
,
mode_t
mode
)
__attribute__
((
alias
(
"open"
)));
...
...
@@ -36,14 +34,12 @@ int dup(int oldfd);
int
dup2
(
int
oldfd
,
int
newfd
);
int
close
(
int
fd
);
static
void
store_pageinfo
(
int
fd
);
static
void
free_unclaimed_pages
(
int
fd
);
extern
int
fadv_dontneed
(
int
fd
,
off_t
offset
,
off_t
len
);
extern
int
fadv_noreuse
(
int
fd
,
off_t
offset
,
off_t
len
);
extern
int
valid_fd
(
int
fd
);
extern
void
sync_if_writable
(
int
fd
);
extern
int
fcntl_dupfd
(
int
fd
,
int
arg
);
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_dup2
)(
int
newfd
,
int
oldfd
);
int
(
*
_original_close
)(
int
fd
);
#define _MAX_FDS 1024
...
...
@@ -120,36 +116,32 @@ static void destroy(void)
int
open
(
const
char
*
pathname
,
int
flags
,
mode_t
mode
)
{
int
fd
;
if
((
fd
=
_original_open
(
pathname
,
flags
,
mode
))
!=
-
1
)
{
if
((
fd
=
_original_open
(
pathname
,
flags
,
mode
))
!=
-
1
)
store_pageinfo
(
fd
);
}
return
fd
;
}
int
creat
(
const
char
*
pathname
,
int
flags
,
mode_t
mode
)
{
int
fd
;
if
((
fd
=
_original_creat
(
pathname
,
flags
,
mode
))
!=
-
1
)
{
if
((
fd
=
_original_creat
(
pathname
,
flags
,
mode
))
!=
-
1
)
store_pageinfo
(
fd
);
}
return
fd
;
}
int
openat
(
int
dirfd
,
const
char
*
pathname
,
int
flags
,
mode_t
mode
)
{
int
fd
;
if
((
fd
=
_original_openat
(
dirfd
,
pathname
,
flags
,
mode
))
!=
-
1
)
{
if
((
fd
=
_original_openat
(
dirfd
,
pathname
,
flags
,
mode
))
!=
-
1
)
store_pageinfo
(
fd
);
}
return
fd
;
}
int
dup
(
int
oldfd
)
{
int
fd
;
if
((
fd
=
_original_dup
(
oldfd
))
!=
-
1
)
{
if
((
fd
=
_original_dup
(
oldfd
))
!=
-
1
)
store_pageinfo
(
fd
);
}
return
fd
;
}
...
...
@@ -163,9 +155,8 @@ int dup2(int oldfd, int newfd)
if
(
valid_fd
(
newfd
))
free_unclaimed_pages
(
newfd
);
if
((
ret
=
_original_dup2
(
oldfd
,
newfd
))
!=
-
1
)
{
if
((
ret
=
_original_dup2
(
oldfd
,
newfd
))
!=
-
1
)
store_pageinfo
(
newfd
);
}
return
ret
;
}
...
...
@@ -183,9 +174,7 @@ static void store_pageinfo(int fd)
void
*
file
=
NULL
;
unsigned
char
*
pageinfo
=
NULL
;
if
(
fstat
(
fd
,
&
st
)
==
-
1
)
return
;
if
(
!
S_ISREG
(
st
.
st_mode
))
if
(
fstat
(
fd
,
&
st
)
==
-
1
||
!
S_ISREG
(
st
.
st_mode
))
return
;
/* Hint we'll be using this file only once;
...
...
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