initial check in

This commit is contained in:
2012-12-06 21:43:03 +04:00
commit 4bc273824d
179 changed files with 29415 additions and 0 deletions

49
util/unfreeze.cpp Normal file
View File

@@ -0,0 +1,49 @@
#include <iostream>
#include <cstring>
#include <cerrno>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/time.h>
using namespace std;
int main(int argc, char *argv[])
try
{
if (argc < 2)
throw string("Usage: ") + argv[0] + " <filenames>";
for( int i = 0; i < argc; ++i )
{
//
// Open the file and determint its size.
//
char *fileName = argv[1];
int fd = open(fileName, O_RDONLY);
if (fd < 0)
throw strerror(errno);
struct stat st;
if (fstat(fd, &st) < 0)
throw strerror(errno);
off_t fileSize = st.st_size;
//
// Request the system to unload the file from the page cache.
//
if (posix_fadvise(fd, 0, fileSize, POSIX_FADV_DONTNEED))
throw strerror(errno);
close(fd);
}
return 0;
}
catch (string str)
{
cout << str << endl;
return 1;
}
catch (const char *str)
{
cout << str << endl;
return 1;
}