• <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
            <2025年8月>
            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

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久久久青草线蕉综合超碰| 99久久www免费人成精品| 久久无码专区国产精品发布| 中文字幕无码免费久久| 国产精品久久久久无码av| 久久99久久无码毛片一区二区| 久久99国产精品久久99小说| 久久精品毛片免费观看| 久久精品无码专区免费| 97精品国产91久久久久久| 亚洲欧洲精品成人久久曰影片| 久久人人爽人人爽人人片AV不| 久久这里有精品视频| 99久久成人国产精品免费| 亚洲а∨天堂久久精品9966| 久久er热视频在这里精品| 影音先锋女人AV鲁色资源网久久| 精品久久久久久国产免费了| 久久中文字幕一区二区| 热re99久久精品国99热| 久久综合亚洲鲁鲁五月天| 青青久久精品国产免费看| 97久久精品人人澡人人爽| 精品久久久久久| 久久99精品国产一区二区三区| 色综合久久综合中文综合网| 亚洲乱码中文字幕久久孕妇黑人| 日日狠狠久久偷偷色综合0| 人妻丰满?V无码久久不卡| 久久性精品| 亚洲精品tv久久久久久久久久| 久久久青草青青国产亚洲免观| 国产精品99久久久久久猫咪| 日韩一区二区久久久久久| 日本精品久久久中文字幕| 热久久国产精品| 激情五月综合综合久久69| 久久久久无码专区亚洲av| 香蕉99久久国产综合精品宅男自 | 欧美久久综合九色综合| 欧美粉嫩小泬久久久久久久 |