您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ sys_safecopyto函数代码示例

51自学网 2021-06-03 08:37:31
  C++
这篇教程C++ sys_safecopyto函数代码示例写得很实用,希望能帮到您。

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

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

示例1: data_to_user

PRIVATE void data_to_user(sub_dev_t *sub_dev_ptr){	int r;	message m;	if (!sub_dev_ptr->RevivePending) return; /* nobody is wating for data */	if (sub_dev_ptr->ReadyToRevive) return;/* we already filled user's buffer */	if (sub_dev_ptr->BufLength == 0 && sub_dev_ptr->DmaLength == 0) return; 		/* no data for user */	if(sub_dev_ptr->BufLength != 0) { /* data in extra buffer available */		sys_safecopyto(sub_dev_ptr->ReviveProcNr, 				(vir_bytes)sub_dev_ptr->ReviveGrant,				0, (vir_bytes)sub_dev_ptr->ExtraBuf + 				sub_dev_ptr->BufReadNext * sub_dev_ptr->FragSize,				(phys_bytes)sub_dev_ptr->FragSize, D);		dprint(" copied buf[%d] to user/n", sub_dev_ptr->BufReadNext); 		/* adjust the buffer status variables */		sub_dev_ptr->BufReadNext = 			(sub_dev_ptr->BufReadNext + 1) % sub_dev_ptr->NrOfExtraBuffers;		sub_dev_ptr->BufLength -= 1;	} else { /* extra buf empty, but data in dma buf*/ 		sys_safecopyto(				sub_dev_ptr->ReviveProcNr, 				(vir_bytes)sub_dev_ptr->ReviveGrant, 0, 				(vir_bytes)sub_dev_ptr->DmaPtr + 				sub_dev_ptr->DmaReadNext * sub_dev_ptr->FragSize,				(phys_bytes)sub_dev_ptr->FragSize, D);		dprint(" copied dma[%d] to user/n", sub_dev_ptr->DmaReadNext);		/* adjust the buffer status variables */		sub_dev_ptr->DmaReadNext = 			(sub_dev_ptr->DmaReadNext + 1) % sub_dev_ptr->NrOfDmaFragments;		sub_dev_ptr->DmaLength -= 1;	}	sub_dev_ptr->ReviveStatus = sub_dev_ptr->FragSize;	sub_dev_ptr->ReadyToRevive = TRUE; 		/* drv_status will send REVIVE mess to FS*/		m.m_type = DEV_REVIVE;			/* build message */	m.REP_ENDPT = sub_dev_ptr->ReviveProcNr;	m.REP_IO_GRANT = sub_dev_ptr->ReviveGrant;	m.REP_STATUS = sub_dev_ptr->ReviveStatus;	r= send(sub_dev_ptr->NotifyProcNr, &m);		/* send the message */	if (r != OK)	{		printf("audio_fw: send to %d failed: %d/n",			sub_dev_ptr->NotifyProcNr, r);	}	/* reset variables */	sub_dev_ptr->ReadyToRevive = FALSE;	sub_dev_ptr->RevivePending = 0;}
开发者ID:QiuLihua83,项目名称:minix2009,代码行数:60,


示例2: netdriver_portinw

/* * Transfer words from hardware to a destination buffer using port-based I/O. */voidnetdriver_portinw(struct netdriver_data * data, size_t off, long port,	size_t size){	uint8_t buf[2];	uint32_t value;	size_t chunk;	unsigned int i;	int r, odd_byte;	off = netdriver_prepare_copy(data, off, size, &i);	odd_byte = 0;	while (size > 0) {		chunk = data->iovec[i].iov_size - off;		if (chunk > size)			chunk = size;		assert(chunk > 0);		if (odd_byte) {			if ((r = sys_safecopyto(data->endpt,			    data->iovec[i].iov_grant, off, (vir_bytes)&buf[1],			    1)) != OK)				panic("netdriver: unable to copy data: %d", r);			off++;			size--;			chunk--;		}		odd_byte = chunk & 1;		chunk -= odd_byte;		if (chunk > 0) {			if ((r = sys_safe_insw(port, data->endpt,			    data->iovec[i].iov_grant, off, chunk)) != OK)				panic("netdriver: port input failed: %d", r);			off += chunk;			size -= chunk;		}		if (odd_byte) {			if ((r = sys_inw(port, &value)) != OK)				panic("netdriver: port input failed: %d", r);			*(uint16_t *)buf = (uint16_t)value;			if ((r = sys_safecopyto(data->endpt,			    data->iovec[i].iov_grant, off, (vir_bytes)&buf[0],			    1)) != OK)				panic("netdriver: unable to copy data: %d", r);			size--;		}		i++;		off = 0;	}}
开发者ID:Hooman3,项目名称:minix,代码行数:62,


