how to access file in kernel space
2013-04-10 10:21
316 查看
static void write_file(char *filename, unsigned char *data, unsigned int nSize)
{
struct file *file;
loff_t pos = 0;
int fd;
dmac_inv_range(data, data + nSize);
mm_segment_t old_fs = get_fs();
set_fs(KERNEL_DS);
fd = sys_open(filename, O_WRONLY|O_CREAT, 0644);
if (fd >= 0) {
sys_write(fd, data, nSize);
file = fget(fd);
if (file) {
vfs_write(file, data, nSize, &pos);
fput(file);
}
sys_close(fd);
}
else
{
mfc_err("........Open fail : %d \n", fd);
}
set_fs(old_fs);
dmac_clean_range(data, data + nSize);
}
{
struct file *file;
loff_t pos = 0;
int fd;
dmac_inv_range(data, data + nSize);
mm_segment_t old_fs = get_fs();
set_fs(KERNEL_DS);
fd = sys_open(filename, O_WRONLY|O_CREAT, 0644);
if (fd >= 0) {
sys_write(fd, data, nSize);
file = fget(fd);
if (file) {
vfs_write(file, data, nSize, &pos);
fput(file);
}
sys_close(fd);
}
else
{
mfc_err("........Open fail : %d \n", fd);
}
set_fs(old_fs);
dmac_clean_range(data, data + nSize);
}
相关文章推荐
- 核心驱动文件操作 How to access file in Kernel Driver
- 核心驱动文件操作 How to access file in Kernel
- How to load a camera module in kernel space
- How to reclaim space in InnoDB when innodb_file_per_table is ON
- How to access a value defined in the application.properties file in Spring Boot ( Externalized Conf)
- How to Access and Use the Windows Hosts File in Windows 7 and Vista
- How to save cookie in file for Requests
- How to create a zip file in NetSuite SuiteScript 2.0 如何在现有SuiteScript中创建和下载ZIP压缩文档
- how to save array in file in c#
- How to access Dropbox from the command line in Linux
- How to make a USB stick use ISO image file in debian
- How to read a frame from YUV file in OpenCV?
- In C# how to find the mime type of a file
- prjGetWriteINIFile - How to Read-Write INI file using VB & API - 读取/写入INI文件 - VB6 + API - SourceCode - HackerJLY
- use WinDbg running in kernel mode to set breakpoints in user space
- How to Create a Debug File in Shipping Execution [ID 290432.1]
- How to synchronize access to a shared resource in a multithreading environment by using Visual C#
- how to free up more space in boot partition with Ubuntu16.04
- How can I force Python's file.write() to use the same newline format in Windows as in Linux (“\r\n”
- How To Read XML File In Java – (SAX Parser)