#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;
}

