• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ pwrite64函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中pwrite64函数的典型用法代码示例。如果您正苦于以下问题:C++ pwrite64函数的具体用法?C++ pwrite64怎么用?C++ pwrite64使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了pwrite64函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: write_note

static int
write_note(int fd, uint_t type, const void *desc, size_t descsz, off64_t *offp)
{
	/*
	 * Note headers are the same regardless of the data model of the
	 * ELF file; we arbitrarily use Elf64_Nhdr here.
	 */
	struct {
		Elf64_Nhdr nhdr;
		char name[8];
	} n;

	bzero(&n, sizeof (n));
	bcopy("CORE", n.name, 4);
	n.nhdr.n_type = type;
	n.nhdr.n_namesz = 5;
	n.nhdr.n_descsz = roundup(descsz, 4);

	if (pwrite64(fd, &n, sizeof (n), *offp) != sizeof (n))
		return (-1);

	*offp += sizeof (n);

	if (pwrite64(fd, desc, n.nhdr.n_descsz, *offp) != n.nhdr.n_descsz)
		return (-1);

	*offp += n.nhdr.n_descsz;

	return (0);
}
开发者ID:apprisi,项目名称:illumos-gate,代码行数:30,代码来源:Pgcore.c


示例2: LoadSwapFile2D

// FlowField2D constructor
int FlowField2D::SaveFlowField2D(char* filename){
    int   fd_g,pf;
    ostream*     o_stream = &cout;
    ofstream*    f_stream = (ofstream*)(o_stream);
    
    ssize_t max_write = 1024L*1024L*1024L;                                                                                                      
    ssize_t one_write = 0L;                                                                                                                     
    ssize_t len  = 0L;                                                                                                                        
    off_t  off = 0L;                                                                                                                           
    LoadSwapFile2D(filename,GetX(),GetY(),sizeof(FlowNode2D< FP, NUM_COMPONENTS>),&pf,&fd_g,f_stream);
    char*  TmpPtr=(char*)GetMatrixPtr();                                                                                                             
    if(GetMatrixSize() > max_write) {                                                                                                                 
        for(off = 0L,one_write = max_write; len < GetMatrixSize(); off += max_write) {                                                                
           len += pwrite64(fd_g,TmpPtr+off,one_write,off);                                                                                       
           if(GetMatrixSize() - len < max_write)                                                                                                      
             one_write = GetMatrixSize() - len;                                                                                                       
           }                                                                                                                                   
          if(len != GetMatrixSize())                                                                                                                    
          *f_stream << "Error: len(" << len << ") != MatrixSize(" << GetMatrixSize() << ") " << endl << flush;                                               
    } else {                                                                                                                                   
        len = pwrite64(fd_g,GetMatrixPtr(),GetMatrixSize(),0L);                                                                                               
    }
    close(fd_g);
    return len;
}
开发者ID:BOuissem,项目名称:openhyperflow2d,代码行数:26,代码来源:hyper_flow_field.cpp


示例3: fusecow_write

static int fusecow_write(const char *path, const char *buf, size_t size,
                     off64_t offset, struct fuse_file_info *fi)
{
    (void) fi;

    long long int block_number = offset / block_size;
    if(offset + size > (block_number+1)*block_size) {
	size = (block_number+1)*block_size - offset; // write only one block. write_safe will care
    }

    int res;
    if(write_map_get(block_number)) {
	res=pwrite64(fd_write, buf, size, offset);
    } else {
	int remaining = block_size;
	while(remaining) {
	    res=pread64(fd, copyup_buffer + block_size - remaining, remaining, block_number*block_size);
	    if(res==0) {
		memset(copyup_buffer + block_size - remaining, 0, remaining);
		break;
	    }
	    if(res==-1) {
		if(errno==EINTR) continue;
		return -errno;
	    }
	    remaining -= res;
	}

	memcpy(copyup_buffer+offset%block_size, buf, size);

	remaining=block_size;
	while(remaining) {
	    fprintf(stderr, "Performing write at offset %lld\n", block_number*block_size);
	    res=pwrite64(fd_write, copyup_buffer + block_size - remaining, remaining, block_number*block_size);
	    if(res==-1) {
		if(errno==EINTR) continue;
		return -errno;
	    }
	    remaining -= res;
	}

    write_map_set(block_number, 1);

	res = size;
    }

    if (res == -1) {
        res = -errno;
    } 

    return res;
}
开发者ID:dellastreet,项目名称:fusecoraw,代码行数:52,代码来源:fusecoraw.c


示例4: write_shdr

static int
write_shdr(pgcore_t *pgc, shstrtype_t name, uint_t type, ulong_t flags,
    uintptr_t addr, ulong_t offset, size_t size, uint_t link, uint_t info,
    uintptr_t addralign, uintptr_t entsize)
{
	if (pgc->P->status.pr_dmodel == PR_MODEL_ILP32) {
		Elf32_Shdr shdr;

		bzero(&shdr, sizeof (shdr));
		shdr.sh_name = shstrtab_ndx(&pgc->pgc_shstrtab, name);
		shdr.sh_type = type;
		shdr.sh_flags = flags;
		shdr.sh_addr = (Elf32_Addr)addr;
		shdr.sh_offset = offset;
		shdr.sh_size = size;
		shdr.sh_link = link;
		shdr.sh_info = info;
		shdr.sh_addralign = addralign;
		shdr.sh_entsize = entsize;

		if (pwrite64(pgc->pgc_fd, &shdr, sizeof (shdr),
		    *pgc->pgc_soff) != sizeof (shdr))
			return (-1);

		*pgc->pgc_soff += sizeof (shdr);
#ifdef _LP64
	} else {
		Elf64_Shdr shdr;

		bzero(&shdr, sizeof (shdr));
		shdr.sh_name = shstrtab_ndx(&pgc->pgc_shstrtab, name);
		shdr.sh_type = type;
		shdr.sh_flags = flags;
		shdr.sh_addr = addr;
		shdr.sh_offset = offset;
		shdr.sh_size = size;
		shdr.sh_link = link;
		shdr.sh_info = info;
		shdr.sh_addralign = addralign;
		shdr.sh_entsize = entsize;

		if (pwrite64(pgc->pgc_fd, &shdr, sizeof (shdr),
		    *pgc->pgc_soff) != sizeof (shdr))
			return (-1);

		*pgc->pgc_soff += sizeof (shdr);
#endif	/* _LP64 */
	}

	return (0);
}
开发者ID:apprisi,项目名称:illumos-gate,代码行数:51,代码来源:Pgcore.c


示例5: write_dev_supers

int write_dev_supers(struct btrfs_root *root, struct btrfs_super_block *sb,
		     struct btrfs_device *device)
{
	u64 bytenr;
	u32 crc;
	int i, ret;

	if (root->fs_info->super_bytenr != BTRFS_SUPER_INFO_OFFSET) {
		btrfs_set_super_bytenr(sb, root->fs_info->super_bytenr);
		crc = ~(u32)0;
		crc = btrfs_csum_data(NULL, (char *)sb + BTRFS_CSUM_SIZE, crc,
				      BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE);
		btrfs_csum_final(crc, (char *)&sb->csum[0]);

		/*
		 * super_copy is BTRFS_SUPER_INFO_SIZE bytes and is
		 * zero filled, we can use it directly
		 */
		ret = pwrite64(device->fd, root->fs_info->super_copy,
				BTRFS_SUPER_INFO_SIZE,
				root->fs_info->super_bytenr);
		BUG_ON(ret != BTRFS_SUPER_INFO_SIZE);
		return 0;
	}

	for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) {
		bytenr = btrfs_sb_offset(i);
		if (bytenr + BTRFS_SUPER_INFO_SIZE > device->total_bytes)
			break;

		btrfs_set_super_bytenr(sb, bytenr);

		crc = ~(u32)0;
		crc = btrfs_csum_data(NULL, (char *)sb + BTRFS_CSUM_SIZE, crc,
				      BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE);
		btrfs_csum_final(crc, (char *)&sb->csum[0]);

		/*
		 * super_copy is BTRFS_SUPER_INFO_SIZE bytes and is
		 * zero filled, we can use it directly
		 */
		ret = pwrite64(device->fd, root->fs_info->super_copy,
				BTRFS_SUPER_INFO_SIZE, bytenr);
		BUG_ON(ret != BTRFS_SUPER_INFO_SIZE);
	}

	return 0;
}
开发者ID:AK47POMA,项目名称:btrfs-progs,代码行数:48,代码来源:disk-io.c


示例6: osd_write

