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

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

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

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

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

示例1: unshare_files

int unshare_files(struct files_struct **displaced){	struct task_struct *task = current;	struct files_struct *copy = NULL;	int error;	error = unshare_fd(CLONE_FILES, &copy);	if (error || !copy) {		*displaced = NULL;		return error;	}	*displaced = task->files;	task_lock(task);	task->files = copy;	task_unlock(task);	return 0;}
开发者ID:amadews,项目名称:j608_fly_4511,代码行数:17,


示例2: SYSCALL_DEFINE1

/* * unshare allows a process to 'unshare' part of the process * context which was originally shared using clone.  copy_* * functions used by do_fork() cannot be used here directly * because they modify an inactive task_struct that is being * constructed. Here we are modifying the current, active, * task_struct. */SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags){	int err = 0;	struct fs_struct *fs, *new_fs = NULL;	struct sighand_struct *new_sigh = NULL;	struct mm_struct *mm, *new_mm = NULL, *active_mm = NULL;	struct files_struct *fd, *new_fd = NULL;	struct nsproxy *new_nsproxy = NULL;	int do_sysvsem = 0;	check_unshare_flags(&unshare_flags);	/* Return -EINVAL for all unsupported flags */	err = -EINVAL;	if (unshare_flags & ~(CLONE_THREAD|CLONE_FS|CLONE_NEWNS|CLONE_SIGHAND|				CLONE_VM|CLONE_FILES|CLONE_SYSVSEM|				CLONE_NEWUTS|CLONE_NEWIPC|CLONE_NEWNET))		goto bad_unshare_out;	/*	 * CLONE_NEWIPC must also detach from the undolist: after switching	 * to a new ipc namespace, the semaphore arrays from the old	 * namespace are unreachable.	 */	if (unshare_flags & (CLONE_NEWIPC|CLONE_SYSVSEM))		do_sysvsem = 1;	if ((err = unshare_thread(unshare_flags)))		goto bad_unshare_out;	if ((err = unshare_fs(unshare_flags, &new_fs)))		goto bad_unshare_cleanup_thread;	if ((err = unshare_sighand(unshare_flags, &new_sigh)))		goto bad_unshare_cleanup_fs;	if ((err = unshare_vm(unshare_flags, &new_mm)))		goto bad_unshare_cleanup_sigh;	if ((err = unshare_fd(unshare_flags, &new_fd)))		goto bad_unshare_cleanup_vm;	if ((err = unshare_nsproxy_namespaces(unshare_flags, &new_nsproxy,			new_fs)))		goto bad_unshare_cleanup_fd;	if (new_fs ||  new_mm || new_fd || do_sysvsem || new_nsproxy) {		if (do_sysvsem) {			/*			 * CLONE_SYSVSEM is equivalent to sys_exit().			 */			exit_sem(current);		}		if (new_nsproxy) {			switch_task_namespaces(current, new_nsproxy);			new_nsproxy = NULL;		}		task_lock(current);		if (new_fs) {			fs = current->fs;			write_lock(&fs->lock);			current->fs = new_fs;			if (--fs->users)				new_fs = NULL;			else				new_fs = fs;			write_unlock(&fs->lock);		}		if (new_mm) {			mm = current->mm;			active_mm = current->active_mm;			current->mm = new_mm;			current->active_mm = new_mm;			activate_mm(active_mm, new_mm);			new_mm = mm;		}		if (new_fd) {			fd = current->files;			current->files = new_fd;			new_fd = fd;		}		task_unlock(current);	}	if (new_nsproxy)		put_nsproxy(new_nsproxy);bad_unshare_cleanup_fd:	if (new_fd)		put_files_struct(new_fd);bad_unshare_cleanup_vm://.........这里部分代码省略.........
开发者ID:genua,项目名称:anoubis_os,代码行数:101,


示例3: SYSCALL_DEFINE1

/* * unshare allows a process to 'unshare' part of the process * context which was originally shared using clone.  copy_* * functions used by do_fork() cannot be used here directly * because they modify an inactive task_struct that is being * constructed. Here we are modifying the current, active, * task_struct. */SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags){	struct fs_struct *fs, *new_fs = NULL;	struct files_struct *fd, *new_fd = NULL;	struct cred *new_cred = NULL;	struct nsproxy *new_nsproxy = NULL;	int do_sysvsem = 0;	int err;	/*	 * If unsharing a user namespace must also unshare the thread.	 */	if (unshare_flags & CLONE_NEWUSER)		unshare_flags |= CLONE_THREAD | CLONE_FS;	/*	 * If unsharing a thread from a thread group, must also unshare vm.	 */	if (unshare_flags & CLONE_THREAD)		unshare_flags |= CLONE_VM;	/*	 * If unsharing vm, must also unshare signal handlers.	 */	if (unshare_flags & CLONE_VM)		unshare_flags |= CLONE_SIGHAND;	/*	 * If unsharing namespace, must also unshare filesystem information.	 */	if (unshare_flags & CLONE_NEWNS)		unshare_flags |= CLONE_FS;	err = check_unshare_flags(unshare_flags);	if (err)		goto bad_unshare_out;	/*	 * CLONE_NEWIPC must also detach from the undolist: after switching	 * to a new ipc namespace, the semaphore arrays from the old	 * namespace are unreachable.	 */	if (unshare_flags & (CLONE_NEWIPC|CLONE_SYSVSEM))		do_sysvsem = 1;	err = unshare_fs(unshare_flags, &new_fs);	if (err)		goto bad_unshare_out;	err = unshare_fd(unshare_flags, &new_fd);	if (err)		goto bad_unshare_cleanup_fs;	err = unshare_userns(unshare_flags, &new_cred);	if (err)		goto bad_unshare_cleanup_fd;	err = unshare_nsproxy_namespaces(unshare_flags, &new_nsproxy,					 new_cred, new_fs);	if (err)		goto bad_unshare_cleanup_cred;	if (new_fs || new_fd || do_sysvsem || new_cred || new_nsproxy) {		if (do_sysvsem) {			/*			 * CLONE_SYSVSEM is equivalent to sys_exit().			 */			exit_sem(current);		}		if (unshare_flags & CLONE_NEWIPC) {			/* Orphan segments in old ns (see sem above). */			exit_shm(current);			shm_init_task(current);		}		if (new_nsproxy)			switch_task_namespaces(current, new_nsproxy);		task_lock(current);		if (new_fs) {			fs = current->fs;			spin_lock(&fs->lock);			current->fs = new_fs;			if (--fs->users)				new_fs = NULL;			else				new_fs = fs;			spin_unlock(&fs->lock);		}		if (new_fd) {			fd = current->files;			current->files = new_fd;			new_fd = fd;		}		task_unlock(current);		if (new_cred) {//.........这里部分代码省略.........
开发者ID:19Dan01,项目名称:linux,代码行数:101,


示例4: SYSCALL_DEFINE1

SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags){	struct fs_struct *fs, *new_fs = NULL;	struct files_struct *fd, *new_fd = NULL;	struct nsproxy *new_nsproxy = NULL;	int do_sysvsem = 0;	int err;	err = check_unshare_flags(unshare_flags);	if (err)		goto bad_unshare_out;	if (unshare_flags & CLONE_NEWNS)		unshare_flags |= CLONE_FS;	if (unshare_flags & (CLONE_NEWIPC|CLONE_SYSVSEM))		do_sysvsem = 1;	err = unshare_fs(unshare_flags, &new_fs);	if (err)		goto bad_unshare_out;	err = unshare_fd(unshare_flags, &new_fd);	if (err)		goto bad_unshare_cleanup_fs;	err = unshare_nsproxy_namespaces(unshare_flags, &new_nsproxy, new_fs);	if (err)		goto bad_unshare_cleanup_fd;	if (new_fs || new_fd || do_sysvsem || new_nsproxy) {		if (do_sysvsem) {			exit_sem(current);		}		if (new_nsproxy) {			switch_task_namespaces(current, new_nsproxy);			new_nsproxy = NULL;		}		task_lock(current);		if (new_fs) {			fs = current->fs;			spin_lock(&fs->lock);			current->fs = new_fs;			if (--fs->users)				new_fs = NULL;			else				new_fs = fs;			spin_unlock(&fs->lock);		}		if (new_fd) {			fd = current->files;			current->files = new_fd;			new_fd = fd;		}		task_unlock(current);	}	if (new_nsproxy)		put_nsproxy(new_nsproxy);bad_unshare_cleanup_fd:	if (new_fd)		put_files_struct(new_fd);bad_unshare_cleanup_fs:	if (new_fs)		free_fs_struct(new_fs);bad_unshare_out:	return err;}
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:72,



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


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