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

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

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

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

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

示例1: copy_from_user

boolcopy_from_user(struct mm_struct *mm, void *dst, const void *src, size_t len, bool writable) {    if (!user_mem_check(mm, (uintptr_t)src, len, writable)) {        return 0;    }    memcpy(dst, src, len);    return 1;}
开发者ID:xieyf13,项目名称:ucore_lab-1,代码行数:8,


示例2: copy_to_user

boolcopy_to_user(struct mm_struct *mm, void *dst, const void *src, size_t len) {    if (!user_mem_check(mm, (uintptr_t)dst, len, 1)) {        return 0;    }    memcpy(dst, src, len);    return 1;}
开发者ID:honoumi,项目名称:ucore_lab,代码行数:8,


示例3: user_mem_assert

//// Checks that environment 'env' is allowed to access the range// of memory [va, va+len) with permissions 'perm | PTE_U | PTE_P'.// If it can, then the function simply returns.// If it cannot, 'env' is destroyed and, if env is the current// environment, this function will not return.//voiduser_mem_assert(struct Env *env, const void *va, size_t len, int perm){	if (user_mem_check(env, va, len, perm | PTE_U) < 0) {		cprintf("[%08x] user_mem_check assertion failure for "			"va %08x/n", env->env_id, user_mem_check_addr);		env_destroy(env);	// may not return	}}
开发者ID:taylorr7732,项目名称:os_dev_tcr,代码行数:16,


示例4: sys_get_home_dir

intsys_get_home_dir(char* buf) {	int r;	if(curenv->user == -1)		return -1;	if((r = user_mem_check(curenv, buf, MAX_PATH_LENGTH, PTE_U|PTE_W)) <0) {		cprintf("SYS_get_logged_user_name: %08x/n",r);		return r;	}	memmove(buf,"/home/stam",11);	return 0;}
开发者ID:Hisham-A,项目名称:JOS,代码行数:12,


示例5: sys_update_current_path

intsys_update_current_path(char* buf) {	int r;	if(curenv->user == -1)		return -1;	if((r = user_mem_check(curenv, buf, MAX_PATH_LENGTH, PTE_U)) <0) {		cprintf("SYS_get_logged_user_name: %08x/n",r);		return r;	}		memmove(users[curenv->user].path,buf,MAX_PATH_LENGTH);	return 0;}
开发者ID:Hisham-A,项目名称:JOS,代码行数:13,


示例6: sys_get_logged_user_name

intsys_get_logged_user_name(char* buf) {	int r;	if(curenv->user == -1)		return -1;	if((r = user_mem_check(curenv, buf, MAX_USER_LENGTH, PTE_U|PTE_W)) <0) {		cprintf("SYS_get_logged_user_name: %08x/n",r);		return r;	}		memmove(buf,users[curenv->user].user,MAX_USER_LENGTH);	return 0;}
开发者ID:Hisham-A,项目名称:JOS,代码行数:13,


示例7: ipc_event_recv

int ipc_event_recv(int *pid_store, int *event_store, unsigned int timeout){	if (event_store == NULL) {		return -E_INVAL;	}	struct mm_struct *mm = current->mm;	if (pid_store != NULL) {		if (!user_mem_check(mm, (uintptr_t) pid_store, sizeof(int), 1)) {			return -E_INVAL;		}	}	if (!user_mem_check(mm, (uintptr_t) event_store, sizeof(int), 1)) {		return -E_INVAL;	}	unsigned long saved_ticks;	timer_t __timer, *timer =	    ipc_timer_init(timeout, &saved_ticks, &__timer);	int pid, event, ret;	if ((ret = recv_event(&pid, &event, timer)) == 0) {		lock_mm(mm);		{			ret = -E_INVAL;			if (pid_store == NULL			    || copy_to_user(mm, pid_store, &pid, sizeof(int))) {				if (copy_to_user				    (mm, event_store, &event, sizeof(int))) {					ret = 0;				}			}		}		unlock_mm(mm);		return ret;	}	return ipc_check_timeout(timeout, saved_ticks);}
开发者ID:Aresthu,项目名称:ucore_plus,代码行数:38,


示例8: host_getvalue

/** * Read a word from the container process's vm when we are in the main one *     This is only used to 'touch' the page as read so the page table will be right. *     See 'copy_from_user' in arch/um/mm/vmm.c for details. * @param proc the PCB whose container process will be touched * @param addr the address of the word to be touched (should be valid in the container process) * @param data the data to be read (of no use now) * @return 0 on success, or a negative otherwise */inthost_getvalue (struct proc_struct *proc,			   uintptr_t addr, uint32_t* data) {	if (!user_mem_check(proc->mm, addr, sizeof (uintptr_t), 0)) {        return -1;    }		struct stub_stack *stub_stack = proc->arch.host->stub_stack;	struct stub_frame *frame = current_stub_frame (stub_stack);	frame->eax = 0;	frame->ebx = addr;	int ret = host_syscall_in_child (proc);	if (data != NULL)		*data = ret;	return 0;}
开发者ID:PungiZhang,项目名称:ucore_plus-next,代码行数:26,


