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

            If you want to compile the sum-module (source mirrored below), follow these steps:

            Create the Makefile in your directory with the sum-module.c

             obj-m    := sum-module.o

            KDIR    := /lib/modules/$(shell uname -r)/build

            PWD    := $(shell pwd)

            default:

                   $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

            Now do a

             make

            ... and the sum-module.ko is built.

             If you get something like this

            # make

            make: Nothing to be done for `default'.

            you need to install the kernel source and compile the kernel first (run "make" at least to the point until
             all "HOSTCC scripts/" stuff is done - this will configure your kernel and allows external module compilation).
            Make sure /lib/modules/$(shell uname -r)/build points to your build directory (most likely /usr/src/linux...).

            Another reason for the above error can be, that your browser converted the TAB before $(MAKE) to spaces.

            Make sure there is a TAB before $(MAKE).

            Install it with install.sh:

            #!/bin/sh

            install -m 644 sum-module.ko /lib/modules/`uname -r`/kernel/drivers/sum-module.ko

            /sbin/depmod -a (adjust the /lib/modules path according to your needs)

             Now make a

            # modprobe sum-module

            Or if you don't want to install the module, do this:

            # insmod ./sum-module.ko

            ..and if your system doesn't freeze you've done it right ;-)

             

            For kernel 2.4, the Makefile would look like this:

            TARGET       := modulename

            INCLUDE    := -I/lib/modules/`uname -r`/build/include

            CFLAGS      := -O2 -Wall -DMODULE -D__KERNEL__ -DLINUX

            CC  := gcc ${TARGET}.o: ${TARGET}.c

                   $(CC) $(CFLAGS) ${INCLUDE} -c ${TARGET}.c

             (not yet tested)

            sum-module source from: http://www.win.tue.nl/~aeb/linux/lk/lk-9.html

            /*

             * sum-module.c

            # modprobe sum-module.o

            # ls -l /proc/arith

            total 0

            dr-xr-xr-x    2 root     root            0 Sep 30 12:40 .

            dr-xr-xr-x   89 root     root            0 Sep 30 12:39 ..

            -r--r--r--    1 root     root            0 Sep 30 12:40 sum

            # cat /proc/arith/sum

            0

            # echo 7 > /proc/arith/sum

            # echo 5 > /proc/arith/sum

            # echo 13 > /proc/arith/sum

            # cat /proc/arith/sum

            25

            # rmmod sum-module

            # ls -l /proc/arith

            ls: /proc/arith: No such file or directory

            #

            */

            #include <linux/module.h>

            #include <linux/init.h>

            #include <linux/proc_fs.h>

            #include <asm/uaccess.h>

            static unsigned long long sum;

            static int show_sum(char *buffer, char **start, off_t offset, int length) {

                    int size;

                 size = sprintf(buffer, "%lld\n", sum);

                    *start = buffer + offset;

                    size -= offset;

               return (size > length) ? length : (size > 0) ? size : 0;

            }

            /* Expect decimal number of at most 9 digits followed by '\n' */

            static int add_to_sum(struct file *file, const char *buffer,

                                  unsigned long count, void *data)

            {

                    unsigned long val = 0;

                    char buf[10];

                   char *endp;

                    if (count > sizeof(buf))

                            return -EINVAL;

                    if (copy_from_user(buf, buffer, count))

                            return -EFAULT;

                    val = simple_strtoul(buf, &endp, 10);

                    if (*endp != '\n')

                            return -EINVAL;


                    sum += val;     /* mod 2^64 */

                    return count;

            }

             

            static int __init sum_init(void) {

                    struct proc_dir_entry *proc_arith;

                    struct proc_dir_entry *proc_arith_sum;

                    proc_arith = proc_mkdir("arith", 0);

                    if (!proc_arith) {

                            printk (KERN_ERR "cannot create /proc/arith\n");

                            return -ENOMEM;

                    }

                    proc_arith_sum = create_proc_info_entry("arith/sum", 0, 0, show_sum);

                    if (!proc_arith_sum) {

                            printk (KERN_ERR "cannot create /proc/arith/sum\n");

                            remove_proc_entry("arith", 0);

                            return -ENOMEM;

                    }

                    proc_arith_sum->write_proc = add_to_sum;

                    return 0;

            }

             

            static void __exit sum_exit(void) {

                    remove_proc_entry("arith/sum", 0);

                    remove_proc_entry("arith", 0);

            }

            module_init(sum_init);

            module_exit(sum_exit);

            MODULE_LICENSE("GPL");

             

             from:

            http://www.captain.at/programming/kernel-2.6/

            http://blog.ednchina.com/fafen/267973/message.aspx
            posted on 2010-04-14 23:00 chatler 閱讀(469) 評論(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

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            91麻豆精品国产91久久久久久| 国产日韩欧美久久| 久久99国产精品久久99小说| 久久无码中文字幕东京热| 亚洲狠狠婷婷综合久久久久 | 国产午夜精品理论片久久 | 无码国内精品久久人妻| 精品久久久久中文字幕日本| 久久精品成人国产午夜| 四虎国产精品免费久久| 色综合久久中文字幕无码| 久久精品www| 伊人久久精品无码av一区| 青青青伊人色综合久久| 久久午夜夜伦鲁鲁片免费无码影视 | 日产精品久久久久久久性色| 爱做久久久久久| 久久精品国产男包| 国内精品久久久久久久久电影网| 77777亚洲午夜久久多喷| 精品久久国产一区二区三区香蕉| 久久国产精品一国产精品金尊| 国产精品美女久久久网AV| 久久精品aⅴ无码中文字字幕重口 久久精品a亚洲国产v高清不卡 | 99久久精品国产一区二区三区 | 久久久老熟女一区二区三区| 欧美一级久久久久久久大| 国产一区二区精品久久| 色综合久久无码五十路人妻| 女人高潮久久久叫人喷水| 久久久久久久国产免费看| 大美女久久久久久j久久| 国产综合久久久久| 99久久99这里只有免费的精品| 亚洲综合伊人久久综合| 亚洲欧美成人久久综合中文网| 久久精品视频91| 久久国产福利免费| 久久久久国产一区二区三区| 国产综合免费精品久久久| 久久精品国产亚洲Aⅴ蜜臀色欲|