示例3: fs_statvfs

/*===========================================================================* *				fs_statvfs				     * *===========================================================================*/int fs_statvfs(){  struct statvfs st;  struct super_block *sp;  int r, scale;  u32_t used;  sp = get_super(fs_dev);  scale = sp->s_log_zone_size;  blockstats((u32_t *) &st.f_blocks, (u32_t *) &st.f_bfree, &used);  st.f_bavail = st.f_bfree;  st.f_bsize =  sp->s_block_size << scale;  st.f_frsize = sp->s_block_size;  st.f_files = sp->s_ninodes;  st.f_ffree = count_free_bits(sp, IMAP);  st.f_favail = st.f_ffree;  st.f_fsid = fs_dev;  st.f_flag = (sp->s_rd_only == 1 ? ST_RDONLY : 0);  st.f_namemax = MFS_DIRSIZ;  /* Copy the struct to user space. */  r = sys_safecopyto(fs_m_in.m_source, fs_m_in.REQ_GRANT, 0, (vir_bytes) &st,		     (phys_bytes) sizeof(st));    return(r);}
开发者ID:0xenvision,项目名称:minix,代码行数:32,


示例4: stat_inode

/** * Common code for stat and fstat system calls. * @param rip   pointer to inode to stat * @param who_e  caller endpoint * @param gid  grant for the stat buf * @return 0 on success */static int stat_inode(struct pipe_inode *rip, int who_e, cp_grant_id_t gid){	struct kstat ksb;	int r, s;	/* Update the atime, ctime, and mtime fields in the inode, if need be. */	if (rip->i_update) update_times(rip);	ksb.dev = rip->i_dev;	ksb.ino = rip->i_num;	ksb.mode = rip->i_mode;	ksb.nlink = rip->i_nlinks;	ksb.uid = rip->i_uid;	ksb.gid = rip->i_gid;	ksb.rdev = (dev_t) 0;	ksb.size = rip->i_size;	ksb.mode &= ~I_REGULAR;	/* wipe out I_REGULAR bit for pipes */	ksb.blksize = 1024;	/* @nucleos: what it should be for pipes? */	ksb.blocks = 0;	ksb.atime.tv_sec = rip->i_atime;	ksb.mtime.tv_sec = rip->i_mtime;	ksb.ctime.tv_sec = rip->i_ctime;	ksb.atime.tv_nsec = 0;	ksb.mtime.tv_nsec = 0;	ksb.ctime.tv_nsec = 0;	/* Copy the struct to caller space. */	r = sys_safecopyto(who_e, gid, 0, (vir_bytes)&ksb,(phys_bytes)sizeof(ksb), D);	return(r);}
开发者ID:locosoft1986,项目名称:nucleos,代码行数:41,


示例5: hello_transfer

static int hello_transfer(endpoint_t endpt, int opcode, u64_t position,    iovec_t *iov, unsigned nr_req, endpoint_t UNUSED(user_endpt),    unsigned int UNUSED(flags)){    int bytes, ret;    printf("hello_transfer()/n");    if (nr_req != 1)    {        /* This should never trigger for character drivers at the moment. */        printf("HELLO: vectored transfer request, using first element only/n");    }    bytes = strlen(HELLO_MESSAGE) - ex64lo(position) < iov->iov_size ?            strlen(HELLO_MESSAGE) - ex64lo(position) : iov->iov_size;    if (bytes <= 0)    {        return OK;    }    switch (opcode)    {        case DEV_GATHER_S:            ret = sys_safecopyto(endpt, (cp_grant_id_t) iov->iov_addr, 0,                                (vir_bytes) (HELLO_MESSAGE + ex64lo(position)),                                 bytes, D);            iov->iov_size -= bytes;            break;        default:            return EINVAL;    }    return ret;}
开发者ID:Sciumo,项目名称:minix,代码行数:35,