示例9: sys_env_set_trapframe

// Set envid's trap frame to 'tf'.// tf is modified to make sure that user environments always run at code// protection level 3 (CPL 3) with interrupts enabled.//// Returns 0 on success, < 0 on error.  Errors are://	-E_BAD_ENV if environment envid doesn't currently exist,//		or the caller doesn't have permission to change envid.static intsys_env_set_trapframe(envid_t envid, struct Trapframe *tf){	// LAB 5: Your code here.	// Remember to check whether the user has supplied us with a good	// address!	struct Env *env;	int r;	if ((r = envid2env(envid, &env, 1)) < 0)		return r; /*-E_BAD_ENV*/	if ((r = user_mem_check(curenv, tf, sizeof(struct Trapframe), PTE_U | PTE_P)) < 0)		return r;	env->env_tf = *tf;	env->env_tf.tf_eflags |= FL_IF;	return 0;//	panic("sys_env_set_trapframe not implemented");}
开发者ID:ldaochen,项目名称:JOS2011,代码行数:25,


示例10: host_assign

/** * Write a word to the container process's vm when we are in the main one *     This is only used to 'touch' the page as written so the page table will be right. *     See 'copy_to_user' in arch/um/mm/vmm.c for details. * @param proc the PCB whose container process will be touched * @param addr the address of the word to be touched (should be valid in the container process) * @param data the data to be written (of no use now) * @return 0 on success, or a negative otherwise */int host_assign (struct proc_struct *proc,			 uintptr_t addr, uint32_t data) {	if (!user_mem_check(proc->mm, addr, sizeof (uintptr_t), 1)) {		kprintf ("try assigning invalid address: 0x%x/n", addr);        return -1;    }	/* Use stub call so that the page table will be modified properly */	struct stub_stack *stub_stack = proc->arch.host->stub_stack;	struct stub_frame *frame = current_stub_frame (stub_stack);	frame->eax = -1;	frame->ebx = addr;	frame->ecx = data;		return host_syscall_in_child (proc);}
开发者ID:PungiZhang,项目名称:ucore_plus-next,代码行数:27,


示例11: sysfile_getcwd

/* sysfile_get cwd - get current working directory */intsysfile_getcwd(char *buf, size_t len) {    struct mm_struct *mm = current->mm;    if (len == 0) {        return -E_INVAL;    }    int ret = -E_INVAL;    lock_mm(mm);    {        if (user_mem_check(mm, (uintptr_t)buf, len, 1)) {            struct iobuf __iob, *iob = iobuf_init(&__iob, buf, len, 0);            ret = vfs_getcwd(iob);        }    }    unlock_mm(mm);    return ret;}
开发者ID:wwffcc,项目名称:spoc_discussions,代码行数:19,


示例12: sys_proc_save

