Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Linux kernel source tree to establish load module hello     - Talk about Java EE Learning (Programming)

- To install the Ubuntu Touch emulator on Ubuntu (Linux)

- iOS in Singleton (Programming)

- HAproxy let IP recording back-end RS (Server)

- Redis is installed and set up Ubuntu 14.04 from the environment under the main ssdb (Server)

- How to manage KVM virtual environments with command-line tools in Linux (Server)

- Gentoo: startx appeared Failed to load module Problem Solving (Linux)

- MongoDB 3.2 Cluster Setup (Database)

- C language sorting instance (select, bubble, insert, binary, fast) (Programming)

- Handle large data problems Bit-map method (Programming)

- Puppet installation and testing (Server)

- Variables Python variables (Programming)

- Mybatis + binding Struts2: achieving user to insert and find (Programming)

- OpenStack image production in the CentOS 6.2 (Linux)

- Volatile keyword in C language understanding (Programming)

- Linux create and delete user step (Linux)

- PostgreSQL query lock and kill the process (Database)

- MySQL time field based partitioning scheme summary (Database)

- It is time to upgrade your gulp 4.0 (Programming)

- Hibernate + JUnit test entity class generate database table (Programming)

 
         
  Linux kernel source tree to establish load module hello
     
  Add Date : 2018-11-21      
         
         
         
  Linux kernel source tree to establish load module hello

Before loading the module, the book said he needed to build the kernel source tree, then, how to build the kernel source tree yet?

First, we must first know the kernel version of your OS, you can get this with uname -r

In / url / src / directory you can see the corresponding release directory

If not you can get the kernel using apt-cache search linux-source

With sudo apt-get install linux-source-3.13.0 download the kernel

After the download is complete, generate a corresponding compressed file linux-source-3.13.0.tar.bz2 in that folder

Then extract the files from tar jxvf linux-source-3.13.0.tar.bz2

Enter the unpacked directory

Then enter root privileges su (where entry failures prompted Authentication failure), enter the following command in Terminal:
sudo passwd
Password: your current password
Enter new UNIX password: This is the root password
Retype new UNIX password: Repeat root password
You are then prompted successful.

Enter the command make oldconfig start configuring the kernel.

Before check the internet to see the kernel configuration spend an hour or so, but after I entered the command output

Information that will generate a new directory under / lib / modules After the configuration /lib/modules/3.16.0-30-generic/

Ls in the directory, I found that already exists in this directory = =! Is the original kernel source tree already exists.

Since the kernel source tree already exists, here we have to do is load the hello module into the kernel.

Here is the source code for hello

#include < linux / init.h>
#include < linux / module.h>
MODULE_LICENSE ( "Dual BSD / GPL");
static int hello_init (void)
{
    printk (KERN_ALERT "Hello, world \ n");
    return 0;
}
static void hello_exit (void)
{
    printk (KERN_ALERT "Goodbye, cruel world \ n");
}
module_init (hello_init);
module_exit (hello_exit);

For coding the Makefile

obj-m: = hello.o
KERNELDIR: = /lib/modules/3.16.0-30/build
PWD: = $ (shell pwd)
modules:
    $ (MAKE) -C $ (KERNELDIR) M = $ (PWD) modules
modules_install:
    $ (MAKE) -C $ (KERNELDIR) M = $ (PWD) modules_install

Run make

Generate the corresponding file hello.ko

Then load hello.ko module, pay attention to in root mode to load and then loaded modules lsmod View (book that will output hello world in the console, but I did not console output)

Unloading module

Although there is no console output, but you can view the output hello module in the / var / log / syslog
     
         
         
         
  More:      
 
- Mybatis + binding Struts2: achieving user to insert and find (Programming)
- IP Security Policy is to learn how to prevent Ping and closed ports (Linux)
- IBM Data Studio to use ---- window displays all rows (Database)
- Java to achieve local fileCopy (Programming)
- Dom4j change XML coding (Programming)
- About phpwind 5.01-5.3 0day analysis of the article (Linux)
- Limit the use of the request being Nginx Flood attack (Linux)
- Git 2.5 increase in the working tree, triangle improved workflow performance (Linux)
- Command-line based tools for better alternatives (Linux)
- Ubuntu 13.04 configure MyEclipse 10.7 Environment (Linux)
- The need to avoid a gap of InnoDB lock (Database)
- Firewall types and instructions (Linux)
- Ubuntu 14.04 build Gitlab (Linux)
- The Objects in JavaScript (Programming)
- MD5 and simple to use (Linux)
- On the Web application attack techniques Common (Linux)
- Linux command to view the system status (Linux)
- Syncthing: Private Security Synchronization tool to synchronize files between computers / folder (Linux)
- Linux performance optimization features Tuned and ktune (Linux)
- Nginx Proxy timeout Troubleshooting (Server)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.