• <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 閱讀(668) 評論(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

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            日日躁夜夜躁狠狠久久AV| 久久不射电影网| 情人伊人久久综合亚洲| 久久频这里精品99香蕉久| 亚洲中文久久精品无码| 日韩精品无码久久久久久| 久久成人国产精品二三区| 亚洲精品久久久www| 久久丫精品国产亚洲av不卡 | 久久中文字幕无码专区| 亚洲精品tv久久久久久久久| 久久中文精品无码中文字幕| 久久99精品久久久久婷婷| 久久偷看各类wc女厕嘘嘘| 狠狠人妻久久久久久综合蜜桃| 亚洲精品美女久久久久99| 91精品日韩人妻无码久久不卡| 九九精品99久久久香蕉| 久久综合色之久久综合| 久久91精品久久91综合| 亚洲色婷婷综合久久| 欧美久久天天综合香蕉伊| 国产叼嘿久久精品久久| 97久久精品国产精品青草| 久久久精品人妻一区二区三区四| 一本久道久久综合狠狠爱| 欧美日韩精品久久久久| 亚洲伊人久久大香线蕉苏妲己| 久久免费的精品国产V∧| 日本亚洲色大成网站WWW久久| 天天爽天天爽天天片a久久网| 久久久亚洲欧洲日产国码二区| 伊人久久大香线蕉AV一区二区| 久久WWW免费人成—看片| 国产成人无码精品久久久久免费| 久久精品国产一区| 91久久九九无码成人网站| 久久精品一区二区| 久久se精品一区二区影院| 四虎国产精品成人免费久久| 亚洲精品视频久久久|