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

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

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

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

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

示例1: binfmt_load

int binfmt_load(struct proc *proc, const char *path, struct proc **ref){    struct vnode vnode;    struct inode *inode = NULL;    int err = 0;    struct uio uio;    memset(&uio, 0, sizeof(struct uio));    if (proc) {        uio = PROC_UIO(proc);    }    if ((err = vfs_lookup(path, &uio, &vnode, NULL)))        return err;    if ((err = vfs_vget(&vnode, &inode)))        return err;    for (size_t i = 0; i < NR_BINFMT; ++i) {        if (!binfmt_list[i].check(inode)) {            binfmt_fmt_load(proc, path, inode, &binfmt_list[i], ref);            vfs_close(inode);            return 0;        }    }    vfs_close(inode);    return -ENOEXEC;}
开发者ID:mohamed-anwar,项目名称:Aquila,代码行数:30,


示例2: vfs_open

/////////////////////////////////////////////////////////////////////// Mapper 20boolNES_mapper20::initialize (NES *parent, NES_PPU *ppu){  hfile_t fp = NULL;  uint8 header[16];    if (!(NES_mapper::initialize (parent, ppu)))    goto error;    fp = vfs_open (parent->disksys_rom_filename, VFS_READ);  if (!fp)  {    ERROR("no disksys.rom");    ERROR(parent->disksys_rom_filename);    goto error;  }    if (vfs_read(header, sizeof(header), 1, fp) != sizeof(header))    goto error;    if (!NES_MEMCMP (header, "NES", 3))    vfs_seek(fp, 0x6010, VFS_SEEK_SET);  else    vfs_seek(fp, 0, VFS_SEEK_SET);    if (vfs_read(bios, 0x2000, 1, fp) != 0x2000)    goto error;    vfs_close(fp);  return true;  error:  if (fp) vfs_close(fp);  return false;}
开发者ID:github188,项目名称:CC6000M_LQ_V3.1_DSCA5.2,代码行数:37,


示例3: op_write

void op_write(const char **params, int nparams) {  assert(nparams > 1);  inode_t *ino = vfs_open(params[0], &dummy_access);  if (!ino) {    /* Find parent. */    char *str = NULL;    int i;    for (i = strlen(params[0]); i >= 0; --i) {      if (params[0][i] == '/') {        str = kmalloc(i+1);        strncpy(str, params[0], i);        str[i] = '/0';        break;      }    }    assert(str && "Parent directory not found!");    ino = vfs_open(str, &dummy_access);    assert(ino && "Parent directory not found!");    vfs_mknod(ino, &params[0][i+1], it_file, 0755, 0, 0);    vfs_close(ino);    ino = vfs_open(params[0], &dummy_access);    assert(ino && "File not found after having created it!");  }  assert(ino && "File not found!");  assert(ino->type == it_file && "File is not a regular file!");  vfs_write(ino, 0, (void*)params[1], strlen(params[1]));  vfs_close(ino);}
开发者ID:RobinVan,项目名称:JMTK,代码行数:34,


示例4: runprogram

