• <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 閱讀(669) 評論(0)  編輯 收藏 引用 所屬分類: linux kernel
            <2009年4月>
            2930311234
            567891011
            12131415161718
            19202122232425
            262728293012
            3456789

            常用鏈接

            留言簿(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

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            伊人久久综合热线大杳蕉下载| 2021久久国自产拍精品| 久久亚洲国产成人精品无码区| 色综合久久最新中文字幕| 久久久WWW免费人成精品| 一级A毛片免费观看久久精品| 亚洲精品美女久久777777| 精品无码久久久久久尤物| 久久久久久青草大香综合精品| 久久人人添人人爽添人人片牛牛| www久久久天天com| 伊人久久一区二区三区无码| 99久久精品费精品国产一区二区| 久久精品成人一区二区三区| 欧美喷潮久久久XXXXx| 久久综合久久鬼色| 久久精品草草草| 亚洲精品乱码久久久久久蜜桃不卡| 99热热久久这里只有精品68| 99精品久久精品一区二区| 国产香蕉97碰碰久久人人| 精品国产一区二区三区久久久狼| 一级a性色生活片久久无| 精品久久久久久无码人妻热| 人妻丰满AV无码久久不卡| 亚洲国产精品狼友中文久久久| 婷婷综合久久中文字幕| 99久久精品费精品国产一区二区 | 色偷偷91久久综合噜噜噜噜| 国内精品久久久久影院优| 亚洲精品无码久久久久去q | 国产成人精品久久| 亚洲AV无码1区2区久久| 久久久这里只有精品加勒比| 久久久久无码精品| 日韩影院久久| 久久只这里是精品66| 久久乐国产综合亚洲精品| 色老头网站久久网| 亚洲午夜久久久久久久久久| 性高湖久久久久久久久|