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

C++ os_close_file函数代码示例

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

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



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

示例1: slirp_close

static void slirp_close(int fd, void *data)
{
	struct slirp_data *pri = data;
	int status,err;

	os_close_file(fd);
	os_close_file(pri->slave);

	pri->slave = -1;

	if(pri->pid<1) {
		printk("slirp_close: no child process to shut down\n");
		return;
	}

#if 0
	if(kill(pri->pid, SIGHUP)<0) {
		printk("slirp_close: sending hangup to %d failed (%d)\n",
			pri->pid, errno);
	}
#endif

	CATCH_EINTR(err = waitpid(pri->pid, &status, WNOHANG));
	if(err < 0) {
		printk("slirp_close: waitpid returned %d\n", errno);
		return;
	}

	if(err == 0) {
		printk("slirp_close: process %d has not exited\n", pri->pid);
		return;
	}

	pri->pid = -1;
}
开发者ID:420GrayFox,项目名称:dsl-n55u-bender,代码行数:35,代码来源:slirp_user.c


示例2: os_process_pc

unsigned long os_process_pc(int pid)
{
	char proc_stat[STAT_PATH_LEN], buf[256];
	unsigned long pc;
	int fd, err;

	sprintf(proc_stat, "/proc/%d/stat", pid);
	fd = os_open_file(proc_stat, of_read(OPENFLAGS()), 0);
	if(fd < 0){
		printk("os_process_pc - couldn't open '%s', err = %d\n",
		       proc_stat, -fd);
		return(ARBITRARY_ADDR);
	}
	err = os_read_file(fd, buf, sizeof(buf));
	if(err < 0){
		printk("os_process_pc - couldn't read '%s', err = %d\n",
		       proc_stat, -err);
		os_close_file(fd);
		return(ARBITRARY_ADDR);
	}
	os_close_file(fd);
	pc = ARBITRARY_ADDR;
	if(sscanf(buf, "%*d " COMM_SCANF " %*c %*d %*d %*d %*d %*d %*d %*d "
		  "%*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d "
		  "%*d %*d %*d %*d %*d %lu", &pc) != 1){
		printk("os_process_pc - couldn't find pc in '%s'\n", buf);
	}
	return(pc);
}
开发者ID:BackupTheBerlios,项目名称:tuxap,代码行数:29,代码来源:process.c


示例3: slirp_open

static int slirp_open(void *data)
{
	struct slirp_data *pri = data;
	int fds[2], pid, err;

	err = os_pipe(fds, 1, 1);
	if(err)
		return(err);

	err = slirp_tramp(pri->argw.argv, fds[1]);
	if(err < 0){
		printk("slirp_tramp failed - errno = %d\n", -err);
		goto out;
	}
	pid = err;

	pri->slave = fds[1];
	pri->slip.pos = 0;
	pri->slip.esc = 0;
	pri->pid = err;

	return(fds[0]);
out:
	os_close_file(fds[0]);
	os_close_file(fds[1]);
	return err;
}
开发者ID:420GrayFox,项目名称:dsl-n55u-bender,代码行数:27,代码来源:slirp_user.c


示例4: etap_pre_exec

static void etap_pre_exec(void *arg)
{
	struct etap_pre_exec_data *data = arg;

	dup2(data->control_remote, 1);
	os_close_file(data->data_me);
	os_close_file(data->control_me);
}
开发者ID:420GrayFox,项目名称:dsl-n55u-bender,代码行数:8,代码来源:ethertap_user.c


示例5: daemon_remove

static void daemon_remove(void *data)
{
	struct daemon_data *pri = data;

	os_close_file(pri->fd);
	os_close_file(pri->control);
	kfree(pri->data_addr);
	kfree(pri->ctl_addr);
	kfree(pri->local_addr);
}
开发者ID:BackupTheBerlios,项目名称:tew632-brp-svn,代码行数:10,代码来源:daemon_user.c


示例6: slip_tramp