intrunprogram(char *progname){	struct addrspace *as;	struct vnode *v;	vaddr_t entrypoint, stackptr;	int result;	/* Open the file. */	result = vfs_open(progname, O_RDONLY, 0, &v);	if (result) {		return result;	}	/* We should be a new process. */	KASSERT(curproc_getas() == NULL);	/* Create a new address space. */	#if OPT_A3	as = as_create(progname);	#else	as = as_create();	#endif	if (as ==NULL) {		vfs_close(v);		return ENOMEM;	}	/* Switch to it and activate it. */	curproc_setas(as);	as_activate();	/* Load the executable. */	result = load_elf(v, &entrypoint);	if (result) {		/* p_addrspace will go away when curproc is destroyed */		vfs_close(v);		return result;	}	/* Done with the file now. */	vfs_close(v);	/* Define the user stack in the address space */	result = as_define_stack(as, &stackptr);	if (result) {		/* p_addrspace will go away when curproc is destroyed */		return result;	}	/* Warp to user mode. */	enter_new_process(0 /*argc*/, NULL /*userspace addr of argv*/,			  stackptr, entrypoint);		/* enter_new_process does not return. */	panic("enter_new_process returned/n");	return EINVAL;}
开发者ID:mellwa,项目名称:os,代码行数:58,


示例5: ui_load_onmov_file

BOOL ui_load_onmov_file(void){    partition_t *p_partition = NULL;    u32 partition_cnt = 0;    u16 file_name[MAX_FILE_PATH] = {0};    hfile_t file = NULL;    u8 identify[3] = {0};    u16 *p_line = NULL;    partition_cnt = file_list_get_partition(&p_partition);    if (partition_cnt > 0)    {        file_name[0] = p_partition[0].letter[0];        str_asc2uni("://onmov.txt", file_name + 1);    }#ifdef WIN32    str_asc2uni("C://onmov.txt", file_name);#endif    file = vfs_open(file_name, VFS_READ);    if(file == NULL)    {        return FALSE;    }    vfs_read((void *)identify, 1, 2, file);    if (strcmp(identify, "/xFF/xFE") && strcmp(identify, "/xFE/xFF"))    {        vfs_close(file);        return FALSE;    }    p_line = freadline(file);    if (p_line != NULL)    {        mtos_free(p_line);        p_line = NULL;    }    while (TRUE)    {        p_line = freadline(file);        if (p_line == NULL)        {            break;        }        parse(p_line);        mtos_free(p_line);        p_line = NULL;    }    vfs_close(file);    return TRUE;}
开发者ID:kuikuitage,项目名称:CC6000M_LQ_V3.1_DSCA5.2,代码行数:58,


示例6: cmd_vfs_sha256

static int cmd_vfs_sha256(struct vmm_chardev *cdev, const char *path){	int fd, rc, i;	u32 len;	size_t buf_rd;	u8 buf[VFS_LOAD_BUF_SZ];	struct stat st;	struct sha256_context sha256c;	sha256_digest_t digest;	fd = vfs_open(path, O_RDONLY, 0);	if (fd < 0) {		vmm_cprintf(cdev, "Failed to open %s/n", path);		return fd;	}	rc = vfs_fstat(fd, &st);	if (rc) {		vfs_close(fd);		vmm_cprintf(cdev, "Failed to stat %s/n", path);		return rc;	}	if (!(st.st_mode & S_IFREG)) {		vfs_close(fd);		vmm_cprintf(cdev, "Cannot read %s/n", path);		return VMM_EINVALID;	}	len = st.st_size;	sha256_init(&sha256c);	while (len) {		memset(buf, 0, sizeof(buf));		buf_rd = (len < VFS_LOAD_BUF_SZ) ? len : VFS_LOAD_BUF_SZ;		buf_rd = vfs_read(fd, buf, buf_rd);		if (buf_rd < 1) {			break;		}		sha256_update(&sha256c, buf, buf_rd);	}	sha256_final(digest, &sha256c);	vmm_cprintf(cdev, "SHA-256 Digest: ");	for (i = 0; i < SHA256_DIGEST_LEN; i++)		vmm_cprintf(cdev, "%x", digest[i]);	vmm_cprintf(cdev, "/n");	rc = vfs_close(fd);	if (rc) {		vmm_cprintf(cdev, "Failed to close %s/n", path);		return rc;	}	return VMM_OK;}
开发者ID:MaiDaftedar,项目名称:xvisor-next,代码行数:58,


示例7: cron_write_error

int16_tcron_write_error(struct vfs_file_handle_t * file){  vfs_close(file);  /* truncate file */  vfs_close(vfs_open(CRON_FILENAME));  return -1;}
开发者ID:NhaTrang,项目名称:ethersex-avr-net-io,代码行数:9,


示例8: cmd_vfs_load

static int cmd_vfs_load(struct vmm_chardev *cdev, physical_addr_t pa, 			const char *path, u32 off, u32 len){	int fd, rc;	size_t buf_rd, rd_count;	char buf[VFS_LOAD_BUF_SZ];	struct stat st;	fd = vfs_open(path, O_RDONLY, 0);	if (fd < 0) {		vmm_cprintf(cdev, "Failed to open %s/n", path);		return fd;	}	rc = vfs_fstat(fd, &st);	if (rc) {		vfs_close(fd);		vmm_cprintf(cdev, "Failed to stat %s/n", path);		return rc;	}	if (!(st.st_mode & S_IFREG)) {		vfs_close(fd);		vmm_cprintf(cdev, "Cannot read %s/n", path);		return VMM_EINVALID;	}	if (off >= st.st_size) {		vfs_close(fd);		vmm_cprintf(cdev, "Offset greater than file size/n", path);		return VMM_EINVALID;	}	len = ((st.st_size - off) < len) ? (st.st_size - off) : len;	rd_count = 0;	while (len) {		buf_rd = (len < VFS_LOAD_BUF_SZ) ? len : VFS_LOAD_BUF_SZ;		buf_rd = vfs_read(fd, buf, buf_rd);		if (buf_rd < 1) {			break;		}		vmm_host_memory_write(pa, buf, buf_rd);		len -= buf_rd;		rd_count += buf_rd;	}	vmm_cprintf(cdev, "Loaded %d bytes/n", rd_count);	rc = vfs_close(fd);	if (rc) {		vmm_cprintf(cdev, "Failed to close %s/n", path);		return rc;	}	return VMM_OK;}
开发者ID:CoryXie,项目名称:xvisor,代码行数:57,


示例9: file_open_end

static void file_open_end(void *token, int err, struct vnode *vn) {    dprintf(3, "file_open_end called/n");    assert(token != NULL);    cont_file_open_t *cont = (cont_file_open_t*)token;    if (err) {        cont->callback(cont->token, err, -1);        free(cont);        return;    }    // Compare openning permission with file permission    int accmode = cont->flags & O_ACCMODE;    bool file_readable = vn->sattr.st_mode & S_IRUSR;    bool file_writable = vn->sattr.st_mode & S_IWUSR;    dprintf(3, "file_readable = %d, file_writable = %d/n", (int)file_readable, (int)file_writable);    if ((accmode == O_RDONLY && !file_readable) ||        (accmode == O_WRONLY && !file_writable) ||        (accmode == O_RDWR && !(file_readable && file_writable)))    {        vfs_close(vn, cont->flags);        cont->callback(cont->token, EINVAL, -1);        free(cont);        return;    }    struct openfile *file;    int fd;    file = malloc(sizeof(struct openfile));    dprintf(3, "created an openfile at %p/n", file);    if (file == NULL) {        vfs_close(vn, cont->flags);        cont->callback(cont->token, ENOMEM, -1);        free(cont);        return;    }    file->of_offset = 0;    file->of_accmode = accmode;    file->of_refcount = 1;    file->of_vnode = vn;    /* place the file in the filetable, getting the file descriptor */    err = filetable_placefile(file, &fd);    if (err) {        free(file);        vfs_close(vn, cont->flags);        cont->callback(cont->token, err, -1);        free(cont);        return;    }    cont->callback(cont->token, 0, fd);    free(cont);}
开发者ID:gapry,项目名称:AOS,代码行数:56,


示例10: runprogram

/* * Load program "progname" and start running it in usermode. * Does not return except on error. * * Calls vfs_open on progname and thus may destroy it. */intrunprogram(char *progname){	struct vnode *v;	vaddr_t entrypoint, stackptr;	int result;	/* Open the file. */	result = vfs_open(progname, O_RDONLY, 0, &v);	if (result) {		return result;	}	/* We should be a new thread. */	KASSERT(curthread->t_addrspace == NULL);	/* Create a new address space. */	curthread->t_addrspace = as_create();	if (curthread->t_addrspace==NULL) {		vfs_close(v);		return ENOMEM;	}	curthread->t_filetable = filetable_create();	if(curthread->t_filetable == NULL){		return ENOMEM;	}	/* Activate it. */	as_activate(curthread->t_addrspace);	/* Load the executable. */	result = load_elf(v, &entrypoint);	if (result) {		/* thread_exit destroys curthread->t_addrspace */		vfs_close(v);		return result;	}	/* Done with the file now. */	vfs_close(v);	/* Define the user stack in the address space */	result = as_define_stack(curthread->t_addrspace, &stackptr);	if (result) {		/* thread_exit destroys curthread->t_addrspace */		return result;	}	/* Warp to user mode. */	enter_new_process(0 /*argc*/, NULL /*userspace addr of argv*/,			  stackptr, entrypoint);		/* enter_new_process does not return. */	panic("enter_new_process returned/n");	return EINVAL;}
开发者ID:JayP16,项目名称:OS161,代码行数:62,


示例11: elf_header_read

static error_t elf_header_read(char* pathname, struct vfs_file_s **file, Elf32_Ehdr **header){ 	kmem_req_t req;	Elf32_Ehdr *e_header;	uint_t refcount;	register error_t err;	register size_t eh_size;	register ssize_t count;	if((err = vfs_open(current_task->vfs_cwd, pathname, VFS_O_RDONLY, 0, file)))	{		printk(ERROR, "/nERROR: elf_header_read: faild to open executable file, error %d/n", err);		return err;	}  	eh_size = sizeof(*e_header);	req.type  = KMEM_GENERIC;	req.size  = eh_size;	req.flags = AF_USER;	if((e_header = kmem_alloc(&req)) == NULL)	{		vfs_close(*file, &refcount);		return -ENOMEM;	}	if((count= vfs_read(*file, (uint8_t*)e_header, eh_size)) != eh_size)	{		printk(ERROR, "/nERROR: elf_header_read: faild to read ELF header, got %d bytes, expected %d bytes/n", count, eh_size);		err = (error_t)count;		goto ELF_HEADER_READ_ERR;	}	if(!(err= elf_isElfHeader(e_header)))	{		printk(ERROR, "/nERROR: elf_header_read: executable is not in ELF format/n");		goto ELF_HEADER_READ_ERR;	}	if(!(err= elf_isValidHeader(e_header)))	{		printk(ERROR, "/nERROR: elf_header_read: not supported Elf/n");		goto ELF_HEADER_READ_ERR;	} 	*header = e_header;	return 0; ELF_HEADER_READ_ERR:	vfs_close(*file, &refcount);	req.ptr = e_header;	kmem_free(&req);	return -1;}
开发者ID:Masshat,项目名称:almos,代码行数:55,


示例12: runprogram

/* * Load program "progname" and start running it in usermode. * Does not return except on error. * * Calls vfs_open on progname and thus may destroy it. */intrunprogram(char *progname){	struct vnode *v;	vaddr_t entrypoint, stackptr;	int result;	/* Open the file. */	result = vfs_open(progname, O_RDONLY, &v);	if (result) {		return result;	}	/* We should be a new thread. */	assert(curthread->t_vmspace == NULL);	/* Create a new address space. */	curthread->t_vmspace = as_create();	if (curthread->t_vmspace==NULL) {		vfs_close(v);		return ENOMEM;	}	//kprintf("/n in runprogram");	assignPid();	/* Activate it. */	as_activate(curthread->t_vmspace);	/* Load the executable. */	result = load_elf(v, &entrypoint);	if (result) {		/* thread_exit destroys curthread->t_vmspace */		vfs_close(v);		return result;	}	/* Done with the file now. */	vfs_close(v);	/* Define the user stack in the address space */	result = as_define_stack(curthread->t_vmspace, &stackptr);	if (result) {		/* thread_exit destroys curthread->t_vmspace */		return result;	}	/* Warp to user mode. */	md_usermode(0 /*argc*/, NULL /*userspace addr of argv*/,		    stackptr, entrypoint);		/* md_usermode does not return */	panic("md_usermode returned/n");	return EINVAL;}
开发者ID:aditi-d,项目名称:csci340,代码行数:60,


示例13: thread_exit

/* * Cause the current thread to exit. * * We clean up the parts of the thread structure we don't actually * need to run right away. The rest has to wait until thread_destroy * gets called from exorcise(). */voidthread_exit(void){	if (curthread->t_stack != NULL) {		/*		 * Check the magic number we put on the bottom end of		 * the stack in thread_fork. If these assertions go		 * off, it most likely means you overflowed your stack		 * at some point, which can cause all kinds of		 * mysterious other things to happen.		 */		assert(curthread->t_stack[0] == (char)0xae);		assert(curthread->t_stack[1] == (char)0x11);		assert(curthread->t_stack[2] == (char)0xda);		assert(curthread->t_stack[3] == (char)0x33);	}        #if OPT_A2        vfs_close(curthread->ft[0]->file);        vfs_close(curthread->ft[1]->file);        vfs_close(curthread->ft[2]->file);        #endif	splhigh();	if (curthread->t_vmspace) {		/*		 * Do this carefully to avoid race condition with		 * context switch code.		 */		struct addrspace *as = curthread->t_vmspace;		curthread->t_vmspace = NULL;		as_destroy(as);	}	if (curthread->t_cwd) {		VOP_DECREF(curthread->t_cwd);		curthread->t_cwd = NULL;	}	assert(numthreads>0);	numthreads--;       /* #if OPT_A2        struct process* current = p_table[curthread->pid];        if (current->ppid != -1){           struct process* parent = p_table[current->ppid];           if (parent->waiting) cv_broadcast(parent->exit,parent->exitlock);        }                 #endif        */	mi_switch(S_ZOMB);	panic("Thread came back from the dead!/n");}
开发者ID:jessZhAnG,项目名称:OS,代码行数:60,


示例14: cp_func

error_t cp_func(void *param){  char *src_name;  char *dest_name;  error_t err;  uint32_t argc;  uint32_t i;  ssize_t size;  struct vfs_file_s *src_file;  struct vfs_file_s *dest_file;  ms_args_t *args;  uint_t count;			/* FIXME to be correctly used */  args  = (ms_args_t *) param;  argc = args->argc;  dest_name = args->argv[argc - 1];  err = 0;    if((err=vfs_open(ms_n_cwd,dest_name,VFS_O_WRONLY | VFS_O_CREATE,0,&dest_file)))    return err;    argc --;  for(i=1; i< argc; i++)  {    src_name = args->argv[i];        if((err=vfs_open(ms_n_cwd,src_name,VFS_O_RDONLY,0,&src_file))){      vfs_close(dest_file, &count);      ksh_print("error while opinig %s/n",src_name);      return err;    }    size = 0;    while((size = vfs_read(src_file,buffer,BUFFER_SIZE)) > 0)    {      if((size=vfs_write(dest_file,buffer,size)) < 0)	goto CP_FUNC_ERROR;    }        if(size < 0) goto CP_FUNC_ERROR;    vfs_close(src_file, &count);  }  vfs_close(dest_file,&count);  return 0; CP_FUNC_ERROR:  vfs_close(src_file,&count);  vfs_close(dest_file,&count);   return size;}
开发者ID:Masshat,项目名称:almos,代码行数:51,


示例15: xsync_handle

static void xsync_handle(struct xsync_ctx_t * ctx){	uint8_t buf[PACKET_DATA_MAX];	size_t size;	switch(ctx->packet.command)	{	case XSYNC_COMMAND_ALIVE:		size = sprintf((char *)buf, "%s", machine_uniqueid());		xsync_put(XSYNC_COMMAND_ALIVE, buf, size);		break;	case XSYNC_COMMAND_START:		buf[0] = xsync_handle_start(ctx);		xsync_put(XSYNC_COMMAND_START, buf, 1);		break;	case XSYNC_COMMAND_TRANSFER:		vfs_write(ctx->fd, (void *)ctx->packet.data, packet_dsize(&ctx->packet));		xsync_put(XSYNC_COMMAND_TRANSFER, 0, 0);		break;	case XSYNC_COMMAND_STOP:		if(ctx->fd > 0)		{			vfs_close(ctx->fd);			ctx->fd = -1;		}		xsync_put(XSYNC_COMMAND_STOP, 0, 0);		break;	case XSYNC_COMMAND_SYSTEM:		xsync_put(XSYNC_COMMAND_SYSTEM, 0, 0);		ctx->quit = 1;		if(ctx->fd > 0)		{			vfs_close(ctx->fd);			ctx->fd = -1;		}		memset(buf, 0, sizeof(buf));		memcpy(buf, &ctx->packet.data[0], packet_dsize(&ctx->packet));		shell_system((const char *)buf);		break;	default:		xsync_put(XSYNC_COMMAND_UNKOWN, 0, 0);		break;	}}
开发者ID:xboot,项目名称:xboot,代码行数:49,


示例16: ui_find_usb_pgdata_file

BOOL ui_find_usb_pgdata_file(void){  hfile_t file = NULL;  channel_data_t * p_channel_data = NULL;  u32 channel_data_size = 0;  u16 filename[MAX_DB_FILE_NAME_LENGTH] = {0};  u32 len = 0;    ui_dbase_mk_db_filename(filename, IW_CHANNEL_DATA_FILE_NAME);    channel_data_size = sizeof(channel_data_t);  p_channel_data = mtos_malloc(channel_data_size);  if(NULL == p_channel_data)  {    OS_PRINTF("@@ %s, p_channel_data malloc failed, size = %d /n", __FUNCTION__, channel_data_size);    return FALSE;  }  memset(p_channel_data, 0, channel_data_size);    //open file --  file = vfs_open(filename, VFS_READ);  if(file != NULL)  {    len = vfs_read(p_channel_data, channel_data_size,  1, file);    if(len != channel_data_size)    {      OS_PRINTF("@@ %s :%d /n", __FUNCTION__, __LINE__);        vfs_close(file);      mtos_free(p_channel_data);      return FALSE;    }  }  else  {    OS_PRINTF("@@ %s :%d /n", __FUNCTION__, __LINE__);      vfs_close(file);    mtos_free(p_channel_data);    return FALSE;  }    if(p_channel_data->total_pg_num == 0 || p_channel_data->total_tp_num == 0)  {    mtos_free(p_channel_data);    return FALSE;  }  mtos_free(p_channel_data);  return TRUE;}
开发者ID:github188,项目名称:CC6000M_LQ_V3.1_DSCA5.2,代码行数:48,


示例17: action_check_copy_vfs

//--------------------------------------------------------------------------------------------mad_t * action_check_copy_vfs( mad_t * pmad, const char* loadname ){    /// @details [email
C++ vfs_create函数代码示例
C++ vfree函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。