• <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

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            国产精品欧美久久久久天天影视 | 一本色综合久久| 亚洲国产一成久久精品国产成人综合 | 狠狠干狠狠久久| 一级女性全黄久久生活片免费 | 国产精品久久波多野结衣| 国产精久久一区二区三区| 久久久午夜精品| 国产成人精品免费久久久久| 久久996热精品xxxx| 亚洲狠狠婷婷综合久久久久| 72种姿势欧美久久久久大黄蕉| 久久影视综合亚洲| 久久噜噜电影你懂的| 狠狠色丁香久久婷婷综合| 国内精品久久久久久久影视麻豆| 伊人久久大香线蕉亚洲五月天| 国产ww久久久久久久久久| 久久99久久99精品免视看动漫| 色偷偷91久久综合噜噜噜噜| 久久夜色tv网站| 99久久国产热无码精品免费| 一本色道久久88综合日韩精品 | 久久er99热精品一区二区| 人人狠狠综合88综合久久| 99久久精品九九亚洲精品| 亚洲精品tv久久久久久久久| 热99RE久久精品这里都是精品免费| 国产精品久久久久久久午夜片| 国产精品久久久久久福利漫画| 久久婷婷国产综合精品| 国产69精品久久久久9999APGF | 国产成人久久777777| 久久久九九有精品国产| 国产情侣久久久久aⅴ免费| 久久亚洲AV成人无码电影| 伊人久久大香线蕉综合Av| 久久丫忘忧草产品| 蜜臀久久99精品久久久久久小说| 久久亚洲日韩精品一区二区三区| 久久亚洲精品成人AV|