/[scripts]/trunk/uncache.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/uncache.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 142 - (show annotations)
Sun Dec 26 13:44:02 2010 UTC (12 years, 1 month ago) by dpavlin
File MIME type: text/plain
File size: 762 byte(s)
http://bazaar.launchpad.net/%7Edomas-mituzas/%2Bjunk/uncache/download/head%3A/uncache.c-20090626103028-ehcytih27ou9g5gx-1/uncache.c
1 /* This program removes specified (or current) directory/file from Linux filesystem cache */
2 #define _GNU_SOURCE
3 #define _XOPEN_SOURCE 600
4
5 #include <unistd.h>
6 #include <stdlib.h>
7 #include <string.h>
8 #include <stdio.h>
9 #include <fts.h>
10 #include <fcntl.h>
11
12 int main(int ac, char ** av) {
13 FTS * tree;
14 FTSENT * node;
15
16 char **paths = malloc(ac*sizeof(char*));
17 memcpy(paths,av+1,(ac-1)*sizeof(char*));
18 paths[ac]=NULL;
19 if (ac<2) paths[0]=getcwd(NULL,0);
20
21 tree=fts_open(paths,FTS_LOGICAL|FTS_NOCHDIR,NULL);
22 while((node=fts_read(tree))) {
23 int fd;
24 if (node->fts_info != FTS_F) continue;
25 fd=open(node->fts_path,O_DIRECT);
26 posix_fadvise(fd,0,0,POSIX_FADV_DONTNEED);
27 close(fd);
28 }
29 fts_close(tree);
30 if (ac<2) free(paths[0]);
31 free(paths);
32 return(0);
33 }
34

  ViewVC Help
Powered by ViewVC 1.1.26