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
5ae3cb45
Commit
5ae3cb45
authored
Feb 05, 2012
by
Julius Plenz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cachedel: remove file from fs cache
parent
1afccbcc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
0 deletions
+45
-0
Makefile
Makefile
+1
-0
cachedel.c
cachedel.c
+44
-0
No files found.
Makefile
View file @
5ae3cb45
default
:
gcc
-Wall
-o
cachestats cachestats.c
gcc
-Wall
-o
cachedel cachedel.c
gcc
-Wall
-fPIC
-c
-o
nocache.o nocache.c
gcc
-Wall
-fPIC
-c
-o
fcntl_helpers.o fcntl_helpers.c
gcc
-Wall
-shared
-Wl
,-soname,nocache.so.1
-ldl
-o
nocache.so nocache.o fcntl_helpers.o
cachedel.c
0 → 100644
View file @
5ae3cb45
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <error.h>
#include <stdio.h>
#include <stdlib.h>
int
exiterr
(
const
char
*
s
)
{
perror
(
s
);
exit
(
-
1
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
fd
;
struct
stat
st
;
if
(
argc
!=
2
)
{
fprintf
(
stderr
,
"usage: %s <file> "
"-- call fadvise(DONTNEED) on file"
,
argv
[
0
]);
exit
(
1
);
}
fd
=
open
(
argv
[
1
],
O_RDONLY
);
if
(
fd
==
-
1
)
exiterr
(
"open"
);
if
(
fstat
(
fd
,
&
st
)
==
-
1
)
exiterr
(
"fstat"
);
if
(
!
S_ISREG
(
st
.
st_mode
))
{
fprintf
(
stderr
,
"%s: S_ISREG: not a regular file"
,
argv
[
1
]);
return
EXIT_FAILURE
;
}
if
(
st
.
st_size
==
0
)
{
fprintf
(
stderr
,
"%s: file size is 0!
\n
"
,
argv
[
1
]);
return
EXIT_FAILURE
;
}
if
(
posix_fadvise
(
fd
,
0
,
0
,
POSIX_FADV_DONTNEED
)
==
-
1
)
exiterr
(
"posix_fadvise"
);
return
EXIT_SUCCESS
;
}
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