示例6: do_request

static int do_request(message *m){	struct vumap_vir vvec[MAPVEC_NR + 3];	struct vumap_phys pvec[MAPVEC_NR + 3];	int r, r2, access, vcount, pcount;	size_t offset;	assert(m->m_type == VTR_RELAY);	vcount = m->VTR_VCOUNT;	pcount = m->VTR_PCOUNT;	offset = m->VTR_OFFSET;	access = m->VTR_ACCESS;	r2 = sys_safecopyfrom(m->m_source, m->VTR_VGRANT, 0, (vir_bytes) vvec,		sizeof(vvec[0]) * vcount);	assert(r2 == OK);	r = sys_vumap(m->m_source, vvec, vcount, offset, access, pvec,		&pcount);	if (pcount >= 1 && pcount <= MAPVEC_NR + 3) {		r2 = sys_safecopyto(m->m_source, m->VTR_PGRANT, 0,			(vir_bytes) pvec, sizeof(pvec[0]) * pcount);		assert(r2 == OK);	}	m->VTR_PCOUNT = pcount;	return r;}
开发者ID:AgamAgarwal,项目名称:minix,代码行数:31,


示例7: do_ioctl

/*===========================================================================* *				do_ioctl				     * *===========================================================================*/static int do_ioctl(message *m){	struct partition sizepart;	switch(m->REQUEST) {	case DIOCSETP:	case DIOCTIMEOUT:	case DIOCOPENCT:		/* These do not make sense for us. */		return EINVAL;	case DIOCGETP:		memset(&sizepart, 0, sizeof(sizepart));		/* The presented disk size is the raw partition size,		 * corrected for space needed for checksums.		 */		sizepart.size = convert(get_raw_size());		if(sys_safecopyto(proc_e, (vir_bytes) grant_id, 0,				(vir_bytes) &sizepart,				sizeof(struct partition), D) != OK) {			printf("Filter: DIOCGETP safecopyto failed/n");			return EIO;		}		break;	default:		printf("Filter: unknown ioctl request: %d!/n", m->REQUEST);		return EINVAL;	}	return OK;}
开发者ID:Spenser309,项目名称:CS551,代码行数:37,


示例8: do_getsockopt_sotype

