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

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            精品久久久久久中文字幕大豆网| 97精品依人久久久大香线蕉97| 青青草原综合久久| 久久97久久97精品免视看| 午夜精品久久影院蜜桃| 久久久婷婷五月亚洲97号色| 99久久99久久| 久久久久久国产精品无码下载| 91精品国产9l久久久久| 欧美无乱码久久久免费午夜一区二区三区中文字幕 | 久久精品国产欧美日韩99热| 久久亚洲精品成人av无码网站| 国内精品久久久久久麻豆| 性做久久久久久久| 合区精品久久久中文字幕一区| 99久久免费国产精精品| 日韩精品久久久久久久电影蜜臀| 久久久久免费视频| 99国内精品久久久久久久| 色诱久久久久综合网ywww| 亚洲欧美久久久久9999| 亚洲一本综合久久| 伊人久久精品线影院| www.久久精品| 久久久亚洲欧洲日产国码aⅴ| 狠狠色丁香久久婷婷综合_中| 国内精品久久久久久麻豆 | 亚洲欧美另类日本久久国产真实乱对白 | 亚洲精品无码久久久| 久久久久久无码国产精品中文字幕| 99久久99久久精品免费看蜜桃| 性色欲网站人妻丰满中文久久不卡| 久久精品国产99久久久古代| 久久精品国产亚洲av麻豆图片| 久久久久人妻一区精品| 久久午夜无码鲁丝片午夜精品| 亚洲人AV永久一区二区三区久久 | 精品人妻伦九区久久AAA片69| 亚洲美日韩Av中文字幕无码久久久妻妇| 亚洲精品NV久久久久久久久久 | 国产69精品久久久久久人妻精品|