Skip to main content

the avatar of Flavio Castelli

Two new entries in my life

Last week two new entries entered my life.A shiny brand-new _Macbook pro _arrived on Thursday. I’ve always dreamed of one of this wonderful laptops (I’ve been an happy iBook user for a long time). Two weeks ago I finally surrendered (I’ve always been scared of the high price) and I’ve ordered this new toy. Now, after one week of usage I’m really happy about it.

Currently I’m using Linux as primary Os, but I’ll give a try also to KDE4 on Mac ;)

The other new entry is Baguette, a three-months old dachshund. She’s really lovely, running around the house eating random things like shoes (I think it’s a must for all pets) and usb cables (she’s already a geek-dog).

I think I’ll have to keep an eye on Baguette, otherwise I’ll find another bite on my Macbook pro apple ;)

the avatar of Andrés G. Aragoneses

Unmanaged documentation hard to manage

I'm not supposed to deal much with low level technologies (unmanaged code, C language...), but in order to test things from the beginning to allow myself understand things better, I'm dealing with Atk for later translating code to C#+Atk#.

One of the things I hate more is not having the excellent refactoring options that the modern IDE's nowadays can provide. For example, how do I know where is some element defined (in my code? in a reference? in which reference?)? Sometimes I find myself copy-pasting a function into another empty test project and start adding references to it until it compiles. Someone would say: hey but there's a lot of documentation out there! Really? Take this example:

Function: g_type_class_ref
- It smells like a Glib/Gobject function.
- Surprisingly, calling it in a test project that has a reference to glib doesn't work.
- More surprisingly, calling it in a test project that has a reference to glib and atk works.
- Mmmm, but it doesn't smell like an ATK component, right? Maybe atk ref already depends on the lib I'm looking for...
- Let's google it...
- WTF! the majority of links provided are forums, not docs.
- Finally got one from the LinuxFoundation, which tells me something about a libgobject-2.0 thingy... but that lib is not in my system.
- Anyway, the page redirects me to the "Gobject 2.6.2 Reference Manual"...
- But! it's a broken link which ends on main gtk.org doc page.
- Well, then, let's look for "site:gtk.org g_type_class_ref"... No results!

Ok ok, this is not C language fault, but how do you guys get to know these type of things? I hope you don't download all the source code of all these libs and grep for the word you're looking for... :D

Please make me feel dumb if you want to reply, and I will learn one more interesting thing today :)

In managed code with an IDE, you just have to right-click on the method and select "Go to definition" and if the method is found in a binary reference, there are different behaviours depending on the IDE you use, if you use VS2005 or later, you get an Object Browser that shows you the API of the library, and with MonoDevelop it tries to use the debugging symbols for showing the source code or otherwise it shows a minibug.

SOLUTION of the QUIZ: I had to look for the library 'gobject-2.0', not libgobject-2.0. Of course, Mike Gorse was the unmanaged expert that made me feel dumb! :D

SOLUTION to avoid the QUIZ to other people in the future: bug 369927. Mmmm, it has been closed as WONTFIX, maybe the unmanaged side of things should not get easier :)

Another mini-quiz that I solved also recently comes from the managed world. Do you know how static constructors work? They get called automatically whenever the code flow comes in the type where they lay. Example:


public static class MainClass
{
  public static void Main(string[] args)
  {
    Console.WriteLine("begin");
    new StaticCtorTest(1);
    new StaticCtorTest(2);
    Console.WriteLine("end");
  }
}

public class StaticCtorTest
{
  public StaticCtorTest(int initValue)
  {
    Console.WriteLine("Normal ctor");
    this.initValue = initValue;
  }

  static StaticCtorTest()
  {
    Console.WriteLine("Static ctor");
  }

  private int initValue;
}


What's the output of this test? This:


begin
Static ctor
Normal ctor
Normal ctor
end


Now, what happens if we drop the custom constructor? We can still create objects from our class, but using the implicit empty constructor:


public static class MainClass
{
  public static void Main(string[] args)
  {
    Console.WriteLine("begin");
    new StaticCtorTest();
    new StaticCtorTest();
    Console.WriteLine("end");
  }
}

public class StaticCtorTest
{
  static StaticCtorTest()
  {
    Console.WriteLine("Static ctor");
  }

  private int initValue;
}


Output:


begin
Static ctor
end


This constructor can only be called when no other constructors have been defined. Example: the following code will give a compiler error:


public static class MainClass
{
  public static void Main(string[] args)
  {
    Console.WriteLine("begin");
    new StaticCtorTest(); //The type `StaticCtorTest' does not contain a constructor that takes `0' arguments(CS1729)
    Console.WriteLine("end");
  }
}

public class StaticCtorTest
{
  public StaticCtorTest(int initValue)
  {
    Console.WriteLine("Normal ctor");
    this.initValue = initValue;
  }

  static StaticCtorTest()
  {
    Console.WriteLine("Static ctor");
  }

  private int initValue;
}


Ok, but here comes the surprise. What happens if, instead of using a class, you use a struct?


public static class MainClass
{
  public static void Main(string[] args)
  {
    Console.WriteLine("begin");
    new StaticCtorTest();
    Console.WriteLine("end");
  }
}

public struct StaticCtorTest
{
  public StaticCtorTest(int initValue)
  {
    Console.WriteLine("Normal ctor");
    this.initValue = initValue;
  }

  static StaticCtorTest()
  {
    Console.WriteLine("Static ctor");
  }

  private int initValue;
}


What happens is that you don't receive any compiler error, and thus you may think that the static constructor is being called, however, the output:


begin
end


WTF! This stupid thing made mkestner and me feel like crazy, wondering if any JIT optimization would kill our call in the GLibSharp bindings.

Fortunately, with this little research and his help, all was solved and I can keep on concentrating on how to complete Atk# in order to get my toplevel-with-n-children sample to work, and finishing the documentation that is still in a draft stage.

a silhouette of a person's head and shoulders, used as a default avatar

Installing Edimax EW-7128G Wireless Lan PCI Adapter on OpenSUSE 10.3

As you saw in my previous post, I have this wireless card, so let see what I did to have the wireless connection working on my OpenSUSE box.

The card is coming with some drivers for linux, on the box is mentioned that it has support for Mac OS, Windows x64 Edition, Linux Debian, Fedora, Redhat and Suse.. I was not able to install their drivers on my computer, I have the feeling that something is wrong with their default drivers and I decided to use the drivers which you can download here.

"rt2x00 Project" is a development effort to provide free, stable and feature rich Linux drivers for wireless 802.11b/g/i cards based on the following Ralink chipsets: rt2400, rt2500, rt2570, rt61 and rt73.

So, the steps are here:

1. prepare the kernel first:

# cd /usr/src/linux # make mrproper # make cloneconfig # make modules_prepare

2. Unpack the archive which you just download it somewhere on your hdd:

# tar -zxvf rt61-cvs-daily.tar.gz

3. change the current directory:

# cd rt61-cvs-2008032308/Module

4. compile and install the module:

# make # make install

Now if everything is fine, you can see if you have the drivers installed:

# ifconfig -a # iwconfig
lo        no wireless extensions. eth0      no wireless extensions. vmnet1    no wireless extensions. vmnet8    no wireless extensions.

For the last two commands you have to look after wlan0 or ra0 device. If you still don't have them (like in my case) try:

# modprobe rt61

If you run again the command iwconfig you will see now the device:

# iwconfig  

lo        no wireless extensions. eth0      no wireless extensions. vmnet1    no wireless extensions. vmnet8    no wireless extensions.

wlan0 RT61 Wireless ESSID:"" Nickname:""  
Mode:Managed Frequency:2.412 GHz Bit Rate=54 Mb/s  
RTS thr:off Fragment thr:off  
Encryption key:off  
Link Quality=0/100 Signal level:-121 dBm Noise level:-143 dBm  
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0  
Tx excessive retries:0 Invalid misc:0 Missed beacon:0  
Now you are ready to configure your wi-fi card with yast, so type
**yast2** at the command prompt, and configure it.

At this point the card will work only (in my case it did) if I disable the SECURITY on my router and if I will set NO-Encryption for Autentification Mode in Yast. I don't like this, I want to use WPA, so here is a nice and small script which will do the work:

#!/bin/sh # # Script to configure Edimax EW-7128G Wireless Lan PCI Adapter # to work with WPA mode

iwconfig wlan0 mode managed  
iwpriv wlan0 set AuthMode=WPAPSK  
iwpriv wlan0 set EncrypType="TKIP"  
iwconfig wlan0 essid "YOUR\_ESSID" \# change here  
iwpriv wlan0 set WPAPSK="YOUR\_PASSPHRASE" \# change here  

Now everything is working, I hope that this small howto is useful also for you, so please let a comment if it is working or if you have some problems with it.

a silhouette of a person's head and shoulders, used as a default avatar

Set up a wireless network in the new house

As you read in my previous post , we arrived in UK already. I have internet connection at work, but I need also at home internet, because during the evening I am reading news, emails, messenger, .... I prefer now, to set up a wirelesss network for my home, because I don't like to have cables in the house.

My computers are here. For Amilo notebook I had already a PCMCIA card "Netgear WG511T" which is working fine on Windows XP, FreeBSD and Linux, Vaio notebook come with an integrated wifi card, I have installed on it Vista and I don't have problems with the wireless card, so what I needed it was a PCI/USB wireless card for the desktop computer which has to work with Linux, Windows and also *BSD operating system and also a wireless router.

Surfing on the internet, reading opinions and different forums, I decided to buy a Linksys WRT54G wireless broadband router, maybe in the future I will try to install  linux on it (openwrt or something similar), and as PCI card I took Edimax EW-7128G wireless adapter which it seems that is working fine with Linux, Windows and FreeBSD/OpenBSD.

The router was very easy to set up and is working fine. I had some problems in installing the PCI wireless card on my Opensuse 10.3 box, finally it is working, I will write here a short tutorial in the next post.

I am really happy with my new wireless network.

a silhouette of a person's head and shoulders, used as a default avatar

a silhouette of a person's head and shoulders, used as a default avatar

YaST2 network, driver options

I've added support for driver options for openSUSE-11.0.
This is feature I don't really use, but some of openSUSE or SLES users does. Maybe I'll need it when I will play more with bonding devices.




Hm, feature ...
In fact it brings back functionality that there was already there. But it was done in "hwcfg" files - deprecated configuration files for hardware devices. Now that configuration is stored in /etc/modprobe.d/network. But it's probably not final solution.

Why? because all that options are stored "on one place" but options packaged by driver rpms are stored in /etc/modprobe.d/$driver_name.

Maybe in future I'll change that place or enhance functionality to work on whole directory, but I need some feedback or opinions. Are there any?

a silhouette of a person's head and shoulders, used as a default avatar

YaST2 network, bridge devices

Hello,
this is my first (and very short) blog about YaST2 development.
I put some screenshots here: new features::bridge.

What is bridged network good for? Mostly for network used with virtualisation (Xen, VirtualBox, Vmware, etc.). For this purpose all virtualisation products has their own tools, configurations and scripts.
This (per-virtualisation-application) has some disadvantages:
- possible conflict between sysconfig
- not unified way how to configure
- network configuration can't be clone by AutoYaST
That's why it makes sense to be implemented in YaST

Briefed introduction : when you want for any of your hosted machine to be seen from network, create bridge attached with physical network interface and some tun device. TUN device will be attached into your virtual machine and it makes virtual hosted machine be directly connected to real LAN.

The plan is (together with bridge) to implement also support for tun/tap devices (this should be done in sysconfig first) and Xen networking to confgure all this staff in one place.

Do you like this feature? If you have any feedback, comment or enhancement request - please let me know.

a silhouette of a person's head and shoulders, used as a default avatar

a silhouette of a person's head and shoulders, used as a default avatar

Disconnect idle users on FreeBSD

If you are trying a solution to disconnect idle users automatically from your server,  take a look at /usr/ports/sysutils/idled. Maybe also is possible to activate this option directly in sshd but I don't find that option. Please let me know if it is possible.
But, idled works well, and can be used with all types of user login sessions.

the avatar of Stephan Kulow

Experiments with Rpm payload

KDE Project:

I appologize to everyone thinking WTF? at the following, but I have to blog
about it, otherwise I'll explode :)

This is the reference for our current payload:
-rw-r--r-- 1 coolo suse 36966400 13. Mär 09:42 coreutils-6.10.tar
8.61user 0.05system 0:08.66elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+11936outputs (0major+2007minor)pagefaults 0swaps
-rw-r--r-- 1 coolo suse 6110179 13. Mär 09:45 coreutils-6.10.tar.bz2.9

Then I did lzma -1 to lzma -9 and these are the numbers:

5.90user 0.04system 0:06.03elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+16456outputs (0major+734minor)pagefaults 0swaps
-rw-r--r-- 1 coolo suse 8423507 13. Mär 09:48 coreutils-6.10.tar.lzma.1

5.83user 0.04system 0:05.88elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+10720outputs (0major+3271minor)pagefaults 0swaps
-rw-r--r-- 1 coolo suse 5488129 13. Mär 09:48 coreutils-6.10.tar.lzma.2

27.11user 0.06system 0:27.23elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+9888outputs (0major+3118minor)pagefaults 0swaps
-rw-r--r-- 1 coolo suse 5061307 13. Mär 09:48 coreutils-6.10.tar.lzma.3

29.60user 0.09system 0:30.36elapsed 97%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+9168outputs (0major+4334minor)pagefaults 0swaps
-rw-r--r-- 1 coolo suse 4691437 13. Mär 09:49 coreutils-6.10.tar.lzma.4

42.07user 0.10system 0:42.27elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+8576outputs (0major+6768minor)pagefaults 0swaps
-rw-r--r-- 1 coolo suse 4385224 13. Mär 09:50 coreutils-6.10.tar.lzma.5

44.68user 0.22system 0:46.32elapsed 96%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+8256outputs (0major+11633minor)pagefaults 0swaps
-rw-r--r-- 1 coolo suse 4222761 13. Mär 09:50 coreutils-6.10.tar.lzma.6

47.24user 0.34system 0:49.82elapsed 95%CPU (0avgtext+0avgdata 0maxresident)k
8inputs+7776outputs (0major+21360minor)pagefaults 0swaps
-rw-r--r-- 1 coolo suse 3971013 13. Mär 09:51 coreutils-6.10.tar.lzma.7

63.44user 0.18system 1:04.61elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+7344outputs (0major+40818minor)pagefaults 0swaps
-rw-r--r-- 1 coolo suse 3753487 13. Mär 09:52 coreutils-6.10.tar.lzma.8

63.52user 0.32system 1:04.14elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+7328outputs (0major+76468minor)pagefaults 0swaps
-rw-r--r-- 1 coolo suse 3746901 13. Mär 09:53 coreutils-6.10.tar.lzma.9

As you can easily see, lzma -2 beats bzip2 -9 both at size and compression speed
(using slightly more memory). Above that it's no longer win-win as you win another
1MB if you go with -5 (as I read in a patch Mandriva is using) at the cost of
taking 5x the compression time bzip2 needs and twice as memory.

So it's important to remember why we're thinking about lzma to begin with:

uncompressing the bzip.9:
1.81user 0.00system 0:01.82elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+1068minor)pagefaults 0swaps

uncompressing the lzma.2:
0.80user 0.00system 0:00.83elapsed 97%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+824minor)pagefaults 0swaps

uncompression the lzma.5:
0.69user 0.01system 0:00.70elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+1080minor)pagefaults 0swaps

And decompressing is what our _users_ do. So what do rpm users want?
- Smaller downloads
- Faster installs of these downloads
- Reasonable memory usage
- (Not waiting one more day for a rebuild to be synced out)

So we're in a small dilemma, but we'll continue playing and something between 2
and 7 will be it.

BTW: remember that these are coreutils sources, the compression rates for binaries
won't be as impressive.