• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            posts - 297,  comments - 15,  trackbacks - 0

            #include <linux/kernel.h>
            #include <linux/module.h>
            #include <linux/init.h>
            #include <linux/fs.h>
            #include <linux/string.h>
            #include <linux/mm.h>
            #include <linux/syscalls.h>
            #include <asm/unistd.h>
            #include <asm/uaccess.h>

            #define MY_FILE "/root/LogFile"

            char buf[128];
            struct file *file = NULL;

            static int __init init(void)
            {
                    mm_segment_t old_fs;
                    printk("Hello, I'm the module that intends to write messages to file.\n");


                    if(file == NULL)
                            file = filp_open(MY_FILE, O_RDWR | O_APPEND | O_CREAT, 0644);
                    if (IS_ERR(file)) {
                            printk("error occured while opening file %s, exiting...\n", MY_FILE);
                            return 0;
                    }

                    sprintf(buf,"%s", "The Messages.");

                    old_fs = get_fs();
                    set_fs(KERNEL_DS);
                    file->f_op->write(file, (char *)buf, sizeof(buf), &file->f_pos);
                    set_fs(old_fs);


                    return 0;
            }

            static void __exit fini(void)
            {
                    if(file != NULL)
                            filp_close(file, NULL);
            }

            module_init(init);
            module_exit(fini);
            MODULE_LICENSE("GPL");


            from:
            http://blog.csdn.net/coofive/archive/2006/05/07/712028.aspx
            posted on 2010-02-27 11:02 chatler 閱讀(678) 評論(0)  編輯 收藏 引用 所屬分類: linux kernel
            <2010年1月>
            272829303112
            3456789
            10111213141516
            17181920212223
            24252627282930
            31123456

            常用鏈接

            留言簿(10)

            隨筆分類(307)

            隨筆檔案(297)

            algorithm

            Books_Free_Online

            C++

            database

            Linux

            Linux shell

            linux socket

            misce

            • cloudward
            • 感覺這個博客還是不錯,雖然做的東西和我不大相關,覺得看看還是有好處的

            network

            OSS

            • Google Android
            • Android is a software stack for mobile devices that includes an operating system, middleware and key applications. This early look at the Android SDK provides the tools and APIs necessary to begin developing applications on the Android platform using the Java programming language.
            • os161 file list

            overall

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            亚洲狠狠婷婷综合久久久久| 93精91精品国产综合久久香蕉| 精品久久久久成人码免费动漫 | 2022年国产精品久久久久| 久久99国内精品自在现线| 久久精品人人做人人爽97| 国产精品xxxx国产喷水亚洲国产精品无码久久一区 | 国产精品一久久香蕉国产线看观看| 亚洲午夜久久久久久久久电影网 | 精品久久久久久无码中文野结衣| 香港aa三级久久三级| 亚洲精品乱码久久久久66| 欧美精品一区二区精品久久| 囯产极品美女高潮无套久久久| 久久精品国产久精国产| 久久久亚洲欧洲日产国码aⅴ| 亚洲?V乱码久久精品蜜桃| A级毛片无码久久精品免费| 久久久久久毛片免费播放| 色综合久久无码中文字幕| 中文字幕无码免费久久| 久久精品国产2020| 亚洲精品蜜桃久久久久久| 亚洲精品乱码久久久久久不卡| 久久久久夜夜夜精品国产| 国产成人精品久久| 国产精品99久久精品爆乳| 久久国产香蕉视频| 国产精品午夜久久| 中文字幕亚洲综合久久菠萝蜜| 老男人久久青草av高清| 久久久久久久综合日本亚洲| 久久最新精品国产| 国内精品久久久久影院老司| 99久久香蕉国产线看观香| 国产精品久久久久国产A级| 国产精品亚洲综合专区片高清久久久 | 国产精品午夜久久| 狠狠色噜噜色狠狠狠综合久久| 久久99久久无码毛片一区二区 | 性高湖久久久久久久久AAAAA|