file_error osd_write(osd_file *file, const void *buffer, UINT64 offset, UINT32 count, UINT32 *actual)
{
	UINT32 result;

   switch (file->type)
   {
      case SDLFILE_FILE:
#if defined(SDLMAME_DARWIN) || defined(SDLMAME_BSD)
         result = pwrite(file->handle, buffer, count, offset);
         if (!result)
#elif defined(SDLMAME_WIN32) || defined(SDLMAME_NO64BITIO) || defined(SDLMAME_OS2) || defined(__CELLOS_LV2__)
         lseek(file->handle, (UINT32)offset&0xffffffff, SEEK_SET);
         result = write(file->handle, buffer, count);
         if (!result)
#elif defined(SDLMAME_UNIX)
         result = pwrite64(file->handle, buffer, count, offset);
         if (!result)
#else
#error Unknown SDL SUBARCH!
#endif
		return error_to_file_error(errno);

         if (actual != NULL)
            *actual = result;
         return FILERR_NONE;
         break;

      default:
         return FILERR_FAILURE;
    }
}
开发者ID:cdenix,项目名称:psmame,代码行数:31,代码来源:sdlfile.c


示例7: defined

void Driver_FILE::set_frame(const int frameid, const Frame& frame)
{
#if defined(__MACH__)
    pthread_mutex_lock(&spinlock);
#else
    pthread_spin_lock(&spinlock);
#endif
    
  if(objmask.find(frameid) != objmask.end()){
    // if in hash
#ifdef __MACH__
      ret = pwrite(fd, frame.content, this->framesize_in_byte, 1L*frameid*this->framesize_in_byte);
#else
      ret = pwrite64(fd, frame.content, this->framesize_in_byte, 1L*frameid*this->framesize_in_byte);
#endif
    if(ret < 0){
      assert(false && "Driver_FILE: fail to write in set()");
    }
  }else{
    assert(false && "Driver_FILE: key not in hash");
  }
    
#if defined(__MACH__)
    pthread_mutex_unlock(&spinlock);
#else
    pthread_spin_unlock(&spinlock);
#endif
}
开发者ID:zhangce,项目名称:deepdive,代码行数:28,代码来源:driver_file.cpp


示例8: assert

void Driver_FILE::add_frame(const int frameid)
{
  assert(frameid >= 0 && "Driver_FILE: only support INTEGER-many frames for now. If you want larger storage, please increase the framesize instead.");
#if defined(__MACH__)
  pthread_mutex_lock(&spinlock);
#else
  pthread_spin_lock(&spinlock);
#endif
    
  if(objmask.find(frameid) != objmask.end()){
    // if already contains the key, error
    assert(false && "Driver_FILE: duplicate key init'ed");
  }else{
    // else, insert using the default constructor
    objmask[frameid] = true;
  }
    
  #ifdef __MACH__
    ret = pwrite(fd, empty_frame.content, this->framesize_in_byte, 1L*frameid*this->framesize_in_byte);
  #else
    ret = pwrite64(fd, empty_frame.content, this->framesize_in_byte, 1L*frameid*this->framesize_in_byte);
  #endif
  
  if(ret < 0){
    assert(false && "Driver_FILE: fail to write in init()");
  }
    
#if defined(__MACH__)
    pthread_mutex_unlock(&spinlock);
#else
    pthread_spin_unlock(&spinlock);
#endif
}
开发者ID:zhangce,项目名称:deepdive,代码行数:33,代码来源:driver_file.cpp


示例9: pci_vfio_write_config

int
pci_vfio_write_config(const struct rte_intr_handle *intr_handle,
		    const void *buf, size_t len, off_t offs)
{
	return pwrite64(intr_handle->vfio_dev_fd, buf, len,
	       VFIO_GET_REGION_ADDR(VFIO_PCI_CONFIG_REGION_INDEX) + offs);
}
开发者ID:emmericp,项目名称:dpdk,代码行数:7,代码来源:eal_pci_vfio.c


示例10: zpool_clear_label

/*
 * Given a file descriptor, clear (zero) the label information.
 */
int
zpool_clear_label(int fd)
{
	struct stat statbuf;
	int l;
	vdev_label_t *label;
	uint64_t size;

	if (fstat_blk(fd, &statbuf) == -1)
		return (0);
	size = P2ALIGN_TYPED(statbuf.st_size, sizeof (vdev_label_t), uint64_t);

	if ((label = calloc(sizeof (vdev_label_t), 1)) == NULL)
		return (-1);

	for (l = 0; l < VDEV_LABELS; l++) {
		if (pwrite64(fd, label, sizeof (vdev_label_t),
		    label_offset(size, l)) != sizeof (vdev_label_t)) {
			free(label);
			return (-1);
		}
	}

	free(label);
	return (0);
}
开发者ID:cbreak-black,项目名称:zfs,代码行数:29,代码来源:libzfs_import.c


