📄 datasection.c
字号:
/* * datasection.c * * Copyright (C) 2006 Insigme Co., Ltd * * Authors: * - Chenzhan Hu * * This software has been developed while working on the Linux Unified Kernel * project (http://linux.insigma.com.cn) in the Insigma Reaserch Institute, * which is a subdivision of Insigma Co., Ltd (http://www.insigma.com.cn). * * The project is sponsored by Insigma Co., Ltd. * * The authors can be reached at linux@insigma.com.cn. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * Revision History: * Jan 2006 - Created. *//* * datasection.c: data section handling implementation */#include <linux/module.h>#include "section.h"#include "objwait.h"#include <linux/file.h>#include <linux/mm.h>#ifdef CONFIG_UNIFIED_KERNELextern unsigned long win32_do_mmap_pgoff(struct task_struct *, char, struct file *, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long);static int data_section_map(struct task_struct *tsk, struct win32_section *, unsigned long *, unsigned long, unsigned long, unsigned long);/* * setup a data section * - if not map a file, creates a file in the shmem filesystem */int data_section_setup(struct win32_section *ws){ char *name, prefix[] = "win32_"; ktrace("data_section_setup(%p)\n", ws); /* set the mmap function */ ws->ws_mmap = data_section_map; if (!ws->ws_wfile) { int len, prefix_len; /* determine the name to use for the SHMEM file */ len = strlen(ws->ws_obj->o_name.name); prefix_len = sizeof(prefix); name = (char *)kmalloc(len + prefix_len, GFP_KERNEL); if (!name) return -ENOMEM; memcpy(name, prefix, prefix_len - 1); memcpy(name + prefix_len - 1, ws->ws_obj->o_name.name, len); name[len + prefix_len - 1] = '\0'; /* create a SHMEM file */ ws->ws_file = shmem_file_setup(name, ws->ws_len, 0); if (IS_ERR(ws->ws_file)) { kfree(name); return PTR_ERR(ws->ws_file); } kfree(name); } else ws->ws_file = ws->ws_wfile->wf_file; return 0;} /* end data_section_setup *//* * map a data section * mapped address is returned from addr */static int data_section_map(struct task_struct *tsk, struct win32_section *ws, unsigned long *addr, unsigned long len, unsigned long flags, unsigned long offset){ struct file *file = ws->ws_file; unsigned long ret; ktrace("data_section_map(%p)\n", ws); ret = win32_do_mmap_pgoff(tsk, 0, file, *addr, len, ws->ws_protect, flags, offset); if (IS_ERR((void *)ret)) return (int)ret; *addr = ret; return 0;} /* end data_section_map */#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -