Пример #1
0
/*! 2017. 6. 3 study -ing */
static int devtmpfsd(void *p)
{
	char options[] = "mode=0755";
	int *err = p;
	/*! sys_unshare는 fork.c의 "SYSCALL_DEFINE1(unshare" 를 참조 */
	*err = sys_unshare(CLONE_NEWNS);
	if (*err)
		goto out;
	/*! sys_mount는 fs/namespace.c의 "SYSCALL_DEFINE5(mount" 를 참조 */
	*err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
	if (*err)
		goto out;
	/*! sys_chdir는 fs/open.c 의 "SYSCALL_DEFINE1(chdir" 을 참조 */
	sys_chdir("/.."); /* will traverse into overmounted root */
	/*! sys_chdir는 fs/open.c 의 "SYSCALL_DEFINE1(chroot" 을 참조  */
	sys_chroot(".");
	complete(&setup_done);
	while (1) {
		spin_lock(&req_lock);
		while (requests) {
			struct req *req = requests;
			requests = NULL;
			spin_unlock(&req_lock);
			while (req) {
				struct req *next = req->next;
				req->err = handle(req->name, req->mode,
						  req->uid, req->gid, req->dev);
				complete(&req->done);
				req = next;
			}
			spin_lock(&req_lock);
		}
		__set_current_state(TASK_INTERRUPTIBLE);
		spin_unlock(&req_lock);
		schedule();
	}
	return 0;
out:
	complete(&setup_done);
	return *err;
}
Пример #2
0
static int devtmpfsd(void *p)
{
	char options[] = "mode=0755";
	int *err = p;
	*err = sys_unshare(CLONE_NEWNS);
	printk(KERN_INFO "%s, %s\n", __FILE__,__func__);

	if (*err)
		goto out;
	*err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
	if (*err)
		goto out;
	sys_chdir("/.."); /* will traverse into overmounted root */
	sys_chroot(".");
	complete(&setup_done);
	while (1) {
		spin_lock(&req_lock);
		while (requests) {
			struct req *req = requests;
			requests = NULL;
			spin_unlock(&req_lock);
			while (req) {
				struct req *next = req->next;
				req->err = handle(req->name, req->mode, req->dev);
				complete(&req->done);
				req = next;
			}
			spin_lock(&req_lock);
		}
		__set_current_state(TASK_INTERRUPTIBLE);
		spin_unlock(&req_lock);
		schedule();
	}
	return 0;
out:
	complete(&setup_done);
	return *err;
}