示例11: root_write

static int
root_write(vnode_t *vp, uio_t *uiop, int ioflag, cred_t *cr, caller_context_t *ct)
{
    ASSERT(vp->v_fd != -1);
    ASSERT(vp->v_type != VBLK || IS_P2ALIGNED(uiop->uio_loffset, 512));
    ASSERT(vp->v_type != VBLK || IS_P2ALIGNED(uiop->uio_iov->iov_len, 512));

    int error = 0;

    ssize_t iolen = pwrite64(vp->v_fd, uiop->uio_iov->iov_base, uiop->uio_iov->iov_len, uiop->uio_loffset);
    if(iolen == -1) {
        error = errno;
        perror("pwrite64");
    }

    if(iolen != uiop->uio_iov->iov_len)
        fprintf(stderr, "root_write(): len: %lli iolen: %lli offset: %lli file: %s\n", (longlong_t) uiop->uio_iov->iov_len, (longlong_t) iolen, (longlong_t) uiop->uio_loffset, vp->v_path);

    if(error)
        return error;

    uiop->uio_resid -= iolen;

    return 0;
}
开发者ID:zhihui-slash2,项目名称:slash2-stable,代码行数:25,代码来源:vnode.c


示例12: fusecow_write_safe

static int fusecow_write_safe(const char *path, const char *buf, size_t size,
                     off64_t offset, struct fuse_file_info *fi)
{
    int res=0;
    if(strcmp(path, "/") != 0)
        return -ENOENT;

    size_t remaining = size;

    while(remaining) {
	int ret=fusecow_write(path, buf+res, remaining, offset+res, fi);
	if(ret==0) {
	    break;
	}
	if(ret==-1) {
	    if(errno==EINTR) continue;
	    return -errno;
	}
	res+=ret;
	remaining-=ret;
    }
    
    if(offset+res > st_size) {
	fprintf(stderr, "Growing files is known to fail\n");
	return -ENOSPC;
	st_size = offset+res;
    if(mem_write_map!=MAP_FAILED) {
        memcpy(mem_write_map+8, &st_size, sizeof st_size);
	} else {
        pwrite64(fd_write_map, &st_size, sizeof st_size, 8);
	}
    }

    return res;
}
开发者ID:dellastreet,项目名称:fusecoraw,代码行数:35,代码来源:fusecoraw.c


示例13: write_map_set

void write_map_set(long long int block, char val) {
    long long int offset = 32 + block/8;    
    if((mem_write_map!=MAP_FAILED) && (offset > mem_write_map_size) ) {
    munmap(mem_write_map, mem_write_map_size);
    mem_write_map_size = (block/8/getpagesize()+1)*getpagesize();
    ftruncate(fd_write_map, mem_write_map_size);
    mem_write_map = mmap(NULL, mem_write_map_size , PROT_READ|PROT_WRITE, MAP_SHARED, fd_write_map, 0);
    }
    char c;
    if(mem_write_map!=MAP_FAILED) {
    c = mem_write_map[offset];
    } else {
        pread64(fd_write_map, &c, 1, offset);
    }

    char mask = 1 << (block%8);
    c &= ~mask;
    if(val) {
	c |= mask;
    }

    if(mem_write_map!=MAP_FAILED) {
    mem_write_map[offset]=c;
    } else {
        pwrite64(fd_write_map, &c, 1, offset);
    }

}
开发者ID:dellastreet,项目名称:fusecoraw,代码行数:28,代码来源:fusecoraw.c


示例14: write_block

static int write_block(int fd, void *buf, unsigned long block,
		unsigned long block_size)
{
	char		*b;
	off64_t		offset;
	unsigned long	remaining;
	ssize_t		rc;

	b		= buf;
	offset		= block * block_size;
	remaining	= block_size;

	while (remaining > 0) {
		rc = pwrite64(fd, b, remaining, offset);
		if (rc < 0) {
			if (errno == EINTR)
				continue;

			fprintf(stderr, "write failed: %s\n", strerror(errno));
			return -1;
		}

		b		+= rc;
		offset		+= rc;
		remaining	-= rc;
	}
	return 0;
}
开发者ID:prasad-joshi,项目名称:iob,代码行数:28,代码来源:psync.c


示例15: write_verity_state

