0

In the linux kernel is there a file that I can start to add my code, ex. load libraries?

thanks

Coder404
  • 895
  • 5
  • 14
  • 24
  • 7
    You can't load (ordinary) libraries in the kernel. You can load modules (and how you write those is well documented on the web). Where you add custom code depends on what you're trying to do... – Mat Jul 01 '12 at 18:15
  • @Mat I wanted to take the kernel and when it finishes loading, load the MP3 Codec and play a song. – Coder404 Jul 02 '12 at 04:37
  • Why do you need to do that in kernel space? Just make an init script that calls `mpg321`, `mplayer` etc... to play your audio file. – Renan Jul 02 '12 at 17:20
  • have you entered the kernel? how is it? – Xsi Nov 23 '12 at 16:42
  • http://unix.stackexchange.com/questions/86955/does-the-kernel-have-a-main-function – Ciro Santilli OurBigBook.com Oct 29 '15 at 13:32

2 Answers2

5

If you're trying to accomplish a user-space task by directly modifying the operating system's kernel, you're doing something wrong 99.999% of the times.

For cases where a direct interaction with kernel's subsystems and data structures is required, people invented the loadable kernel modules.

I think you have a misunderstood the terms kernel and shell.

To answer your question: in order to play an mp3 file at system startup, you should probably get mpg123 or some other command-line music player, and launch it via an init script, after your sound system is initialized, as Mat already pointed out in an earlier comment.

For more information on init scripts usage, refer to your distribution's documentation and man-pages.

dkaragasidis
  • 1,896
  • 12
  • 10
2

In response to your reply to Mat, I doubt that would have anything to do with a kernel library or module; therefore, I would leave the kernel as is.

Depending on what desktop environment you are using, you can set up a program to execute after everything is loaded. I assume you have the mp3 codec on your machine. So for example, in KDE, you can access 'System Settings' and under the 'System Administration' heading, you can click on 'Task Scheduler' and set up a program to run at as a personal cron or a system cron.

Of course, I don't know exactly what you are trying to accomplish here based on what you have asked. But I think the task schedule will accomplish what you want.

slafat01
  • 227
  • 1
  • 2
  • 2
    Or use an init script to start an mp3 player as soon as the sound setup is done (that should be relatively easy with something like `mpd`). – Mat Jul 02 '12 at 13:47
  • @slafat01 I am trying not to make a GUI – Coder404 Jul 02 '12 at 15:00
  • Then don't make a GUI, make an init script that runs an audio player. There's no need to mess with kernel space. – Renan Jul 02 '12 at 17:23