Example #1
0
ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset)
{
	orig_pwrite_type orig_pwrite;
	orig_pwrite = (orig_pwrite_type)dlsym(RTLD_NEXT,"pwrite"); 


		clock_t start = clock();

		ssize_t temp = orig_pwrite(fd,buf,count,offset);

		clock_t end = clock();

		double start_diff = ((double)(start-program_start))/(double)CLOCKS_PER_SEC;
		double end_diff = ((double)(end-program_start))/(double)CLOCKS_PER_SEC;
		printf("%lf %lf PWrite Called \n", start_diff, end_diff);
		return temp;
}
Example #2
0
ssize_t pwrite(int fd, const void *buf, size_t count,off_t offset)
{
  int size;
  int size_t_count=count;
  orig_pwrite_f_type orig_pwrite;
  //int gettimeofday(struct timeval *tv, struct timezone *tz);
  struct timeval tv0;
  struct timeval tv1;
  struct timezone tz;
  //mtx.lock();
  orig_pwrite  = (orig_pwrite_f_type)dlsym(RTLD_NEXT,"pwrite");

  gettimeofday(&tv0,&tz);
  size=orig_pwrite(fd,buf,count,offset);
  gettimeofday(&tv1,&tz);

  std::string str;
  std::ostringstream oss;
  oss << "pwrite(" << fd << "," << buf << "," << count << ")\n"; 
  log.add(oss.str());


  if (size>=0)
    {
      if (myiio.existFd(fd)==-1)
	{
	  Ifile ifi;
	  ifi.setFd(fd);
	  ifi.setName(std::string("UNKNOWN-PWRITE"));
	  ifi.setState(IOBYFILE_WRITE);
	  myiio.iiof.push_back(ifi);
	}
      add_write_count(fd,size);
      add_write_time(fd,tv0,tv1);
    }
  //mtx.unlock();
  return size;
}