static int slip_tramp(char **argv, int fd)
{
	struct slip_pre_exec_data pe_data;
	char *output;
	int status, pid, fds[2], err, output_len;

	err = os_pipe(fds, 1, 0);
	if(err < 0){
		printk("slip_tramp : pipe failed, err = %d\n", -err);
		goto out;
	}

	err = 0;
	pe_data.stdin = fd;
	pe_data.stdout = fds[1];
	pe_data.close_me = fds[0];
	err = run_helper(slip_pre_exec, &pe_data, argv, NULL);
	if(err < 0)
		goto out_close;
	pid = err;

	output_len = page_size();
	output = um_kmalloc(output_len);
	if(output == NULL){
		printk("slip_tramp : failed to allocate output buffer\n");
		os_kill_process(pid, 1);
		err = -ENOMEM;
		goto out_free;
	}

	os_close_file(fds[1]);
	read_output(fds[0], output, output_len);
	printk("%s", output);

	CATCH_EINTR(err = waitpid(pid, &status, 0));
	if(err < 0)
		err = errno;
	else if(!WIFEXITED(status) || (WEXITSTATUS(status) != 0)){
		printk("'%s' didn't exit with status 0\n", argv[0]);
		err = -EINVAL;
	}
	else err = 0;

	os_close_file(fds[0]);

out_free:
	kfree(output);
	return err;

out_close:
	os_close_file(fds[0]);
	os_close_file(fds[1]);
out:
	return err;
}
开发者ID:FatSunHYS,项目名称:OSCourseDesign,代码行数:55,代码来源:slip_user.c


示例7: pre_exec

static void pre_exec(void *d)
{
	struct dog_data *data = d;

	dup2(data->stdin, 0);
	dup2(data->stdout, 1);
	dup2(data->stdout, 2);
	os_close_file(data->stdin);
	os_close_file(data->stdout);
	os_close_file(data->close_me[0]);
	os_close_file(data->close_me[1]);
}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:12,代码来源:harddog_user.c


示例8: etap_close

static void etap_close(int fd, void *data)
{
	struct ethertap_data *pri = data;

	iter_addresses(pri->dev, etap_close_addr, &pri->control_fd);
	os_close_file(fd);
	os_shutdown_socket(pri->data_fd, 1, 1);
	os_close_file(pri->data_fd);
	pri->data_fd = -1;
	os_close_file(pri->control_fd);
	pri->control_fd = -1;
}
开发者ID:420GrayFox,项目名称:dsl-n55u-bender,代码行数:12,代码来源:ethertap_user.c


示例9: os_process_parent

int os_process_parent(int pid)
{
	char stat[STAT_PATH_LEN];
	char data[256];
	int parent, n, fd;

	if(pid == -1) return(-1);

	snprintf(stat, sizeof(stat), "/proc/%d/stat", pid);
	fd = os_open_file(stat, of_read(OPENFLAGS()), 0);
	if(fd < 0){
		printk("Couldn't open '%s', err = %d\n", stat, -fd);
		return(FAILURE_PID);
	}

	n = os_read_file(fd, data, sizeof(data));
	os_close_file(fd);

	if(n < 0){
		printk("Couldn't read '%s', err = %d\n", stat, -n);
		return(FAILURE_PID);
	}

	parent = FAILURE_PID;
	n = sscanf(data, "%*d " COMM_SCANF " %*c %d", &parent);
	if(n != 1)
		printk("Failed to scan '%s'\n", data);

	return(parent);
}
开发者ID:BackupTheBerlios,项目名称:tuxap,代码行数:30,代码来源:process.c


示例10: change_pre_exec

static void change_pre_exec(void *arg)
{
	struct change_pre_exec_data *data = arg;

	os_close_file(data->close_me);
	dup2(data->stdout, 1);
}
开发者ID:OpenHMR,项目名称:Open-HMR600,代码行数:7,代码来源:net_user.c


示例11: file_close

void file_close(file_t* file)
{
    u32 i;
    cache_entry_t* entry;
    
    /* Unmap cached pages. */
    for (i = 0; i < CACHE_SIZE; i++) {
        entry = &file->cache.entries[i];
        if (entry->ptr != NULL) {
            if (entry->ref > 0) {
                fprintf(stderr, "file_close: unmapping used page %u (%p)\n",
                        entry->pageid, entry->ptr);
            }
            
            DPRINT("file_close: unmapping cached page %u (%p)\n",
                   entry->pageid, entry->ptr);
            if (os_put_page(file->handle, entry->ptr) == 0)
                file->stats.unmapped++;
        }
    }
    
#if !defined(NSTATS)
    file_dump_info(file);
#endif /* !defined(NSTATS) */

    /* Unmap the header page. */
    os_put_page(file->handle, file->header);

    /* Close the file. */
    os_close_file(file->handle);

    /* Free the file object. */
    memset(file, 0, sizeof(file_t));
    free(file);
}
开发者ID:acampbell,项目名称:kscope,代码行数:35,代码来源:file.c