int do_getsockopt_sotype(message *dev_m_in, message *dev_m_out){	int minor;	int rc;#if DEBUG == 1	static int call_count = 0;	printf("(uds) [%d] do_getsockopt_sotype() call_count=%d/n",				uds_minor(dev_m_in), ++call_count);#endif	minor = uds_minor(dev_m_in);	if (uds_fd_table[minor].type == -1) {		/* the type hasn't been set yet. instead of returning an		 * invalid type, we fail with EINVAL		 */		return EINVAL;	}	rc = sys_safecopyto(VFS_PROC_NR, (cp_grant_id_t) dev_m_in->IO_GRANT,		(vir_bytes) 0, (vir_bytes) &(uds_fd_table[minor].type),		sizeof(int));	return rc ? EIO : OK;}
开发者ID:anuragpeshne,项目名称:minix,代码行数:27,


示例9: vcarry

/*===========================================================================* *				vcarry					     * *===========================================================================*/static int vcarry(int grants, iovec_t *iov, int flag_rw, size_t size){	/* Carry data between caller proc and filter, through grant-vector.	 */	char *bufp;	int i, r;	size_t bytes;	bufp = buffer;	for(i = 0; i < grants && size > 0; i++) {		bytes = MIN(size, iov[i].iov_size);		if (flag_rw == FLT_WRITE)			r = sys_safecopyfrom(proc_e,				(vir_bytes) iov[i].iov_addr, 0,				(vir_bytes) bufp, bytes, D);		else			r = sys_safecopyto(proc_e,				(vir_bytes) iov[i].iov_addr, 0,				(vir_bytes) bufp, bytes, D);		if(r != OK)			return r;		bufp += bytes;		size -= bytes;	}	return OK;}
开发者ID:Spenser309,项目名称:CS551,代码行数:33,


示例10: subread

/*===========================================================================* *				subread					     * *===========================================================================*/static intsubread(struct logdevice *log, size_t size, endpoint_t endpt,	cp_grant_id_t grant){  size_t offset, count;  char *buf;  int r;  for (offset = 0; log->log_size > 0 && offset < size; offset += count) {	count = size - offset;    	if (count > log->log_size)    		count = log->log_size;        if (log->log_read + count > LOG_SIZE)        	count = LOG_SIZE - log->log_read;    	buf = log->log_buffer + log->log_read;	if((r=sys_safecopyto(endpt, grant, offset, (vir_bytes)buf,		count)) != OK)		return r;  	LOGINC(log->log_read, count);        log->log_size -= count;  }  return offset;}
开发者ID:Stichting-MINIX-Research-Foundation,项目名称:minix,代码行数:30,


示例11: block_ioctl

/*===========================================================================* *				block_ioctl		                     * *===========================================================================*/static intblock_ioctl(dev_t minor,    unsigned int request, endpoint_t endpt, cp_grant_id_t grant){	/* IOCTL handling */	struct sd_slot *slot;	mmc_log_trace(&log,	    "enter (minor,request,endpoint,grant)=(%d,%lu,%d)/n", minor,	    request, endpt, grant);	slot = get_slot(minor);	if (!slot) {		mmc_log_warn(&log,		    "Doing ioctl on non existing block device(%d)/n", minor);		return EINVAL;	}	switch (request) {	case DIOCOPENCT:		// TODO: add a check for card validity */		mmc_log_trace(&log, "returning open count %d/n",		    slot->card.open_ct);		/* return the current open count */		return sys_safecopyto(endpt, grant, 0,		    (vir_bytes) & slot->card.open_ct,		    sizeof(slot->card.open_ct));	case DIOCFLUSH:		/* No need to flush but some devices like movinands require		 * 500 ms inactivity */		return OK;	}	return EINVAL;}
开发者ID:bdeepak77,项目名称:minix3,代码行数:37,


示例12: mem2user

/***  Name:	void mem2user(dpeth_t *dep, buff_t *rxbuff);**  Function:	Copies a packet from local buffer to user area.*/void mem2user(dpeth_t *dep, buff_t *rxbuff){  int bytes, ix = 0;  iovec_dat_s_t *iovp = &dep->de_read_iovec;  int r, pktsize = rxbuff->size;  char *buffer = rxbuff->buffer;  do {				/* Reads chuncks of packet into user buffers */	bytes = iovp->iod_iovec[ix].iov_size;	/* Size of buffer */	if (bytes > pktsize) bytes = pktsize;	/* Reads from Rx buffer to user area */	r= sys_safecopyto(iovp->iod_proc_nr, iovp->iod_iovec[ix].iov_grant, 0,		(vir_bytes)buffer, bytes);	if (r != OK)		panic("mem2user: sys_safecopyto failed: %d", r);	buffer += bytes;	if (++ix >= IOVEC_NR) {	/* Next buffer of IO vector */		dp_next_iovec(iovp);		ix = 0;	}	/* Till packet done */  } while ((pktsize -= bytes) > 0);  return;}
开发者ID:AgamAgarwal,项目名称:minix,代码行数:31,


示例13: do_getsockname

int do_getsockname(message *dev_m_in, message *dev_m_out){	int minor;	int rc;#if DEBUG == 1	static int call_count = 0;	printf("(uds) [%d] do_getsockname() call_count=%d/n",					uds_minor(dev_m_in), ++call_count);#endif	minor = uds_minor(dev_m_in);	/* Unconditionally send the address we have assigned to this socket.	 * The POSIX standard doesn't say what to do if the address	 * hasn't been set. If the address isn't currently set, then	 * the user will get NULL bytes. Note: libc depends on this	 * behavior.	 */	rc = sys_safecopyto(VFS_PROC_NR, (cp_grant_id_t) dev_m_in->IO_GRANT,		(vir_bytes) 0, (vir_bytes) &(uds_fd_table[minor].addr),		sizeof(struct sockaddr_un));	return rc ? EIO : OK;}
开发者ID:anuragpeshne,项目名称:minix,代码行数:25,


示例14: fs_getdents

/*===========================================================================* *				fs_getdents				     * *===========================================================================*/PUBLIC int fs_getdents(void){  int r;  register struct puffs_node *pn;  ino_t ino;  cp_grant_id_t gid;  size_t size, buf_left;  off_t pos;  struct dirent *dent;  int eofflag = 0;  size_t written;  PUFFS_MAKECRED(pcr, &global_kcred);  ino = (ino_t) fs_m_in.REQ_INODE_NR;  gid = (gid_t) fs_m_in.REQ_GRANT;  size = buf_left = (size_t) fs_m_in.REQ_MEM_SIZE;  pos = (off_t) fs_m_in.REQ_SEEK_POS_LO;  if ((pn = puffs_pn_nodewalk(global_pu, 0, &ino)) == NULL) {	lpuffs_debug("walk failed.../n");        return(EINVAL);  }  if (GETDENTS_BUFSIZ < size)	  size = buf_left = GETDENTS_BUFSIZ;  memset(getdents_buf, '/0', GETDENTS_BUFSIZ);  /* Avoid leaking any data */  dent = (struct dirent*) getdents_buf;  r = global_pu->pu_ops.puffs_node_readdir(global_pu, pn, dent, &pos,						&buf_left, pcr, &eofflag, 0, 0);  if (r) {	lpuffs_debug("puffs_node_readdir returned error/n");	return(EINVAL);  }  assert(buf_left <= size);  written = size - buf_left;  if (written == 0 && !eofflag) {	lpuffs_debug("The user's buffer is too small/n");	return(EINVAL);  }  if (written) {	r = sys_safecopyto(VFS_PROC_NR, gid, (vir_bytes) 0,			     (vir_bytes) getdents_buf, written, D);	if (r != OK) return(r);  }  update_times(pn, ATIME, 0);  fs_m_out.RES_NBYTES = written;  fs_m_out.RES_SEEK_POS_LO = pos;  return(OK);}
开发者ID:vivekp,项目名称:minix-1,代码行数:60,


示例15: fs_read

/*===========================================================================* *				fs_read					     * *===========================================================================*/int fs_read(void){	/* Read from a file.	 */	cp_grant_id_t gid;	struct inode *node;	off_t pos;	size_t len;	char *ptr;	int r;	if (fs_m_in.REQ_SEEK_POS_HI != 0)		return EIO;	/* Try to get inode by to its inode number. */	if ((node = find_inode(fs_m_in.REQ_INODE_NR)) == NULL)		return EINVAL;	/* Check whether the node is a regular file. */	if (!S_ISREG(node->i_stat.mode))		return EINVAL;	/* Get the values from the request message. */	gid = fs_m_in.REQ_GRANT;	pos = fs_m_in.REQ_SEEK_POS_LO;	/* Call the read hook, if any. */	if (!is_inode_deleted(node) && vtreefs_hooks->read_hook != NULL) {		len = fs_m_in.REQ_NBYTES;		/* On success, the read hook provides us with a pointer to the		 * resulting data. This avoids copying overhead.		 */		r = vtreefs_hooks->read_hook(node, pos, &ptr, &len,			get_inode_cbdata(node));		assert(len >= 0 && len <= fs_m_in.REQ_NBYTES);		/* Copy the resulting data to user space. */		if (r == OK && len > 0) {			r = sys_safecopyto(fs_m_in.m_source, fs_m_in.REQ_GRANT,				0, (vir_bytes) ptr, len, D);		}	} else {		/* Feign an empty file. */		r = OK;		len = 0;	}	if (r == OK) {		fs_m_out.RES_SEEK_POS_HI = 0;		fs_m_out.RES_SEEK_POS_LO = pos + len;		fs_m_out.RES_NBYTES = len;	}	return r;}
开发者ID:Sciumo,项目名称:minix,代码行数:60,


示例16: do_read

/*===========================================================================* *				do_read					     * *===========================================================================*/int do_read(){/* Read data from a file. */  struct inode *ino;  u64_t pos;  size_t count, size;  vir_bytes off;  char *ptr;  int r, chunk;  if ((ino = find_inode(m_in.REQ_INODE_NR)) == NULL)	return EINVAL;  if (IS_DIR(ino)) return EISDIR;  if ((r = get_handle(ino)) != OK)	return r;  pos = make64(m_in.REQ_SEEK_POS_LO, m_in.REQ_SEEK_POS_HI);  count = m_in.REQ_NBYTES;  assert(count > 0);  /* Use the buffer from below to eliminate extra copying. */  size = sffs_table->t_readbuf(&ptr);  off = 0;  while (count > 0) {	chunk = MIN(count, size);	if ((r = sffs_table->t_read(ino->i_file, ptr, chunk, pos)) <= 0)		break;	chunk = r;	r = sys_safecopyto(m_in.m_source, m_in.REQ_GRANT, off,		(vir_bytes) ptr, chunk, D);	if (r != OK)		break;	count -= chunk;	off += chunk;	pos = add64u(pos, chunk);  }  if (r < 0)	return r;  m_out.RES_SEEK_POS_HI = ex64hi(pos);  m_out.RES_SEEK_POS_LO = ex64lo(pos);  m_out.RES_NBYTES = off;  return OK;}
开发者ID:Sciumo,项目名称:minix,代码行数:59,


示例17: carry

/*===========================================================================* *				carry					     * *===========================================================================*/static int carry(size_t size, int flag_rw){	/* Carry data between caller proc and filter.	 */	if (flag_rw == FLT_WRITE)		return sys_safecopyfrom(proc_e, grant_id, 0,			(vir_bytes) buffer, size, D);	else		return sys_safecopyto(proc_e, grant_id, 0,			(vir_bytes) buffer, size, D);}
开发者ID:Spenser309,项目名称:CS551,代码行数:15,


示例18: fs_stat

/*===========================================================================* *                             fs_stat					     * *===========================================================================*/int fs_stat(){  register int r;              /* return value */  register struct puffs_node *pn;  /* target pnode */  struct vattr va;  struct stat statbuf;  mode_t mo;  int s;  PUFFS_MAKECRED(pcr, &global_kcred);  if (global_pu->pu_ops.puffs_node_getattr == NULL) {	lpuffs_debug("fs_stat: puffs_node_getattr is missing/n");	return(EINVAL);  }  if ((pn = puffs_pn_nodewalk(global_pu, 0, &fs_m_in.REQ_INODE_NR)) == NULL) {  	lpuffs_debug("walk failed.../n");        return(EINVAL);  }  if (global_pu->pu_ops.puffs_node_getattr(global_pu, pn, &va, pcr) != 0) {	if (errno) {		if (errno > 0) errno = -errno;		return(errno);	}	return(EINVAL);  }  /* Fill in the statbuf struct. */  mo = va.va_mode & I_TYPE;  /* true iff special */  s = (mo == I_CHAR_SPECIAL || mo == I_BLOCK_SPECIAL);  statbuf.st_dev = fs_dev;  statbuf.st_ino = va.va_fileid;  statbuf.st_mode = va.va_mode;  statbuf.st_nlink = va.va_nlink;  statbuf.st_uid = va.va_uid;  statbuf.st_gid = va.va_gid;  statbuf.st_rdev = (s ? va.va_rdev : NO_DEV);  statbuf.st_size = va.va_size;  statbuf.st_atime = va.va_atime.tv_sec;  statbuf.st_mtime = va.va_mtime.tv_sec;  statbuf.st_ctime = va.va_ctime.tv_sec;  /* Copy the struct to user space. */  r = sys_safecopyto(fs_m_in.m_source, (cp_grant_id_t) fs_m_in.REQ_GRANT,		     (vir_bytes) 0, (vir_bytes) &statbuf,		     (size_t) sizeof(statbuf));  return(r);}
开发者ID:AgamAgarwal,项目名称:minix,代码行数:56,


示例19: fs_fstatfs

/*===========================================================================* *				fs_fstatfs				     * *===========================================================================*/PUBLIC int fs_fstatfs(void){	/* Retrieve file system statistics.	 */	struct statfs statfs;	memset(&statfs, 0, sizeof(statfs));	/* Copy the struct to user space. */	return sys_safecopyto(fs_m_in.m_source, fs_m_in.REQ_GRANT, 0,		(vir_bytes) &statfs, (phys_bytes) sizeof(statfs), D);}
开发者ID:DragonQuan,项目名称:minix3,代码行数:15,


示例20: do_get_fixscreeninfo

static intdo_get_fixscreeninfo(int minor, endpoint_t ep, cp_grant_id_t gid){        int r;        struct fb_fix_screeninfo fbfs;        if ((r = arch_get_fixscreeninfo(minor, &fbfs)) == OK) {                r = sys_safecopyto(ep, gid, 0, (vir_bytes) &fbfs, sizeof(fbfs));        }        return r;}
开发者ID:AjeyBohare,项目名称:minix,代码行数:12,


示例21: hello_transfer

static int hello_transfer(endpoint_t endpt, int opcode, u64_t position,    iovec_t *iov, unsigned nr_req, endpoint_t user_endpt,    unsigned int UNUSED(flags)){    int bytes, ret;    // printf("hello_transfer()/n");    if (nr_req != 1)    {        /* This should never trigger for character drivers at the moment. */        printf("HELLO: vectored transfer request, using first element only/n");    }    bytes = SECRET_SIZE - ex64lo(position) < iov->iov_size ?            SECRET_SIZE - ex64lo(position) : iov->iov_size;    // printf("iov->iov_size: %lu, transfer() bytes: %d/n", iov->iov_size, bytes);    if (bytes <= 0)    {        return OK;    }    switch (opcode)    {        case DEV_SCATTER_S:            printf("transfer() WRITE.../n");            ret = sys_safecopyfrom(user_endpt, (cp_grant_id_t) iov->iov_addr, 0, (vir_bytes) (the_secret + ex64lo(position)), bytes);            iov->iov_size += bytes;            printf("the secret: %s/n", the_secret);            break;        case DEV_GATHER_S:            printf("transfer() READ.../n");            ret = sys_safecopyto(endpt, (cp_grant_id_t) iov->iov_addr, 0,                                (vir_bytes) (the_secret + ex64lo(position)),                                 bytes);            iov->iov_size -= bytes;            printf("the secret: %s/n", the_secret);            break;        default:            fprintf(stderr, "Unknown opcode: %d/n", opcode);            return EINVAL;    }    return ret;}
开发者ID:girum11,项目名称:cpe453-minix-os,代码行数:52,


示例22: store_t

static intstore_t(endpoint_t ep, cp_grant_id_t gid, struct tm *t){	int r;	r = sys_safecopyto(ep, gid, (vir_bytes) 0, (vir_bytes) t,	    sizeof(struct tm));	if (r != OK) {		log_warn(&log, "sys_safecopyto() failed (r=%d)/n", r);		return r;	}	return OK;}
开发者ID:anuragpeshne,项目名称:minix,代码行数:14,


示例23: atl2_getstat

/*===========================================================================* *				atl2_getstat				     * *===========================================================================*/static void atl2_getstat(message *m){	/* Copy out statistics.	 */	int r;	sys_safecopyto(m->m_source, m->DL_GRANT, 0,		(vir_bytes) &state.stat, sizeof(state.stat));	m->m_type = DL_STAT_REPLY;	if ((r = send(m->m_source, m)) != OK)		printf("ATL2: unable to send reply (%d)/n", r);}
开发者ID:ssinghi,项目名称:minix,代码行数:17,


示例24: copyto

static intcopyto(endpoint_t dst_e,    cp_grant_id_t gr_id, vir_bytes offset, vir_bytes address, size_t bytes){	/* Helper function that used memcpy to copy data when the endpoint ==	 * SELF */	if (dst_e == SELF) {		memcpy((char *) gr_id + offset, (char *) address, bytes);		return OK;	} else {		/* Read io_size bytes from our data at the correct * offset		 * and write it to the output buffer at 0 */		return sys_safecopyto(dst_e, gr_id, offset, address, bytes);	}}
开发者ID:bdeepak77,项目名称:minix3,代码行数:15,


示例25: fs_statvfs

/*===========================================================================* *				fs_fstatfs				     * *===========================================================================*/PUBLIC int fs_statvfs(void){	/* Retrieve file system statistics.	 */	struct statvfs statvfs;	memset(&statvfs, 0, sizeof(statvfs));	statvfs.f_fsid = fs_dev;	statvfs.f_flag = ST_RDONLY | ST_NOTRUNC;	statvfs.f_namemax = PNAME_MAX;	return sys_safecopyto(fs_m_in.m_source, fs_m_in.REQ_GRANT, 0,		(vir_bytes) &statvfs, sizeof(statvfs), D);}
开发者ID:DragonQuan,项目名称:minix3,代码行数:18,


示例26: fs_rdlink

/*===========================================================================* *                             fs_rdlink                                     * *===========================================================================*/int fs_rdlink(){  block_t b;                   /* block containing link text */  struct buf *bp = NULL;       /* buffer containing link text */  char* link_text;             /* either bp->b_data or rip->i_block */  register struct inode *rip;  /* target inode */  register int r;              /* return value */  size_t copylen;  copylen = min( (size_t) fs_m_in.REQ_MEM_SIZE, UMAX_FILE_POS);  /* Temporarily open the file. */  if( (rip = get_inode(fs_dev, (ino_t) fs_m_in.REQ_INODE_NR)) == NULL)	  return(EINVAL);  if (rip->i_size >= MAX_FAST_SYMLINK_LENGTH) {  /* normal symlink */	if ((b = read_map(rip, (off_t) 0)) == NO_BLOCK) {		r = EIO;	} else {		bp = get_block(rip->i_dev, b, NORMAL);		link_text = bp->b_data;		if (bp)			r = OK;		else			r = EIO;	}  } else {        /* fast symlink, stored in inode */        link_text = (char*) rip->i_block;	r = OK;  }  if (r == OK) {  /* Passed all checks */  /* We can safely cast to unsigned, because copylen is guaranteed to be     below max file size */	copylen = min( copylen, (unsigned) rip->i_size);	r = sys_safecopyto(VFS_PROC_NR, (cp_grant_id_t) fs_m_in.REQ_GRANT,	                   (vir_bytes) 0, (vir_bytes) link_text,			   (size_t) copylen);	put_block(bp, DIRECTORY_BLOCK);	if (r == OK)		fs_m_out.RES_NBYTES = copylen;  }  put_inode(rip);  return(r);}
开发者ID:ssinghi,项目名称:minix,代码行数:51,


示例27: do_getsockopt_sndbuf

int do_getsockopt_sndbuf(message *dev_m_in, message *dev_m_out){	int rc;	size_t sndbuf = PIPE_BUF;#if DEBUG == 1	static int call_count = 0;	printf("(uds) [%d] do_getsockopt_sndbuf() call_count=%d/n",				uds_minor(dev_m_in), ++call_count);#endif	rc = sys_safecopyto(VFS_PROC_NR, (cp_grant_id_t) dev_m_in->IO_GRANT,		(vir_bytes) 0, (vir_bytes) &(sndbuf), sizeof(size_t));	return rc ? EIO : OK;}
开发者ID:anuragpeshne,项目名称:minix,代码行数:16,


示例28: do_getsockopt_peercred_old

int do_getsockopt_peercred_old(message *dev_m_in, message *dev_m_out){	int minor;	int peer_minor;	int rc;	struct ucred cred;	struct ucred_old cred_old;#if DEBUG == 1	static int call_count = 0;	printf("(uds) [%d] do_getsockopt_peercred() call_count=%d/n",					uds_minor(dev_m_in), ++call_count);#endif	minor = uds_minor(dev_m_in);	if (uds_fd_table[minor].peer == -1) {		if (uds_fd_table[minor].err == ECONNRESET) {			uds_fd_table[minor].err = 0;			return ECONNRESET;		} else {			return ENOTCONN;		}	}	peer_minor = uds_fd_table[minor].peer;	/* obtain the peer's credentials */	rc = getnucred(uds_fd_table[peer_minor].owner, &cred);	if (rc == -1) {		/* likely error: invalid endpoint / proc doesn't exist */		return errno;	}	/* copy to old structure */	cred_old.pid = cred.pid;	cred_old.uid = (short) cred.uid;	cred_old.gid = (char) cred.gid;	rc = sys_safecopyto(VFS_PROC_NR, (cp_grant_id_t) dev_m_in->IO_GRANT,		(vir_bytes) 0, (vir_bytes) &cred_old, sizeof(struct ucred_old),		D);	return rc ? EIO : OK;}
开发者ID:Sciumo,项目名称:minix,代码行数:47,



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


C++ sys_sem_new函数代码示例
C++ sys_safecopyfrom函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。