static int  sys_proc_save(envid_t envid, struct proc *ps)  {      	struct Env *e;      	struct Page *pg;      	int offset;      	//save env       	if (envid2env(envid, &e, 1) <0)          	return -E_BAD_ENV;      	if (user_mem_check(curenv, ps, sizeof(struct proc), PTE_U|PTE_W|PTE_P) <0)          	return -E_FAULT;      	ps->env = *e;      	//save stack      	if ((pg=page_lookup(e->env_pgdir, (void *)(USTACKTOP-PGSIZE), NULL))==NULL)          	return -E_FAULT;      	    	memmove(ps->stack, page2kva(pg), PGSIZE);     	// cprintf("process %x has been saved/n", envid);      	return 0;}  
开发者ID:rinascere,项目名称:Jos,代码行数:20,


示例13: sysfile_pipe

intsysfile_pipe(int *fd_store) {    struct mm_struct *mm = current->mm;    int ret, fd[2];    if (!user_mem_check(mm, (uintptr_t)fd_store, sizeof(fd), 1)) {        return -E_INVAL;    }    if ((ret = file_pipe(fd)) == 0) {        lock_mm(mm);        {            if (!copy_to_user(mm, fd_store, fd, sizeof(fd))) {                ret = -E_INVAL;            }        }        unlock_mm(mm);        if (ret != 0) {            file_close(fd[0]), file_close(fd[1]);        }    }    return ret;}
开发者ID:spinlock,项目名称:ucore,代码行数:21,


示例14: sys_proc_resume

//restore one process  static int  sys_proc_resume(envid_t envid, struct proc *ps)  {      struct Env *e;      struct Page *pg;      int offset;     if (envid2env(envid, &e, 1) <0)          return -E_BAD_ENV;      if (user_mem_check(curenv, ps, sizeof(struct proc), PTE_U|PTE_P) <0)          return -E_FAULT;          *e = ps->env;          if ((pg=page_lookup(e->env_pgdir, (void *)(USTACKTOP-PGSIZE), NULL))==NULL)          return -E_FAULT;          memmove(page2kva(pg), ps->stack, PGSIZE);              return 0;  }  
开发者ID:rinascere,项目名称:Jos,代码行数:22,


示例15: copy_string

boolcopy_string(struct mm_struct *mm, char *dst, const char *src, size_t maxn) {    size_t alen, part = ROUNDDOWN((uintptr_t)src + PGSIZE, PGSIZE) - (uintptr_t)src;    while (1) {        if (part > maxn) {            part = maxn;        }        if (!user_mem_check(mm, (uintptr_t)src, part, 0)) {            return 0;        }        if ((alen = strnlen(src, part)) < part) {            memcpy(dst, src, alen + 1);            return 1;        }        if (part == maxn) {            return 0;        }        memcpy(dst, src, part);        dst += part, src += part, maxn -= part;        part = PGSIZE;    }}
开发者ID:PungiZhang,项目名称:ucore_plus-next,代码行数:22,


示例16: sys_send_packet

// Send packetstatic intsys_send_packet(void *va, unsigned int size) {	int perm;	int offset;	int r;	struct Page *p;		perm = PTE_U;	if(va + size >= (void *)UTOP) {		cprintf("SYS_send_packet: above UTOP/n");		return -E_INVAL;	}	if((r = user_mem_check(curenv, va, size, perm)) <0) {		cprintf("SYS_send_packet: %08x/n",r);		return r;	}	if(size > MAX_ETH_FRAME_SIZE)  {		//should fix the size ...		cprintf("SYS_send_packet: size is too big!");		return -E_INVAL; //better return?	}	//cprintf("Transmitting......./n/n/n/n");	return e100_send_packet(va, size);	}
开发者ID:Hisham-A,项目名称:JOS,代码行数:25,


示例17: do_wait

// do_wait - wait one OR any children with PROC_ZOMBIE state, and free memory space of kernel stack//         - proc struct of this child.// NOTE: only after do_wait function, all resources of the child proces are free.int do_wait(int pid, int *code_store){	struct mm_struct *mm = current->mm;	if (code_store != NULL) {		if (!user_mem_check(mm, (uintptr_t) code_store, sizeof(int), 1)) {			return -E_INVAL;		}	}	struct proc_struct *proc, *cproc;	bool intr_flag, haskid;repeat:	cproc = current;	haskid = 0;	if (pid != 0) {		proc = find_proc(pid);		if (proc != NULL) {			do {				if (proc->parent == cproc) {					haskid = 1;					if (proc->state == PROC_ZOMBIE) {						goto found;					}					break;				}				cproc = next_thread(cproc);			} while (cproc != current);		}	} else {		do {			proc = cproc->cptr;			for (; proc != NULL; proc = proc->optr) {				haskid = 1;				if (proc->state == PROC_ZOMBIE) {					goto found;				}			}			cproc = next_thread(cproc);		} while (cproc != current);	}	if (haskid) {		current->state = PROC_SLEEPING;		current->wait_state = WT_CHILD;		schedule();		may_killed();		goto repeat;	}	return -E_BAD_PROC;found:	if (proc == idleproc || proc == initproc) {		panic("wait idleproc or initproc./n");	}	int exit_code = proc->exit_code;	spin_lock_irqsave(&proc_lock, intr_flag);	{		unhash_proc(proc);		remove_links(proc);	}	spin_unlock_irqrestore(&proc_lock, intr_flag);	put_kstack(proc);	kfree(proc);	int ret = 0;	if (code_store != NULL) {		lock_mm(mm);		{			if (!copy_to_user			    (mm, code_store, &exit_code, sizeof(int))) {				ret = -E_INVAL;			}		}		unlock_mm(mm);	}	return ret;}
开发者ID:liangchao1992,项目名称:ucore,代码行数:79,


示例18: debuginfo_eip

// debuginfo_eip(addr, info)////	Fill in the 'info' structure with information about the specified//	instruction address, 'addr'.  Returns 0 if information was found, and//	negative if not.  But even if it returns negative it has stored some//	information into '*info'.//intdebuginfo_eip(uintptr_t addr, struct Eipdebuginfo *info){	const struct Stab *stabs, *stab_end;	const char *stabstr, *stabstr_end;	int lfile, rfile, lfun, rfun, lline, rline;	// Initialize *info	info->eip_file = "<unknown>";	info->eip_line = 0;	info->eip_fn_name = "<unknown>";	info->eip_fn_namelen = 9;	info->eip_fn_addr = addr;	info->eip_fn_narg = 0;	// Find the relevant set of stabs	if (addr >= ULIM) {		stabs = __STAB_BEGIN__;		stab_end = __STAB_END__;		stabstr = __STABSTR_BEGIN__;		stabstr_end = __STABSTR_END__;	} else {		// The user-application linker script, user/user.ld,		// puts information about the application's stabs (equivalent		// to __STAB_BEGIN__, __STAB_END__, __STABSTR_BEGIN__, and		// __STABSTR_END__) in a structure located at virtual address		// USTABDATA.		const struct UserStabData *usd = (const struct UserStabData *) USTABDATA;		// Make sure this memory is valid.		// Return -1 if it is not.  Hint: Call user_mem_check.		// LAB 3: Your code here.		if(user_mem_check(curenv, usd, sizeof(struct UserStabData), PTE_U) < 0)		{			return -1;		}		stabs = usd->stabs;		stab_end = usd->stab_end;		stabstr = usd->stabstr;		stabstr_end = usd->stabstr_end;		// Make sure the STABS and string table memory is valid.		// LAB 3: Your code here.		if(user_mem_check(curenv, stabs, stab_end-stabs, PTE_U) < 0)		{			return -1;		}				if(user_mem_check(curenv, stabstr, stabstr_end-stabstr, PTE_U) < 0)		{			return -1;		}	}	// String table validity checks	if (stabstr_end <= stabstr || stabstr_end[-1] != 0)		return -1;	// Now we find the right stabs that define the function containing	// 'eip'.  First, we find the basic source file containing 'eip'.	// Then, we look in that source file for the function.  Then we look	// for the line number.		// Search the entire set of stabs for the source file (type N_SO).	lfile = 0;	rfile = (stab_end - stabs) - 1;	stab_binsearch(stabs, &lfile, &rfile, N_SO, addr);	if (lfile == 0)		return -1;	// Search within that file's stabs for the function definition	// (N_FUN).	lfun = lfile;	rfun = rfile;	stab_binsearch(stabs, &lfun, &rfun, N_FUN, addr);	if (lfun <= rfun) {		// stabs[lfun] points to the function name		// in the string table, but check bounds just in case.		if (stabs[lfun].n_strx < stabstr_end - stabstr)			info->eip_fn_name = stabstr + stabs[lfun].n_strx;		info->eip_fn_addr = stabs[lfun].n_value;		addr -= info->eip_fn_addr;		// Search within the function definition for the line number.		lline = lfun;		rline = rfun;	} else {		// Couldn't find function stab!  Maybe we're in an assembly		// file.  Search the whole file for the line number.		info->eip_fn_addr = addr;		lline = lfile;		rline = rfile;//.........这里部分代码省略.........
开发者ID:PennPanda,项目名称:mitjos,代码行数:101,


示例19: do_linux_waitpid

intdo_linux_waitpid(int pid, int *code_store) {    struct mm_struct *mm = current->mm;    if (code_store != NULL) {        if (!user_mem_check(mm, (uintptr_t)code_store, sizeof(int), 1)) {            return -E_INVAL;        }    }    struct proc_struct *proc, *cproc;    bool intr_flag, haskid;repeat:    cproc = current;    haskid = 0;    if (pid > 0) {        proc = find_proc(pid);        if (proc != NULL) {            do {                if (proc->parent == cproc) {                    haskid = 1;                    if (proc->state == PROC_ZOMBIE) {                        goto found;                    }                    break;                }                cproc = next_thread(cproc);            } while (cproc != current);        }    }    /* we do NOT have group id, so..*/    else if(pid==0 || pid==-1){ /* pid == 0 */        do {            proc = cproc->cptr;            for (; proc != NULL; proc = proc->optr) {                haskid = 1;                if (proc->state == PROC_ZOMBIE) {                    goto found;                }            }            cproc = next_thread(cproc);        } while (cproc != current);    }else{ //pid<-1      //TODO      return -E_INVAL;    }    if (haskid) {        current->state = PROC_SLEEPING;        current->wait_state = WT_CHILD;        schedule();        may_killed();        goto repeat;    }    return -E_BAD_PROC;found:    if (proc == idleproc || proc == initproc) {        panic("wait idleproc or initproc./n");    }    int exit_code = proc->exit_code;    int return_pid = proc->pid;    local_intr_save(intr_flag);    {        unhash_proc(proc);        remove_links(proc);    }    local_intr_restore(intr_flag);    put_kstack(proc);    kfree(proc);    int ret = 0;    if (code_store != NULL) {        lock_mm(mm);        {            int status = exit_code << 8;            if (!copy_to_user(mm, code_store, &status, sizeof(int))) {                ret = -E_INVAL;            }        }        unlock_mm(mm);    }    return (ret == 0) ? return_pid : ret;}
开发者ID:chyyuu,项目名称:ucore-arch-arm,代码行数:82,



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


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