• <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 閱讀(659) 評論(0)  編輯 收藏 引用 所屬分類: linux kernel
            <2010年9月>
            2930311234
            567891011
            12131415161718
            19202122232425
            262728293012
            3456789

            常用鏈接

            留言簿(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

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久综合亚洲色HEZYO社区| 国产欧美一区二区久久| 久久国产香蕉一区精品| 久久久中文字幕日本| 性欧美大战久久久久久久久| 麻豆一区二区99久久久久| 久久夜色tv网站| 久久精品国产亚洲AV影院| 久久99精品久久久久久| 亚洲午夜精品久久久久久浪潮| 人妻精品久久无码区| 久久露脸国产精品| 国产精品久久久久久久| 久久亚洲国产成人影院| 人人狠狠综合久久亚洲88| 日韩精品无码久久久久久| 久久久国产精品| 一本大道久久a久久精品综合| 久久婷婷是五月综合色狠狠| 亚洲伊人久久大香线蕉苏妲己| 99久久夜色精品国产网站| 久久精品国产一区二区三区不卡| 中文字幕无码精品亚洲资源网久久| 99精品久久久久久久婷婷| 亚洲va久久久噜噜噜久久狠狠| 伊人久久大香线蕉综合5g| 国内精品欧美久久精品| 亚洲国产精品久久久久| www.久久热.com| 久久66热人妻偷产精品9| 77777亚洲午夜久久多人| 亚洲国产成人久久精品99| 久久久久97国产精华液好用吗| 久久99国产精品久久久| .精品久久久麻豆国产精品| 久久久久人妻精品一区二区三区| 久久精品国产亚洲AV蜜臀色欲| 伊人久久大香线蕉精品不卡| 一本一本久久a久久精品综合麻豆| 免费一级做a爰片久久毛片潮| 久久久久亚洲爆乳少妇无|