示例12: destroy_context

void destroy_context(struct mm_struct *mm)
{
	struct mm_context *mmu = &mm->context;

	if (proc_mm)
		os_close_file(mmu->id.u.mm_fd);
	else {
		/*
		 * If init_new_context wasn't called, this will be
		 * zero, resulting in a kill(0), which will result in the
		 * whole UML suddenly dying.  Also, cover negative and
		 * 1 cases, since they shouldn't happen either.
		 */
		if (mmu->id.u.pid < 2) {
			printk(KERN_ERR "corrupt mm_context - pid = %d\n",
			       mmu->id.u.pid);
			return;
		}
		os_kill_ptraced_process(mmu->id.u.pid, 1);
	}

	if (skas_needs_stub)
		free_page(mmu->id.stack);

	free_ldt(mmu);
}
开发者ID:openube,项目名称:android_kernel_sony_c2305,代码行数:26,代码来源:mmu.c


示例13: file_removed

static int file_removed(struct dentry *dentry, const char *file)
{
	char *host_file;
	int extra, fd;

	extra = 0;
	if(file != NULL) extra += strlen(file) + 1;

	host_file = dentry_name(dentry, extra + strlen("/remove"));
	if(host_file == NULL){
		printk("file_removed : allocation failed\n");
		return(-ENOMEM);
	}

	if(file != NULL){
		strcat(host_file, "/");
		strcat(host_file, file);
	}
	strcat(host_file, "/remove");

	fd = os_open_file(host_file, of_read(OPENFLAGS()), 0);
	kfree(host_file);
	if(fd >= 0){
		os_close_file(fd);
		return(1);
	}
	return(0);
}
开发者ID:romanalexander,项目名称:Trickles,代码行数:28,代码来源:hppfs_kern.c


示例14: os_process_pc

unsigned long os_process_pc(int pid)
{
	char proc_stat[STAT_PATH_LEN], buf[256];
	unsigned long pc = ARBITRARY_ADDR;
	int fd, err;

	sprintf(proc_stat, "/proc/%d/stat", pid);
	fd = open(proc_stat, O_RDONLY, 0);
	if (fd < 0) {
		printk(UM_KERN_ERR "os_process_pc - couldn't open '%s', "
		       "errno = %d\n", proc_stat, errno);
		goto out;
	}
	CATCH_EINTR(err = read(fd, buf, sizeof(buf)));
	if (err < 0) {
		printk(UM_KERN_ERR "os_process_pc - couldn't read '%s', "
		       "err = %d\n", proc_stat, errno);
		goto out_close;
	}
	os_close_file(fd);
	pc = ARBITRARY_ADDR;
	if (sscanf(buf, "%*d " COMM_SCANF " %*c %*d %*d %*d %*d %*d %*d %*d "
		   "%*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d "
		   "%*d %*d %*d %*d %*d %lu", &pc) != 1)
		printk(UM_KERN_ERR "os_process_pc - couldn't find pc in '%s'\n",
		       buf);
 out_close:
	close(fd);
 out:
	return pc;
}
开发者ID:08opt,项目名称:linux,代码行数:31,代码来源:process.c


示例15: tuntap_open_tramp

