• <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
            <2009年5月>
            262728293012
            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

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            99精品国产免费久久久久久下载 | 99久久精品免费看国产一区二区三区 | 亚洲欧美日韩中文久久| 久久亚洲日韩看片无码| 久久婷婷激情综合色综合俺也去| 精品国产乱码久久久久久郑州公司 | 亚洲午夜久久久久妓女影院| 久久亚洲精品国产精品| 国产精品激情综合久久| 久久亚洲国产精品成人AV秋霞| 人妻精品久久无码区| 久久er国产精品免费观看8| 国产69精品久久久久9999APGF| 久久精品国产亚洲AV麻豆网站 | 久久免费看黄a级毛片| 久久青青草原综合伊人| 国产激情久久久久久熟女老人| 欧美精品一区二区精品久久| 亚洲va久久久噜噜噜久久| 久久精品三级视频| 狠狠色丁香久久综合五月| 久久人人爽人人爽人人片AV不 | 国产精品99久久久精品无码| 精品久久久久一区二区三区| 久久99精品综合国产首页| 亚洲国产精品成人久久| 中文成人无码精品久久久不卡 | 亚洲精品午夜国产va久久 | 久久乐国产综合亚洲精品| 国产免费久久久久久无码| 潮喷大喷水系列无码久久精品| 久久精品中文字幕一区| 久久丫忘忧草产品| 亚洲婷婷国产精品电影人久久 | 伊人久久五月天| 伊人精品久久久久7777| 午夜精品久久久久久久无码| 欧美日韩精品久久久久| 免费一级欧美大片久久网| 91久久精品无码一区二区毛片| 久久精品国产99国产电影网 |