static int write_verity_state(const char *fname, off64_t offset, int32_t mode)
{
    int fd;
    int rc = -1;
    struct verity_state s = { VERITY_STATE_HEADER, VERITY_STATE_VERSION, mode };

    fd = TEMP_FAILURE_RETRY(open(fname, O_WRONLY | O_SYNC | O_CLOEXEC));

    if (fd == -1) {
        PERROR << "Failed to open " << fname;
        goto out;
    }

    if (TEMP_FAILURE_RETRY(pwrite64(fd, &s, sizeof(s), offset)) != sizeof(s)) {
        PERROR << "Failed to write " << sizeof(s) << " bytes to " << fname
               << " to offset " << offset;
        goto out;
    }

    rc = 0;

out:
    if (fd != -1) {
        close(fd);
    }

    return rc;
}
开发者ID:MoKee,项目名称:android_system_core,代码行数:28,代码来源:fs_mgr_verity.cpp


示例16: Pwrite

static void
Pwrite(int fd, void *buf, size_t size, off64_t off)
{
	if (pwrite64(fd, buf, size, off) != size)
		logprint(SC_SL_ERR | SC_EXIT_ERR, "pwrite: %s",
		    strerror(errno));
}
开发者ID:FilipinOTech,项目名称:illumos-gate,代码行数:7,代码来源:savecore.c


示例17: BOOST_ASSERT

ssize_t RandomAccessFile::write(uint64_t offset, void* src, size_t size)
{
	BOOST_ASSERT( size <= WINDOW_SIZE );
	ssize_t written = pwrite64(_fd, src, size, offset);
	if ((size_t)written != size)
		throw std::ios_base::failure("Failed to write");
	return written;
}
开发者ID:AlexejK,项目名称:bithorde,代码行数:8,代码来源:randomaccessfile.cpp


示例18: full_pwrite64

ssize_t full_pwrite64(int fd, const void *buf, size_t count, int64_t offset)
{
#if CCTOOLS_OPSYS_CYGWIN || CCTOOLS_OPSYS_DARWIN || CCTOOLS_OPSYS_FREEBSD || CCTOOLS_OPSYS_DRAGONFLY
	FULL_PIO(pwrite(fd, buf, count, offset));
#else
	FULL_PIO(pwrite64(fd, buf, count, offset));
#endif
}
开发者ID:Baguage,项目名称:cctools,代码行数:8,代码来源:full_io.c


示例19: pci_device_linux_sysfs_write

static int
pci_device_linux_sysfs_write( struct pci_device * dev, const void * data,
			     pciaddr_t offset, pciaddr_t size,
			     pciaddr_t * bytes_written )
{
    char name[256];
    pciaddr_t temp_size = size;
    int err = 0;
    int fd;
    const char *data_bytes = data;

    if ( bytes_written != NULL ) {
	*bytes_written = 0;
    }

    /* Each device has a directory under sysfs.  Within that directory there
     * is a file named "config".  This file used to access the PCI config
     * space.  It is used here to obtain most of the information about the
     * device.
     */
    snprintf( name, 255, "%s/%04x:%02x:%02x.%1u/config",
	      SYS_BUS_PCI,
	      dev->domain,
	      dev->bus,
	      dev->dev,
	      dev->func );

    fd = open( name, O_WRONLY | O_CLOEXEC);
    if ( fd == -1 ) {
	return errno;
    }


    while ( temp_size > 0 ) {
	const ssize_t bytes = pwrite64( fd, data_bytes, temp_size, offset );

	/* If zero bytes were written, then we assume it's the end of the
	 * config file.
	 */
	if ( bytes == 0 )
	    break;
	if ( bytes < 0 ) {
	    err = errno;
	    break;
	}

	temp_size -= bytes;
	offset += bytes;
	data_bytes += bytes;
    }

    if ( bytes_written != NULL ) {
	*bytes_written = size - temp_size;
    }

    close( fd );
    return err;
}
开发者ID:karolherbst,项目名称:libpciaccess,代码行数:58,代码来源:linux_sysfs.c


示例20: write_file

int write_file(int fd, unsigned long long *offset, const char *buf, int len)
{
	int n;

	n = pwrite64(fd, buf, len, *offset);
	if(n < 0) return(-errno);
	*offset += n;
	return(n);
}
开发者ID:WiseMan787,项目名称:ralink_sdk,代码行数:9,代码来源:hostfs_user.c



注:本文中的pwrite64函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ px函数代码示例发布时间:2022-05-30
下一篇:
C++ pwrite函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap