<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Coding Friends &#187; Linux</title>
	<atom:link href="http://www.codingfriends.com/index.php/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codingfriends.com</link>
	<description>Coding Friends, place for developers.</description>
	<lastBuildDate>Mon, 06 Sep 2010 20:18:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>upstart &#8211; emit &#8211; start on network</title>
		<link>http://www.codingfriends.com/index.php/2010/04/22/upstart-emit-start-on-network/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=upstart-emit-start-on-network</link>
		<comments>http://www.codingfriends.com/index.php/2010/04/22/upstart-emit-start-on-network/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 21:07:06 +0000</pubDate>
		<dc:creator>genux</dc:creator>
				<category><![CDATA[Linux install and configurations]]></category>
		<category><![CDATA[upstart]]></category>

		<guid isPermaLink="false">http://www.codingfriends.com/?p=904</guid>
		<description><![CDATA[I have been reading some of the funky things in ubuntu implementations that has been happening in the distribution. One of the things that I like is the upstart, this changes the way that init (the process of the computer system from boot to console/GUI for creating the different runlevels ). In essence, it replaces [...]]]></description>
			<content:encoded><![CDATA[<p>I have been reading some of the funky things in <a href="http://www.ubuntu.com/">ubuntu</a> implementations that has been happening in the distribution.  One of the things that I like is the <a href="http://upstart.ubuntu.com">upstart</a>, this changes the way that init (the process of the computer system from boot to console/GUI for creating the different <a href="http://en.wikipedia.org/wiki/Runlevel">runlevels</a> ).</p>
<p>In essence, it replaces the /sys/init daemon which handles the start up and shutting down, looking after tasks/services during boot/running and shutdown.</p>
<p>One of the things that is great is that the upstart will &#8220;emit&#8221; and signal to other services to &#8220;start on&#8221; when that signal has been emitted, to demonstrate this when a network card is activated for the Ethernet (for example) in the &#8220;/etc/network/if-up.d/upstart&#8221;</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">initctl emit <span style="color: #660033;">-n</span> net-device-up \</pre></div></div>

<p>which basically says when a network device because in a state of up emit a signal, the state of being up is when the device is active.  Then in the /etc/init/mountall-net.conf file</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">description     <span style="color: #ff0000;">&quot;Mount network filesystems&quot;</span>
&nbsp;
start on net-device-up</pre></div></div>

<p>is listening for the emitted signal of net-device-up and thus the upstart will start the networking filesystems.</p>
<p>Another example is within the /etc/init/mountall.conf there is the emitting of a signal</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mountall.conf:emits virtual-filesystems</pre></div></div>

<p>the signal is virtual-filesystems which is then picked up with the udev.conf with the</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">start on virtual-filesystems</pre></div></div>

<p>since udev is a virtual filesystem in the /dev and /sys directories.</p>
<p>I find the stuff that <a href="http://www.canonical.com/">Canonical</a> is doing with the ubuntu linux distribution is just great.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingfriends.com/index.php/2010/04/22/upstart-emit-start-on-network/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone &#8211; Linux &#8211; iTunes it works</title>
		<link>http://www.codingfriends.com/index.php/2010/04/19/iphone-linux-itunes-it-works/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=iphone-linux-itunes-it-works</link>
		<comments>http://www.codingfriends.com/index.php/2010/04/19/iphone-linux-itunes-it-works/#comments</comments>
		<pubDate>Mon, 19 Apr 2010 11:06:30 +0000</pubDate>
		<dc:creator>genux</dc:creator>
				<category><![CDATA[Linux install and configurations]]></category>
		<category><![CDATA[3GS]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[iTunes]]></category>

		<guid isPermaLink="false">http://www.codingfriends.com/?p=891</guid>
		<description><![CDATA[I have been using gtkPod and also amarok, but sometimes I just missed that iTunes interface to sync with my iPhone 3GS (16GB). Well, with using the virtual box ( you will need to get the Sun version and not the OSE (open source edition) because the Sun edition has the USB parts) Then I [...]]]></description>
			<content:encoded><![CDATA[<p>I have been using <a href="http://www.gtkpod.org/about.html">gtkPod</a> and also <a href="http://amarok.kde.org/">amarok</a>, but sometimes I just missed that iTunes interface to sync with my iPhone 3GS (16GB).</p>
<p>Well, with using the <a href="http://www.virtualbox.org">virtual box</a> ( you will need to get the <a href="http://www.virtualbox.org/wiki/Linux_Downloads">Sun version</a> and not the OSE (open source edition) because the Sun edition has the USB parts)</p>
<p>Then I booted up the virtualbox with a Windows OS, and installed the <a href="http://www.apple.com/itunes/download/">iTunes</a>  I was able to sort out my iPhone in the apple way!!.</p>
<p>It is still kinder annoying that apple are not making iTunes for Linux, but with this setup at least I am able to still use the iTunes interface with my phone and sync correctly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingfriends.com/index.php/2010/04/19/iphone-linux-itunes-it-works/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mono &#8211; web development on Linux</title>
		<link>http://www.codingfriends.com/index.php/2010/04/14/mono-web-development-on-linux/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=mono-web-development-on-linux</link>
		<comments>http://www.codingfriends.com/index.php/2010/04/14/mono-web-development-on-linux/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 09:38:45 +0000</pubDate>
		<dc:creator>genux</dc:creator>
				<category><![CDATA[C Sharp (c#)]]></category>
		<category><![CDATA[Linux install and configurations]]></category>
		<category><![CDATA[Apache2]]></category>
		<category><![CDATA[mono]]></category>
		<category><![CDATA[web server]]></category>

		<guid isPermaLink="false">http://www.codingfriends.com/?p=873</guid>
		<description><![CDATA[It is really easy to get some web c# (csharp) (asp.net) development within a Linux setup, since I use kubuntu which is derived from ubuntu. All you need to do is to this installs the mono module for the apache2 aptitude install libapache2-mod-mono to enable the module to work within apache2 you have to update [...]]]></description>
			<content:encoded><![CDATA[<p>It is really easy to get some web c# (csharp) (asp.net) development within a Linux setup, since I use kubuntu which is derived from ubuntu.  All you need to do is to</p>
<p>this installs the mono module for the apache2</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> libapache2-mod-mono</pre></div></div>

<p>to enable the module to work within apache2 you have to update the mods-enabled directory and to do this, just use the</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">a2enmod mod_mono_auto</pre></div></div>

<p>which stands for apache2 (a2) enable (en) mod (module) and then the module name, you will need to restart apache2 for it to work</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2 restart</pre></div></div>

<p>that is it., then if you look within the /etc/apache2/mods-enabled you will notice the</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mod_mono_auto.conf
mod_mono_auto.load</pre></div></div>

<p>of course you could symlink them yourself, but it is just easier to use the a2enmod script.</p>
<p>Within the .conf file it tells apache what extensions to &#8220;listen&#8221; to direct to the module mono instead of either php module or just a static html web page.</p>
<p>To test the setup, just create a directory within your hosting directory this is normally /var/www/ or just place a file in that base directory /var/www it is up to you, but within that file you could create a basic test file like.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&lt;%</span>@ Page Language<span style="color: #008000;">=</span><span style="color: #666666;">&quot;C#&quot;</span> <span style="color: #008000;">%&gt;</span>
<span style="color: #008000;">&lt;</span>html<span style="color: #008000;">&gt;</span>
  <span style="color: #008000;">&lt;</span>head<span style="color: #008000;">&gt;</span>
    <span style="color: #008000;">&lt;</span>title<span style="color: #008000;">&gt;</span>Apache2 Mod mono test page<span style="color: #008000;">&lt;/</span>title<span style="color: #008000;">&gt;</span>
  <span style="color: #008000;">&lt;/</span>head<span style="color: #008000;">&gt;</span>
  <span style="color: #008000;">&lt;</span>body<span style="color: #008000;">&gt;</span>
        <span style="color: #008000;">&lt;</span>form id<span style="color: #008000;">=</span><span style="color: #666666;">&quot;form1&quot;</span> runat<span style="color: #008000;">=</span><span style="color: #666666;">&quot;server&quot;</span><span style="color: #008000;">&gt;</span>
          <span style="color: #008000;">&lt;</span>asp<span style="color: #008000;">:</span>label id<span style="color: #008000;">=</span><span style="color: #666666;">&quot;lbl1&quot;</span> runat<span style="color: #008000;">=</span><span style="color: #666666;">&quot;server&quot;</span><span style="color: #008000;">&gt;</span>Apache2 Mod mono test page<span style="color: #008000;">&lt;/</span>asp<span style="color: #008000;">:</span>label<span style="color: #008000;">&gt;</span>
        <span style="color: #008000;">&lt;/</span>form<span style="color: #008000;">&gt;</span>
  <span style="color: #008000;">&lt;/</span>body<span style="color: #008000;">&gt;</span>
<span style="color: #008000;">&lt;/</span>html<span style="color: #008000;">&gt;</span></pre></div></div>

<p>the asp:label will be the main test, since that part of the csharp library as such. you should see something like</p>
<p>Apache2 Mod mono test page</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingfriends.com/index.php/2010/04/14/mono-web-development-on-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Acid Rip</title>
		<link>http://www.codingfriends.com/index.php/2010/04/07/acid-rip/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=acid-rip</link>
		<comments>http://www.codingfriends.com/index.php/2010/04/07/acid-rip/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 10:29:02 +0000</pubDate>
		<dc:creator>genux</dc:creator>
				<category><![CDATA[Video]]></category>
		<category><![CDATA[AVI]]></category>
		<category><![CDATA[DVD]]></category>
		<category><![CDATA[LAME]]></category>
		<category><![CDATA[rip]]></category>

		<guid isPermaLink="false">http://www.codingfriends.com/?p=846</guid>
		<description><![CDATA[I have just been using AcidRip to convert DVD&#8217;s into AVI files so that I can I copies of family movies in a more compressed format.. it will either use a DVD disk or a DVD image on a harddrive to convert to the required format that you want. It uses mencoder which is part [...]]]></description>
			<content:encoded><![CDATA[<p>I have just been using <a href="http://untrepid.com/acidrip/">AcidRip</a> to convert DVD&#8217;s into AVI files so that I can I copies of family movies in a more compressed format..  it will either use a DVD disk or a DVD image on a harddrive to convert to the required format that you want.  </p>
<p>It uses <a href="http://www.mplayerhq.hu/design7/news.html">mencoder</a> which is part of the mplayer suit of applications, mplayer is also a very nice movie player too, which I use mainly from the command line, but there is also a GUI for it.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mplayer</span> <span style="color: #660033;">-fs</span> <span style="color: #000000; font-weight: bold;">&lt;</span>filename<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>would play a video in full screen (-fs) and since I do have a console window open most of the time then it is sometimes just easier to use the console to play a video. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingfriends.com/index.php/2010/04/07/acid-rip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux applications</title>
		<link>http://www.codingfriends.com/index.php/2010/03/24/linux-applications/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=linux-applications</link>
		<comments>http://www.codingfriends.com/index.php/2010/03/24/linux-applications/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 10:24:28 +0000</pubDate>
		<dc:creator>genux</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[applications]]></category>

		<guid isPermaLink="false">http://www.codingfriends.com/?p=825</guid>
		<description><![CDATA[When you move from one place to another you need to find out where your local stores are (Tesco&#8217;s, Sainburies etc) also it is the same when you move from one operating system to another. I am going to add to this list where ever possible, the first is the windows application and the second [...]]]></description>
			<content:encoded><![CDATA[<p>When you move from one place to another you need to find out where your local stores are (Tesco&#8217;s, Sainburies etc) also it is the same when you move from one operating system to another.</p>
<p>I am going to add to this list where ever possible, the first is the windows application and the second is the Linux equivalent that I use.</p>
<table border="1">
<tr>
<td width="33%">Type</td>
<td width="33%">Windows Application</td>
<td width="33%">Linux alternative</td>
</tr>
<tr>
<td>MP3 player</td>
<td><a href="http://www.microsoft.com/windows/windowsmedia/default.mspx">Media player (MP3)</a></td>
<td><a href="http://amarok.kde.org/">Amarok</a></td>
</tr>
<tr>
<td>Video player</td>
<td><a href="http://www.microsoft.com/windows/windowsmedia/default.mspx">Media player (MP3 / Videos)</a></td>
<td><a href="http://kaffeine.kde.org/">Kaffeine</a></td>
</tr>
<tr>
<td>Developer tools</td>
<td><a href="http://msdn.microsoft.com/en-us/vstudio/default.aspx">Visual Studio</a><br/><a href="http://monodevelop.com/">MonoDevelop</a><br/><a href="http://qt.nokia.com/products/developer-tools">QTCreator</a></td>
<td><a href="http://www.kdevelop.org/">KDevelop</a><br/><a href="http://monodevelop.com/">MonoDevelop</a><br/><a href="http://qt.nokia.com/products/developer-tools">QTCreator</a></td>
</tr>
<tr>
<td>Text pad</td>
<td><a href="http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/app_notepad.mspx?mfr=true">Notepad</a></td>
<td><a href="http://kate-editor.org/">Kate</a></td>
</tr>
<tr>
<td>Office applications (Word, Spread sheets etc)
<td><a href="http://office.microsoft.com/en-us/default.aspx">Office</a><br/><a href="http://www.openoffice.org/">Open Office</a></td>
<td><a href="http://www.openoffice.org/">Open Office</a></td>
</tr>
<tr>
<td>FTP</td>
<td><a href="http://filezilla-project.org/">Filezilla</a></td>
<td><a href="http://filezilla-project.org/">Filezilla</a></td>
</tr>
<tr>
<td>Web browser</td>
<td><a href="http://www.mozilla.com/en-US/firefox/personal.html">Firefox</a><br/><a href="http://www.opera.com/">Opera</a><br/><a href="http://www.microsoft.com/windows/internet-explorer/default.aspx">IE</a><br/><a href="http://www.google.com/chrome">Chrome</a></td>
<td><a href="http://www.mozilla.com/en-US/firefox/personal.html">Firefox</a><br/><a href="http://www.opera.com/">Opera</a><br/><a href="http://www.google.com/chrome">Chrome</a></td>
</tr>
</table>
<p>There is a couple of applications in there that also can be used within Windows Operating System as well, so you can try out open source applications without moving operating system to find out if you are able to use that application before moving over to Linux.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingfriends.com/index.php/2010/03/24/linux-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>k/ubuntu update path</title>
		<link>http://www.codingfriends.com/index.php/2010/03/21/kubuntu-update-path/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=kubuntu-update-path</link>
		<comments>http://www.codingfriends.com/index.php/2010/03/21/kubuntu-update-path/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 09:40:15 +0000</pubDate>
		<dc:creator>genux</dc:creator>
				<category><![CDATA[Ubuntu/Kubuntu]]></category>
		<category><![CDATA[kubuntu]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[update]]></category>
		<category><![CDATA[upgrade]]></category>

		<guid isPermaLink="false">http://www.codingfriends.com/?p=823</guid>
		<description><![CDATA[I am upgrading 9.10 to 10.4 Kubuntu (the 9.10 means 2009 and the month of October (10), so thus 10.4 means 2010 and the month of April). It really could not be any easier just open up a quick run command ALT + F2 and then type in update-notifier-kde -d And it will do the [...]]]></description>
			<content:encoded><![CDATA[<p>I am upgrading 9.10 to 10.4 <a href="http://www.kubuntu.org/">Kubuntu</a> (the 9.10 means 2009 and the month of October (10), so thus 10.4 means 2010 and the month of April).</p>
<p>It really could not be any easier just open up a quick run command</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ALT + F2</pre></div></div>

<p>and then type in</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">update-notifier-kde <span style="color: #660033;">-d</span></pre></div></div>

<p>And it will do the rest for you, update &#8211; upgrade your system..</p>
<p>Not much more to say really apart from once I have updated I shall have to say what I think of the 10.4 <a href="https://wiki.ubuntu.com/LTS">LTS</a> (Long Term Support) version.  Which the LTS has 2 year release cycle, 3 years support for the desktop and 5 years for a server, that is just great!.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingfriends.com/index.php/2010/03/21/kubuntu-update-path/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>kernel &#8211; hello world</title>
		<link>http://www.codingfriends.com/index.php/2010/03/01/kernel-hello-world/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=kernel-hello-world</link>
		<comments>http://www.codingfriends.com/index.php/2010/03/01/kernel-hello-world/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 10:25:39 +0000</pubDate>
		<dc:creator>genux</dc:creator>
				<category><![CDATA[C / C++]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[hello world]]></category>
		<category><![CDATA[Kernel]]></category>

		<guid isPermaLink="false">http://www.codingfriends.com/?p=761</guid>
		<description><![CDATA[To compile up this module you will need to have the linux header files, which should be installed but if not you just need to either use apt-get, rpm, pacman etc to install the linux header files. With kubuntu I use the aptitude command to install applications and updates etc, but to get the linux-headers [...]]]></description>
			<content:encoded><![CDATA[<p>To compile up this module you will need to have the linux header files, which should be installed but if not you just need to either use apt-get, rpm, pacman etc to install the linux header files.</p>
<p>With <a href="http://www.kubuntu.org/">kubuntu</a> I use the aptitude command to install applications and updates etc, but to get the linux-headers I used</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> linux-headers</pre></div></div>

<p>that is normally linked to the latest version of the linux kernel that you are using.</p>
<p>The main part of the program is outputting a potential parameter being passed (passing parameters to a nvidia kernel module <a href="http://www.codingfriends.com/index.php/2010/02/27/kernel-passing-module-parameters/">here</a>) and also saying hello world, kinder two for the price of one as such tutorial. </p>
<p>As in c language there is the <a href="http://en.wikipedia.org/wiki/Printf">printf</a>, but in the kernel there is a printk which is the same similar thing but more for outputting errors/messages to the user.</p>
<p>So for example</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;">printk<span style="color: #008000;">&#40;</span>KERN_INFO <span style="color: #FF0000;">&quot;hi there<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></div></div>

<p>the KERN_INFO is a kernel information marco that sends the details to a information level of output, e.g. /var/log/messages or you could use dmesg</p>
<p>here is the code on how to pull in parameters from a kernel module being loaded, the parameter_int is my parameter to be checked against and the S_IRUSR is the access rights (IR = read permission, IW = write permission, USR = user, GRP = group, OTH = others)</p>
<p>The module_param takes 3 parameters, the first is the variable to place the value into, second is the variable type and the third is the access rights, with the MODULE_PARM_DESC is the description of the parameter to pass, in this case it is just a integer value.</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #0000ff;">static</span> <span style="color: #0000ff;">int</span> parameter_int <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
module_param<span style="color: #008000;">&#40;</span>parameter_int, <span style="color: #0000ff;">int</span>, S_IRUSR <span style="color: #000040;">|</span> S_IWUSR <span style="color: #000040;">|</span> S_IRGRP <span style="color: #000040;">|</span> S_IROTH<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
MODULE_PARM_DESC<span style="color: #008000;">&#40;</span>parameter_int, <span style="color: #FF0000;">&quot;An integer value&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></div></div>

<p>Within a normal c/c++ program there is a main function where the program is run from, but in the kernel space since the main program is already running you can define what functions to call when the module is inserted and also removed,</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;">module_init<span style="color: #008000;">&#40;</span>hello_init<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
module_exit<span style="color: #008000;">&#40;</span>hello_exit<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></div></div>

<p>the module_init parameter is the function to call when the module is loaded and the module_exit parameter is the function to call when module is removed from the kernel space.</p>
<p>Here is the full code, if you save this as helloworld_parameter.c</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #ff0000; font-style: italic;">/* hello world with passing some parameters in the kernel module */</span>
&nbsp;
<span style="color: #339900;">#include &lt;linux/module.h&gt;</span>
<span style="color: #339900;">#include &lt;linux/moduleparam.h&gt;</span>
<span style="color: #339900;">#include &lt;linux/kernel.h&gt;</span>
<span style="color: #339900;">#include &lt;linux/init.h&gt;</span>
<span style="color: #339900;">#include &lt;linux/stat.h&gt;</span>
&nbsp;
MODULE_LICENSE<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;GPL&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
MODULE_AUTHOR<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;genux&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #ff0000; font-style: italic;">/* need to setup a setup a static variable to hold the parameter value and
   set it to a default value is none is passed */</span>
<span style="color: #0000ff;">static</span> <span style="color: #0000ff;">int</span> parameter_int <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #ff0000; font-style: italic;">/* the linux/stat.h has the S_IRUSR definitions etc.. */</span>
<span style="color: #ff0000; font-style: italic;">/* S_IRUSR = read permission, owner
   S_IWUSR = write permission, owner
   S_IRGRP = read permission, group
   S_IROTH = read permission, others
   */</span>
&nbsp;
module_param<span style="color: #008000;">&#40;</span>parameter_int, <span style="color: #0000ff;">int</span>, S_IRUSR <span style="color: #000040;">|</span> S_IWUSR <span style="color: #000040;">|</span> S_IRGRP <span style="color: #000040;">|</span> S_IROTH<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
MODULE_PARM_DESC<span style="color: #008000;">&#40;</span>parameter_int, <span style="color: #FF0000;">&quot;An integer value&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">static</span> <span style="color: #0000ff;">int</span> __init hello_init<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	printk<span style="color: #008000;">&#40;</span>KERN_INFO <span style="color: #FF0000;">&quot;Hello world<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	printk<span style="color: #008000;">&#40;</span>KERN_INFO <span style="color: #FF0000;">&quot;my parameter int value is : %d<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>, parameter_int<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span> __exit hello_exit<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	printk<span style="color: #008000;">&#40;</span>KERN_INFO <span style="color: #FF0000;">&quot;Goodbye from hello world parameter<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
module_init<span style="color: #008000;">&#40;</span>hello_init<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
module_exit<span style="color: #008000;">&#40;</span>hello_exit<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></pre></div></div>

<p>since we are compiling a kernel module we need to link to the loaded kernel modules, here is a Makefile to compile up the program, so save this as &#8220;Makefile&#8221;</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">obj-m += helloworld_parameter.o
&nbsp;
all:
	<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #660033;">-C</span> <span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>modules<span style="color: #000000; font-weight: bold;">/</span>$<span style="color: #7a0874; font-weight: bold;">&#40;</span>shell <span style="color: #c20cb9; font-weight: bold;">uname</span> -r<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span>build <span style="color: #007800;">M</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span>PWD<span style="color: #7a0874; font-weight: bold;">&#41;</span> modules
&nbsp;
clean:
	<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #660033;">-C</span> <span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>modules<span style="color: #000000; font-weight: bold;">/</span>$<span style="color: #7a0874; font-weight: bold;">&#40;</span>shell <span style="color: #c20cb9; font-weight: bold;">uname</span> -r<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span>build <span style="color: #007800;">M</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span>PWD<span style="color: #7a0874; font-weight: bold;">&#41;</span> clean</pre></div></div>

<p>the first is the obj-m += which means compile a object module and you could have more than one file to compile up so use the += to add more files to it, the -C means change directory for the build environment for the kernel space, the M is a parameter passed to the build environment to use this current directory for where the source files are, and the modules means to create kernel modules e.g. filename.ko.</p>
<p>once you have run the</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">make</span></pre></div></div>

<p>there should be a file called helloworld_parameter.ko, to find out details about your new module you can use the modinfo</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">modinfo helloworld_parameter.ko
filename:       helloworld_parameter.ko
author:         genux
license:        GPL
srcversion:     A81F18D40DA3C5FAB1C71FF
depends:
vermagic:       2.6.31-<span style="color: #000000;">17</span>-generic SMP mod_unload modversions
parm:           parameter_int:An interger value <span style="color: #7a0874; font-weight: bold;">&#40;</span>int<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>and the parm: is the important part here, it is what the parameter is called to pass a value to for example to watch the module being inserted if you open up two consoles and on one put</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>messages</pre></div></div>

<p>in the second console do</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">insmod helloworld_parameter.ko
rmmod helloworld_parameter.ko
insmod helloworld_parameter.ko <span style="color: #007800;">parameter_int</span>=<span style="color: #000000;">3</span>
rmmod helloworld_parameter.ko</pre></div></div>

<p>and the output should be in the first console</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Hello world
&nbsp;
my parameter int value is : <span style="color: #000000;">0</span>
Goodbye from hello world parameter
&nbsp;
Hello world
&nbsp;
my parameter int value is : <span style="color: #000000;">3</span>
Goodbye from hello world parameter</pre></div></div>

<p>hope that helps with kernel modules, I am planning on doing a kernel module for a custom built USB device.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingfriends.com/index.php/2010/03/01/kernel-hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