static int tuntap_open_tramp(char *gate, int *fd_out, int me, int remote,
			     char *buffer, int buffer_len, int *used_out)
{
	struct tuntap_pre_exec_data data;
	char version_buf[sizeof("nnnnn\0")];
	char *argv[] = { "uml_net", version_buf, "tuntap", "up", gate,
			 NULL };
	char buf[CMSG_SPACE(sizeof(*fd_out))];
	struct msghdr msg;
	struct cmsghdr *cmsg;
	struct iovec iov;
	int pid, n, err;

	sprintf(version_buf, "%d", UML_NET_VERSION);

	data.stdout = remote;
	data.close_me = me;

	pid = run_helper(tuntap_pre_exec, &data, argv, NULL);

	if(pid < 0) return(-pid);

	os_close_file(remote);

	msg.msg_name = NULL;
	msg.msg_namelen = 0;
	if(buffer != NULL){
		iov = ((struct iovec) { buffer, buffer_len });
开发者ID:420GrayFox,项目名称:dsl-n55u-bender,代码行数:28,代码来源:tuntap_user.c


示例16: tuntap_pre_exec

static void tuntap_pre_exec(void *arg)
{
	struct tuntap_pre_exec_data *data = arg;
	
	dup2(data->stdout, 1);
	os_close_file(data->close_me);
}
开发者ID:420GrayFox,项目名称:dsl-n55u-bender,代码行数:7,代码来源:tuntap_user.c


示例17: etap_tramp

static int etap_tramp(char *dev, char *gate, int control_me, 
		      int control_remote, int data_me, int data_remote)
{
	struct etap_pre_exec_data pe_data;
	int pid, status, err, n;
	char version_buf[sizeof("nnnnn\0")];
	char data_fd_buf[sizeof("nnnnnn\0")];
	char gate_buf[sizeof("nnn.nnn.nnn.nnn\0")];
	char *setup_args[] = { "uml_net", version_buf, "ethertap", dev,
			       data_fd_buf, gate_buf, NULL };
	char *nosetup_args[] = { "uml_net", version_buf, "ethertap", 
				 dev, data_fd_buf, NULL };
	char **args, c;

	sprintf(data_fd_buf, "%d", data_remote);
	sprintf(version_buf, "%d", UML_NET_VERSION);
	if(gate != NULL){
		strcpy(gate_buf, gate);
		args = setup_args;
	}
	else args = nosetup_args;

	err = 0;
	pe_data.control_remote = control_remote;
	pe_data.control_me = control_me;
	pe_data.data_me = data_me;
	pid = run_helper(etap_pre_exec, &pe_data, args, NULL);

	if(pid < 0) err = pid;
	os_close_file(data_remote);
	os_close_file(control_remote);
	n = os_read_file(control_me, &c, sizeof(c));
	if(n != sizeof(c)){
		printk("etap_tramp : read of status failed, err = %d\n", -n);
		return(-EINVAL);
	}
	if(c != 1){
		printk("etap_tramp : uml_net failed\n");
		err = -EINVAL;
		CATCH_EINTR(n = waitpid(pid, &status, 0));
		if(n < 0)
			err = -errno;
		else if(!WIFEXITED(status) || (WEXITSTATUS(status) != 1))
			printk("uml_net didn't exit with status 1\n");
	}
	return(err);
}
开发者ID:420GrayFox,项目名称:dsl-n55u-bender,代码行数:47,代码来源:ethertap_user.c


示例18: release_thread_tt

void release_thread_tt(struct task_struct *task)
{
	int pid = task->thread.mode.tt.extern_pid;

	/*
         * We first have to kill the other process, before
         * closing its switch_pipe. Else it might wake up
         * and receive "EOF" before we could kill it.
         */
	if(os_getpid() != pid)
		os_kill_process(pid, 0);

        os_close_file(task->thread.mode.tt.switch_pipe[0]);
        os_close_file(task->thread.mode.tt.switch_pipe[1]);
	/* use switch_pipe as flag: thread is released */
        task->thread.mode.tt.switch_pipe[0] = -1;
}
开发者ID:420GrayFox,项目名称:dsl-n55u-bender,代码行数:17,代码来源:process_kern.c


示例19: slip_pre_exec

static void slip_pre_exec(void *arg)
{
	struct slip_pre_exec_data *data = arg;

	if(data->stdin >= 0) dup2(data->stdin, 0);
	dup2(data->stdout, 1);
	if(data->close_me >= 0) os_close_file(data->close_me);
}
开发者ID:FatSunHYS,项目名称:OSCourseDesign,代码行数:8,代码来源:slip_user.c


示例20: hostaudio_release

static int hostaudio_release(struct inode *inode, struct file *file)
{
	struct hostaudio_state *state = file->private_data;

#ifdef DEBUG
	printk(KERN_DEBUG "hostaudio: release called\n");
#endif
	os_close_file(state->fd);
	kfree(state);

	return 0;
}
开发者ID:020gzh,项目名称:linux,代码行数:12,代码来源:hostaudio_kern.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ os_delay_us函数代码示例发布时间:2022-05-30
下一篇:
C++ os_calloc函数代码示例发布时间: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