Tag Archives: gnu/linux

Mac and Debian … not a happy couple

Trying to insall Debian on Mac OS X. If you plan on doing so, familiarize yourself with following concepts: rEFIt, gptsync, MBR/GPT hybrid partition table. And .. prepare to reboot a few times. This is with Debian Lenny CD1 only; amazingly it has no gptsync in default install and its install is completely confused by Macs. Hopefully they’ve ironed it out in Squeeze a bit.

Zagreb's Public Transportation device details

Ako se pitate što vrte ZETovi tramvaji, to jest uređaji za poništavanje karata, čitajte dalje.
Rest of this post is in English.

Ticket checkout devices installed during 2009 in Zagreb’s trams and buses are already known to run X Window System. I have identified and photographed it during an obvious malfunction. Another one has happened today.

In a tram on line 4, I took the shots attached to this post. They identify the hardware as running on Atmel’s BIOS. CPU is also Atmel’s; they contain AT91SAM9263 CPU at 200 MHz. Devices contain 64MB of SDRAM, and for storage purposes, 256 MB of NAND flash. They seem run U-Boot 1.1.5 from May 2 2008. At least I think that’s a U; as you can see it was sliced off. Screen calibration fail, much?

Because it runs U-Boot, they also probably run Linux, on which they run X11, on which they run their custom GUI.

For those who don’t know (those outside Zagreb), these are new smartcard-reading devices used to track “subscribers” and to charge “non-subscribers”. You’re supposed to put your card on the device in order for it to scan your ZET-issued smartcard, and charge you/record your movement accordingly.

Some more technicalities:

  • AT91SAM9263 is an ARM9-based system-on-a-chip with 200 million instructions per second, 27 DMA controllers, AC97 audio controller, USB 1.1 host,  compact flash, and more. See link for more info. A powerful little piece of hardware indeed; this means there could be literally anything in there.
  • U-Boot is a part of Linux4SAM, which led me to conclude they run Linux.
  • While they might, I doubt they run a GNU system. While it’s probably Linux, as it’s an embedded system I doubt it’s GNU; or at least GNU comprises a much smaller part of it than on desktops. Which is why in text above I’m calling the system just Linux and not GNU/Linux 🙂
This is all so fascinating. I hope someone does an interview with the designers of the system, and I’d love even more if I could meet those engineers. I’d love to hear some more inside info and some official specs. It’s quite sad that I’m basing all my info on system crashes.

Enabling Ctrl+Alt+Backspace in X11

Your X.org misbehaves? You don’t like what’s done in Ubuntu? To forcibly restart Xorg, you have two options:

In /etc/init.d/xorg.conf:

Section “ServerFlags”
Option “DontZap” “false”
EndSection

or use RightAlt+PrintScreen+K.

P2PVPN 0.7

Anyone looking for a piece  of software similar to Hamachi, but open source free software – take a look at P2PVPN. It uses torrent trackers for finding nodes, it works on GNU/Linux and Windows and individual nodes do the forwarding. (This also means at least one node in network needs to be able to accept connections but that can probably be arranged.)

Now, since this is a blog with programmer’s thoughts, I’ve taken special interest in this program’s source code; especially in how it manages to use OpenVPN‘s TUN/TAP driver under Windows. You see, TUN/TAP devices under GNU/Linux reveal themselves to be just simple named file descriptors you can write into and read from. But how to do it under Windows?  This seemed like it might be another one of those things where you can venture around the net for days looking for an answer, but luckily, there was no need for that.

P2PVPN’s got two versions of its low level code for accessing TUN/TAP devices, one for GNU/Linux and one for Windows. They are written in C and are Java wrappers for accessing the devices. Windows version has 280 lines of code excluding header, and GNU/Linux version has 111 lines excluding header. They are a must-read tutorial for anyone wanting to write some code that has to do with virtual network devices and VPN. P2PVPN’s licensed under GPLv3, and the TUN/TAP Java wrapper code is licensed under LGPLv3.

Wolfgang Ginolas did some great work here. Anyone that wants to try something new aside from Hamachi, or wants to write their own VPN software, should take a look at P2PVPN.

Fixing "warning: missing sentinel in function call"

I got it for the folowing line:

execl("/bin/sh", "sh", "-c", sessioncommand.c_str(), 0);

Quite easy to fix:

execl("/bin/sh", "sh", "-c", sessioncommand.c_str(), (char*)0);

—————————————–

Alright. Since I’m getting “lots” of hits on this, let’s see if we can improve this post. (June 28th 2010, more examples added July 22nd 2010, style but not content updated April 19 2014)

Generally, you’re missing a sentinel if you don’t add a “NULL” in C/C++, or a “nil” in Objective-C. In above example in C, I presume the compiler did not notice the zero (a valid sentinel) and threw a warning. That’s what this post was mostly about.

However, it could also happen if you really did forget to add the sentinel. What is the purpose of this “sentinel”? When iterating through a varlist**, the function needs to know where to stop. In printf() and scanf(), the format string specifies this number of arguments. Functions could also accept the number of arguments as one of the arguments. Third option is this — specifying a sentinel, such as NULL or nil, as something that will stop further iteration.

Examples of sentinels in C:

execl("/bin/sh", "sh", "-c", sessioncommand.c_str(), NULL);

and in Objective-C:

NSArray *names = [NSArray arrayWithObjects: @"Ivan", @"Ana", @"Marko", @"Petar", nil];

** Iterating through a varlist – which is how you iterate through arguments in variadic functions, those with variable number of arguments

close() of listening socket from another thread

Just a warning.

Calling close() on listening socket in another thread will NOT prevent another connection from being made. Instead, you must call shutdown(). This should abort existing select() calls (probably accept() too, but I didn’t try).

Guess how I found out 🙂