Sponsored Content
Top Forums UNIX for Advanced & Expert Users program that boots at OS startup Post 28391 by preetham on Tuesday 17th of September 2002 10:36:29 PM
Old 09-17-2002
Re: Re: Re: Your file locations may vary but should be similar

thank you Optimus,
First, let me assure you that i have no intention of hacking, im not a hacker, can't afford to be one...i just code for food man Smilie

I have this hello world kernal module code:
Code:
/* Declare what kind of code we want from the header files */
#define __KERNEL__         /* We're part of the kernel */
#define MODULE             /* Not a permanent part, though. */

/* Standard headers for LKMs */
#include <linux/modversions.h> 
#include <linux/module.h>  

#define _LOOSE_KERNEL_NAMES
    /* With some combinations of Linux and gcc, tty.h will not compile if
       you don't define _LOOSE_KERNEL_NAMES.  It's a bug somewhere.
    */
#include <linux/tty.h>      /* console_print() interface */

/* Initialize the LKM */
int init_module()
{
  console_print("Hello, world - this is the kernel speaking\n");
  /* More normal is printk(), but there's less that can go wrong with 
     console_print(), so let's start simple.
  */

  /* If we return a non zero value, it means that 
   * init_module failed and the LKM can't be loaded 
   */
  return 0;
}


/* Cleanup - undo whatever init_module did */
void cleanup_module()
{
  console_print("Short is the life of an LKM\n");
}

i compile the program using the command:
gcc -c hello.c -Wall

When i compile the program i get the following errors:
/usr/include/linux/modversions.h:1:2: #error Modules should never use kernel-headers system headers,
/usr/include/linux/modversions.h:2:2: #error but rather headers from an appropriate kernel-source package.
/usr/include/linux/modversions.h:3:2: #error Change -I/usr/src/linux/include (or similar) to
/usr/include/linux/modversions.h:4:2: #error -I/lib/modules/$(uname -r)/build/include
/usr/include/linux/modversions.h:5:2: #error to build against the currently-running kernel.

Appreciate the help.
thanks,
Preetham.

added code tags for readability --oombera

Last edited by oombera; 02-20-2004 at 03:43 PM..
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

auto startup of a program

how do i make a program run at system startup? is there a hirarchy i have to consider? is there any equivalent to an NT "Service" in unix? how do you set it up? thanx Ron (2 Replies)
Discussion started by: exoron
2 Replies

2. Solaris

NIS Boots Me Out

I have a NIS environment using all Solaris 9 systems. After all kinds of trobleshooting i am to the point where I can login to a NIS account from a client system. However, the logon process starts and the splash screen is displayed and then the desk top is displayed but then it flashes and kicks... (1 Reply)
Discussion started by: meyersp
1 Replies

3. Shell Programming and Scripting

How can I make a program start up automatically after the computer restart/startup?

hi all How can I make a program start up automatically after the computer restart/startup in fedora? something like: ... Establish a shell then run some of command code. Thanks for Help!! (1 Reply)
Discussion started by: munna_dude
1 Replies

4. Red Hat

Fedora on Laptop No Longer Boots

Hi, I'm a bit of a newbie, so please bare with me. I installed Fedora 10 on a Dell Latitude D610 a few weeks ago. The computer previously had Windows on it, but I wiped it clean. I've been trying out Fedora successfully for the past couple of weeks and I was able to use the computer as recently... (1 Reply)
Discussion started by: iansocool
1 Replies

5. OS X (Apple)

How to execute a command when system boots?

Hi all, I want to execute a command when system boots. I tried to edit /etc/rc.common and add my command at the end of rc.common, but it does not work! Anyone knows how to do it? Thanks :) (6 Replies)
Discussion started by: andrewust
6 Replies

6. Ubuntu

execute command when Ubuntu boots up ?

hey all,, I want to add comments when Ubuntu starts up.. now I know that there is a directory called /etc/init.d which I can place my scripts there to run them at Ubuntu's startup.. but I prefer if there would be a file which runs when Ubuntu starts!! because it is only one command. not... (2 Replies)
Discussion started by: eawedat
2 Replies

7. Shell Programming and Scripting

Launch a text program inside a konsole at startup

Hi ULFers, I am trying to setup a (very) simple startup script on a centos 6.4 computer and it kind of failed.... Here are the details : As said just above the computer setup is running a CentOS 6.4 x64, on this computer a vncserver is automatically started (by a chkconfig vncserver on), i... (1 Reply)
Discussion started by: pierpier
1 Replies

8. Shell Programming and Scripting

Apache tomcat startup script not booting at startup.

I copied the script from an AskUbuntu post - #!/bin/bash ### BEGIN INIT INFO # Provides: tomcat7 # Required-Start: $network # Required-Stop: $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start/Stop Tomcat server ### END INIT INFO ... (14 Replies)
Discussion started by: Hijanoqu
14 Replies

9. HP-UX

HP-UX server boots to black graphical screen

hello all, please can you help me crack this.... i have an hp-ux server which when after booting it does not completely boot to graphical. it stops aa black screen with only an hour glass showing. at this stage only the mouse responds but the keyboard does not respond. any idea to find... (5 Replies)
Discussion started by: steveGH
5 Replies
CREATE_MODULE(2)					     Linux Programmer's Manual						  CREATE_MODULE(2)

NAME
create_module - create a loadable module entry SYNOPSIS
#include <linux/module.h> caddr_t create_module(const char *name, size_t size); Note: No declaration of this system call is provided in glibc headers; see NOTES. DESCRIPTION
Note: This system call is present only in kernels before Linux 2.6. create_module() attempts to create a loadable module entry and reserve the kernel memory that will be needed to hold the module. This sys- tem call requires privilege. RETURN VALUE
On success, returns the kernel address at which the module will reside. On error, -1 is returned and errno is set appropriately. ERRORS
EEXIST A module by that name already exists. EFAULT name is outside the program's accessible address space. EINVAL The requested size is too small even for the module header information. ENOMEM The kernel could not allocate a contiguous block of memory large enough for the module. ENOSYS create_module() is not supported in this version of the kernel (e.g., the kernel is version 2.6 or later). EPERM The caller was not privileged (did not have the CAP_SYS_MODULE capability). VERSIONS
This system call is present on Linux only up until kernel 2.4; it was removed in Linux 2.6. CONFORMING TO
create_module() is Linux-specific. NOTES
This obsolete system call is not supported by glibc. No declaration is provided in glibc headers, but, through a quirk of history, glibc versions before 2.23 did export an ABI for this system call. Therefore, in order to employ this system call, it was sufficient to manually declare the interface in your code; alternatively, you could invoke the system call using syscall(2). SEE ALSO
delete_module(2), init_module(2), query_module(2) COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. Linux 2017-09-15 CREATE_MODULE(2)
All times are GMT -4. The time now is 12:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy