iPhone – Linux – iTunes it works

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 booted up the virtualbox with a Windows OS, and installed the iTunes I was able to sort out my iPhone in the apple way!!.

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.

Mono – web development on Linux

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 the mods-enabled directory and to do this, just use the

a2enmod mod_mono_auto

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

/etc/init.d/apache2 restart

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

mod_mono_auto.conf
mod_mono_auto.load

of course you could symlink them yourself, but it is just easier to use the a2enmod script.

Within the .conf file it tells apache what extensions to “listen” to direct to the module mono instead of either php module or just a static html web page.

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.

<%@ Page Language="C#" %>
<html>
  <head>
    <title>Apache2 Mod mono test page</title>
  </head>
  <body>
        <form id="form1" runat="server">
          <asp:label id="lbl1" runat="server">Apache2 Mod mono test page</asp:label>
        </form>
  </body>
</html>

the asp:label will be the main test, since that part of the csharp library as such. you should see something like

Apache2 Mod mono test page

Acid Rip

I have just been using AcidRip to convert DVD’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 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.

mplayer -fs <filename>

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.

Linux applications

When you move from one place to another you need to find out where your local stores are (Tesco’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 is the Linux equivalent that I use.

Type Windows Application Linux alternative
MP3 player Media player (MP3) Amarok
Video player Media player (MP3 / Videos) Kaffeine
Developer tools Visual Studio
MonoDevelop
QTCreator
KDevelop
MonoDevelop
QTCreator
Text pad Notepad Kate
Office applications (Word, Spread sheets etc)

Office
Open Office
Open Office
FTP Filezilla Filezilla
Web browser Firefox
Opera
IE
Chrome
Firefox
Opera
Chrome

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.

k/ubuntu update path

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 rest for you, update – upgrade your system..

Not much more to say really apart from once I have updated I shall have to say what I think of the 10.4 LTS (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!.

kernel – hello world

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 I used

aptitude install linux-headers

that is normally linked to the latest version of the linux kernel that you are using.

The main part of the program is outputting a potential parameter being passed (passing parameters to a nvidia kernel module here) and also saying hello world, kinder two for the price of one as such tutorial.

As in c language there is the printf, but in the kernel there is a printk which is the same similar thing but more for outputting errors/messages to the user.

So for example

printk(KERN_INFO "hi there\n");

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

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)

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.

static int parameter_int = 0;
module_param(parameter_int, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
MODULE_PARM_DESC(parameter_int, "An integer value");

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,

module_init(hello_init);
module_exit(hello_exit);

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.

Here is the full code, if you save this as helloworld_parameter.c

/* hello world with passing some parameters in the kernel module */
 
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/stat.h>
 
MODULE_LICENSE("GPL");
MODULE_AUTHOR("genux");
 
/* need to setup a setup a static variable to hold the parameter value and
   set it to a default value is none is passed */
static int parameter_int = 0;
 
/* the linux/stat.h has the S_IRUSR definitions etc.. */
/* S_IRUSR = read permission, owner
   S_IWUSR = write permission, owner
   S_IRGRP = read permission, group
   S_IROTH = read permission, others
   */
 
module_param(parameter_int, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
MODULE_PARM_DESC(parameter_int, "An integer value");
 
static int __init hello_init(void)
{
	printk(KERN_INFO "Hello world\n\n");
	printk(KERN_INFO "my parameter int value is : %d\n", parameter_int);
	return 0;
}
 
static void __exit hello_exit(void)
{
	printk(KERN_INFO "Goodbye from hello world parameter\n");
}
 
module_init(hello_init);
module_exit(hello_exit);

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 “Makefile”

obj-m += helloworld_parameter.o
 
all:
	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
 
clean:
	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

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.

once you have run the

make

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

modinfo helloworld_parameter.ko
filename:       helloworld_parameter.ko
author:         genux
license:        GPL
srcversion:     A81F18D40DA3C5FAB1C71FF
depends:
vermagic:       2.6.31-17-generic SMP mod_unload modversions
parm:           parameter_int:An interger value (int)

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

tail -f /var/log/messages

in the second console do

insmod helloworld_parameter.ko
rmmod helloworld_parameter.ko
insmod helloworld_parameter.ko parameter_int=3
rmmod helloworld_parameter.ko

and the output should be in the first console

Hello world
 
my parameter int value is : 0
Goodbye from hello world parameter
 
Hello world
 
my parameter int value is : 3
Goodbye from hello world parameter

hope that helps with kernel modules, I am planning on doing a kernel module for a custom built USB device.

kernel – passing module parameters

With normal programs that allow you pass parameters on there command line, for example

printoutmyname genux

where the program is called printoutmyname and the first parameter is genux (it is normal that the first parameter [0] is actually the program name and the second parameter [1] is the parameter that is passed)

Well in Linux kernel (where here is a example on how to compile the kernel for a ubuntu based setup) you can pass parameters to the modules that are getting loaded. One module would be your graphics card, in my case a nvidia graphics card.

To find out what parameters can be passed to the graphics card you will have to find the kernel module file (filename.ko, where the ko is the kernel object file), so to search for the nvidia.ko in my case I did

locate nvidia.ko

and then changed to that directory and did a module information on it

cd /lib/modules/2.6.31-17-generic/updates/dkms/
ls
nvidia.ko  vboxdrv.ko  vboxnetadp.ko  vboxnetflt.ko

and doing a module information on it you call the modinfo on the kernel object file as

modinfo nvidia.ko
</pre
 
my output was
 
<pre lang="bash">
filename:       nvidia.ko
license:        NVIDIA
alias:          char-major-195-*
alias:          pci:v000010DEd*sv*sd*bc03sc02i00*
alias:          pci:v000010DEd*sv*sd*bc03sc00i00*
depends:
vermagic:       2.6.31-17-generic SMP mod_unload modversions
parm:           NVreg_EnableVia4x:int
parm:           NVreg_EnableALiAGP:int
parm:           NVreg_ReqAGPRate:int
parm:           NVreg_EnableAGPSBA:int
parm:           NVreg_EnableAGPFW:int
parm:           NVreg_Mobile:int
parm:           NVreg_ResmanDebugLevel:int
parm:           NVreg_RmLogonRC:int
parm:           NVreg_ModifyDeviceFiles:int
parm:           NVreg_DeviceFileUID:int
parm:           NVreg_DeviceFileGID:int
parm:           NVreg_DeviceFileMode:int
parm:           NVreg_RemapLimit:int
parm:           NVreg_UpdateMemoryTypes:int
parm:           NVreg_UseVBios:int
parm:           NVreg_RMEdgeIntrCheck:int
parm:           NVreg_UsePageAttributeTable:int
parm:           NVreg_EnableMSI:int
parm:           NVreg_MapRegistersEarly:int
parm:           NVreg_RmNvclkIdleGraphics:int
parm:           NVreg_RegistryDwords:charp
parm:           NVreg_NvAGP:int

where the parm: is a parameter to pass to the module on load (insmod, or loaded via the kernel at boot time which you can force to load via the /etc/modules file and the parameters can be placed in the /etc/modprobe.d directory).

for example to load the nvidia module with a parameter NVreg_NvAGP you would do something like

insmod nvidia.ko NVreg_NvAGP=1

and the passing value is 1 to the NVreg_NvAGP parameter