示例#1
0
文件: suite.c 项目: Abioy/oceanbase
ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset)
{
  if (real_pwrite == NULL) __mtrace_init();
  struct stat st;
  if (fstat(fd, &st) == 0)
  {
    /*
    char buf[BUFSIZ];
    int len = snprintf(buf, BUFSIZ, "pwrite fd=%d st_mode=%X\n", fd, st.st_mode);
    int wl = real_write(test_fd, buf, len);
    if (wl != len)
    {
      fprintf(stderr, "log write error: %s\n", strerror(errno));
    }
    fsync(test_fd);
    */
    if (S_ISREG(st.st_mode))
    {
      int64_t st = get_sleep_time();
      if (st > 0)
      {
        usleep(st);
      }
    }
  }
  return real_pwrite(fd, buf, count, offset);
}
示例#2
0
ssize_t pwrite(int fd, void *buf, size_t size, off_t ofs)
{
    if (smbw_fd(fd)) {
        return smbw_pwrite(fd, buf, size, ofs);
    }

    return real_pwrite(fd, buf, size, ofs);
}
示例#3
0
ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset) {
	if (nfs_fd_list[fd].is_nfs == 1) {
		int ret;

		LD_NFS_DPRINTF(9, "pwrite(fd:%d offset:%d count:%d)", fd,
			(int)offset, (int)count);
		if ((ret = nfs_pwrite(nfs_fd_list[fd].nfs, nfs_fd_list[fd].fh,
				offset, count,
				(char *)discard_const(buf))) < 0) {
			errno = -ret;
			return -1;
		}
		return ret;
	}
	return real_pwrite(fd, buf, count, offset);
}
示例#4
0
ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset) {
	if ((iscsi_fd_list[fd].is_iscsi == 1 && iscsi_fd_list[fd].in_flight == 0)) {
		off_t old_offset;
		if ((old_offset = lseek(fd, 0, SEEK_CUR)) < 0) {
			errno = EIO;
			return -1;
		}
		if (lseek(fd, offset, SEEK_SET) < 0) {
			return -1;
		}
		if (write(fd, buf, count) < 0) {
			lseek(fd, old_offset, SEEK_SET);
			return -1;
		}
		lseek(fd, old_offset, SEEK_SET);
		return count;
	}
	return real_pwrite(fd, buf, count, offset);
}