martes, 22 de noviembre de 2011

How to connect your smartphone through your GNU/Linux box. Part I: With a spare wireless router

Hi!

So, you forgot to pay your phone bill? Or you are just in the middle of a financial crisis? Whatever the reason, you lost connection of the most important item of communication in your daily life: your smartphone.

But you have a computer that does connect to internet. Well, I got my BlackBerry to connect to internet (and regain simple communication to a very dear group of friends) by connecting through the computer.

You see, as I've always said, GNU/Linux is about fun and flexibility. This is no exception. I connect to my ISP through a USB dongle (GSM connection). This box has a wireless interface but, in this chapter, I will use a spare wireless router I have at home. I'll hack on to connect through the wireless interface directly on a following chapter (if the interface allows me to).

So, first, I set up my wireless router and my box to use static IPs (so that my computer and the router will be able to "see" each other). To make things simple, I used this set up:
My Box: 192.168.2.1/24
Router: 192.168.2.2/24
Router's GW: 192.168.2.1 (your box)
Router's DNS: Whatever my ISP's DNSs are (cat /etc/resolv.conf)

Now, in order for the traffic comming from the router to go through your box, you have to make sure two things are set up.

There not be any rule/policy in netfilter's FORWARD chain keeping the traffic from going through
# iptables -L FORWARD -nvChain FORWARD (policy ACCEPT 1756 packets, 917K bytes)
 pkts bytes target     prot opt in     out     source               destination

You have a DROP policy? Don't want to get rid of it? Add rules to allow traffic going from the router to internet to pass through, and also the traffic that comes back. That's a whole topic in and of itself so I won't go into it. I have an ACCEPT policy on FORWARD, so I have no problem with that.

The kernel be enabled to forward ipv4 traffic
# sysctl net.ipv4.ip_forwardnet.ipv4.ip_forward = 1

It says 0? You have to enable it:
# sysctl -w net.ipv4.ip_forward=1

That should be it.... or almost. The thing is that the kernel is now letting traffic comimg from the router to get to internet but it's not doing any network address translation on that traffic so it's coimg out not with your network interface's IP address but with the wireless router's (which is probably doing nat on the traffic from its clientes) and that won't hold water so next step is to masquerade all traffic that is going out to internet. Something like this should be enough:

# iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE

I'm using ppp0 for my example (as I said, USB dongle) but it has to be the interface you use to connect to internet. Now, your smartphone (if it's already using the wireless network from the router) should be able to get to internet.

I hope it does the trick for you.

martes, 8 de noviembre de 2011

raidpycovery supports raid4 and repetitions

Hi!

Just wanted to announce that I just tagged/pushed version 2.01 of raidpycovery which now supports raid4 and also repetitions (like the one an HP SmartArray P410i displayed).

Repetitions works this way.On a normal RAID5 (left async) you would see something like this:
A0 B0 C0 D0 X0
A1 B1 C1 X1 D0
A2 B2 X2 C2 D2
A3 X3 B3 C3 D3
X4 A4 B4 C4 D4
A5 B5 C5 D5 X5
.
.
.

On a raid with 2 "repetitions" you would see:
A0 B0 C0 D0 X0
A1 B1 C1 D1 X1
A2 B2 C2 X2 D2
A3 B3 C3 X3 D3
A4 B4 X4 C4 D4
A5 B5 X5 C5 D5
.
.
.

You get the idea, right? On the raid5 I broke last weekend the controller did 16 repetitions.

Repository for the project is here.

domingo, 6 de noviembre de 2011

Edmundo 750 GBs - HP 0 Gbs

Hi!

Just today I finished one almost perfect data recovery from another RAID5 that its controller spitted onto (another HP controller, yet again).This time around, it was a 6-disk RAID5 (some 130 GBs each).

I knew beforehand that my python library (which I had translated from java about one year ago) was too slow and this task was going to take days if I hadn't done something about it. So, first I took the task of translating it to C++, which I finished some days ago.

When faced with the disks, the HP controller reported that 1 of them was physically dead, one of them had been hotswapped and another was to fail soon (public administration, don't ask about the details... gruesome). Fact of the matter is that the controller didn't want to make it visible so the server would not start. HP support asked me to dip the array in holy whater and forget about it. But that was not to happen, was it?

The disks were mounted on a separate computer one by one (well, not one by one but on a separate computer), and images were made from each one of them (only one of the drives didn't allow itself to be copied). Tips: LiveUSB, ddrescue.

After getting my hands on the images, I started analyzing how it was built to figure out the order of the drives, the chunk size and the algorithm used. Normally for this job the first MBs from each image help to do it.... after taking a long cold look at the images, I had figured out the chunk size (64ks) by looking at some numbered markers present on the ext2 partition that was at the begining of the disks... however, as this was a linux server with no FAT of NTFS stuff on it, there was no data (specially text) to be able to figure out the order... and specially, not crammed at the begining of the disk (does NTFS still work like this? You gotta be kiding me).

After thinking about it (and working on it) for a while I ended up finding whole stripes that would be made out of text (except, most probably) for a single chunk for every stripe. Finding these stripes and their sequence took its time, but eventually I was able to break it. The only thing that bothered me was that for many stripes (one after the other) the checksum chunk was always on the same disk (which I didn't expect) and the sequence remained the same on those stripes. At first I thought that perhaps it had been built as a RAID4 instead of a RAID5, but after checking many stripes the whole thing made itself clear: It's a RAID5 in which row configurations repeat themselves a number of times (in this case, 16 times). All in all, left async 64Ks with 16 repetitions. This took me to make an adjustment to my C++ utility just for this task and on a single shot I was able to rebuild the RAID5 from its pieces. Rebuilding took some 14 hours (probably not because of the utility but because of the bottleneck of having all 5 images on a single drive).

After rebuilding, I was able to do fdisk -lu on the disk image, do the losetup trick, and mount the server's / partition and get data out of it. There were some IO errors (not that many, fortunately.... given that the controller had already reported more than one disk as broken, maybe some pieces of the images were broken or the controller had stopped using one of the drives as a whole some time before crashing). Some other people will take of getting the stuff working but my task is definitely over.

So, next time you have a RAID5 crash , always remember it can take some time/thought breaking it... but in the end, it can pay off.

I'm starting to feel like the Messi of data recovery. Anybody needs a data recovery hacker around there? I'm willing to travel anywhere!

PS And before you ask, it's 750 GBs (or close) for this array plus the one I had recovered in 2005.

jueves, 3 de noviembre de 2011

Remember the times when I used python for RAID5 Recovery? Not anymore

Hi!

Remember the times when I translated the raid5 recovery utility from java to python? Well, let me tell you something. It was horrendously SLOW. For example, I used to help a guy who had a problem with his array and the operation to rebuild the array took literally days (and the data wasn't recovered in the end, so...). While doing my tests, a (virtual) 300 MBs RAID5 with a missing disk took about 450 secs to be rebuilt on python (on my netbook, anyway).

Right now I'm facing the recovery from a RAID that has 6 disks 150 GBs each. That is going to take _a lot_ of time to recover. So, just in case we do have to go on with the operation, I decided I was goint to translate it to C++, which I started doing a little more than 24 hours ago (not fully employed on the task so don't complains about me being slow in the process).

So, I'm happy to announce that the translation has worked and after making some tests I can attest that it absolutely kicks ass (at least time-wise :-)). Remember the 300 MBs RAID5 I talked about a couple of paragraphs ago? It's rebuilt in roughly 8 seconds. 8!!!!

The way you call it is the same (same arguments) only that, instead of calling Raid5Recovery.py, you will just write Raid5Recovery (with the accompanying ./, you know the drill).

I don't intend to change its name at the time so it will remain Raidpycovery.

As usual, I have made some tests on it but they were not exhaustive so feel free to use it at your own risk.

The project is hosted on launchpad (no release) here:

https://code.launchpad.net/~eantoranz/+junk/raidpycovery

Last but by no means least, I dedicate this project to the memory of my wife, Lina Marcela "Nena" Salgado.

sábado, 24 de septiembre de 2011

Open Letter to Neelie Kroes

Hi, Ms. Kroes.

First, I'd like to say that I'm not an european citizen. I'm
venezuelan and I'm living in Colombia at the time. If that's all it
takes to get this email dropped from your inbox, so be it. If you (or
someone from your staff) is still reeading it, I thank you.

During the last few days it has hit the IT mainstream media that
Microsoft, as part of their "Windows 8 Logo" program, will request
computer manufacturers to support UEFI's "secure boot". Manufacturers
that don't support it, won't get the privilege of putting a "WIndows
8" logo stamp on their computers. It has also been published that
manufacturers are willing to implement this _without_ giving the users
the possibility to disable this option.

In order for "secure boot" to be used, it requires using certification
keys to allow any operating system to boot the computer and that
provides Microsoft with a double advantage:
- Users wouldn't be able to use an older version of Windows
- Users won't be able to use a "non certified" operating system, like
say, GNU/Linux.

Given their strong position on computer manufacturers, whatever
Microsoft comes up with, manufacturers will follow. Unfortunately,
that power, as we can see here, is being used to hinder Microsoft's
competition and force the user to use Microsoft's latest OS instead of
any other OS they so choose to use (even older versions of Microsoft
Windows).

Thank you very much.

Update: The mail has been forwarded to Mr Almunia, on the Competition front.  Email Address: CAB-ALMUNIA-COURRIER at ec.europa.eu

Update II: I got a response this morning (oct. 27th) from staff:


Dear Mr. Carmona,
Thank you very much for your messages of 24 and 26 September 2011 expressing concerns regarding the new Microsoft's Windows 8 security requirements. According to these requirements, the computer manufacturers ("OEMs") conforming to the Windows 8 logo program are obliged to use Unified Extensible Firmware Interface ("UEFI") secure boot. This might allegedly lead to anti-competitive effects in the market.
As you are probably aware, Windows 8 is currently under development and therefore not final. We will, however, monitor the further developments in order to ensure the full respect of European competition rules. Whether or not there is a violation of EU competition law, however, depends on a range of factual, legal and economic considerations. 
For more information about the competition-related activities of the European Commission we invite you to consult our website: http://europa.eu.int/comm/competition/index_en.html .
Feedback from interested citizens, such as yours, is a very valuable source of information for us which we take seriously, and for which we would like to thank you.
Yours sincerely,

Per Hellström   
Head of Unit   
European Commission   
DG Competition   
Markets and cases II: Information, Communication and Media  
Antitrust: IT, Internet and Consumer electronics


domingo, 28 de agosto de 2011

Will ARM get to sweep X86 (and take WIndows to hell along with it)?

Hi!

I've been very interested in ARM developments since a couple of years ago when it looked like ARM netbooks were just about to be released and kick x86 out of the market (at least on netbooks). A lot of things didn't happen since then, don't you agree? A lot of speculation about how Microsoft got to influence potential manufacturers has been thrown around... but anyway, fact of the matter is that they were never released.

During the last month a couple of things have happened that are making me think that ARM is going to become a major headache for the (already kind of broken) Wintel monopoly (duopoly? whatever!).

First, I helped solve a printing problem involving three cheap printers. First we tried to solve the problem connecting all 3 printers to a single computer (some PC) and almost got to get the whole thing working... the only problem was that only one of the printers would print reliably and the other 2 would refuse to make it all of the times. Workaround? Bought 3 dreamplug servers, connected a single printer to each one of the servers, ran a couple of commands* and, voilà!, problem solved.

Here's a picture of the whole set up (will upload a higher resolution pic when I get it):


On the left of the desk you can see all 3 printers and each printer's dreamplug master right on top of each one, see?

Now.... this was a rather simple fix, each server is kind of cheap (specially compared with a fully fledged computer) and, on top of that, these beauties will keep the electricity bill low (as they all put together eat a lot less than a computer). To me, this spells trouble ahead for Intel (and Windows, though they are at the top on servers will see a ferocious battle with GNU/Linux on the not-so-short term) as it means that people will have yet another simple comoditized option different from a PC to solve problems.

And if that was not enough, then I see this today:


Full article where I got it from here.

Now, this is not a PC. This is an ARM-based platform that is expected to start selling by the end of the year... and at US$ 25 a pop.

About 2 years ago I thought ARM was about to kick butt (back then)... boy, was I wrong.... but given these two events I told you about, I don't think it's too crazy to believe that this is going to make a major dent on Intel and Microsoft (given that Microsoft is years from releasing/stabilizing their ARM port of Windows... and I'm not talking about WP7 or Windows CE, of course) in the not-so-distant future. Only time will tell.

PS Oh, and did I say that apparently Canonical is throwing a lot of its weight on ARM too? Interesting times ahead of us.

* As a matter of fact, getting the printer to work took a little work. The splix drivers (they are cheap samsung printers) were not available for the model of the printers we were using (on updated debian) but we knew ubuntu did have it available so, after a little trying and trying we ended up compiling the ubuntu splix driver's source on the dreamplugs to get them running (the source of the drivers I got from a normal netbook running kubuntu natty and placed them on the dreamplug for compilation).  A little scripting here and there and they were finally printing the way we wanted them to.

viernes, 26 de agosto de 2011

Sales of GNU/Linux servers explode on Q2 2011 with an increase of 47%

Hi!

According to numbers released by IDC, income from server sales for Q2 2011 saw an increase of 47.5% compared to the same quarter 2010 to reach US$ 2.7 billon. This represented 20.5% of all income for the quarter. In comparison, income for Windows servers increased a healthy 12.4% to reach US$ 5.9 billion with represents 45.5% of all income for the quarter. These numbers in a very healthy quarter for all server segments.

If you get the calculater out of your pockets you will notice that GNU/Linux income increased by some US$ 870 million while Windows servers' incresed by some US$ 650 million.

In case you want to see the whole report, check here.

martes, 23 de agosto de 2011

How to add a custom session type to kdm

Hi!

I was trying to start my "failsafe" session from kdm. Back in the old days, what I would get with that would be a plain session with a terminal on top and nothing else. Unfortunately, when I tried it I would always get back to kdm. Not what I expected.

I figured out that there must be a simple way to create my own custom session... say, where I would only call rxvt for example... and there certainly is a simple way to do it. All you have to do is create a simple file like this under /usr/share/xsessions. Mine is called rxvt.desktop with this content:

[Desktop Entry]
Encoding=UTF-8
Type=XSession
Exec=/usr/bin/rxvt
TryExec=/usr/bin/rxvt
Name=Just RXVT Session
Name[es]=Solo RXVT

After the file is set up, just restart kdm and your new session type will be on the menu.



Given that the location looks pretty neutral and not tied to a desktop environment, I would expect the same trick to work for gdm and xdm as well.

Also, I would recommend people to take a close look at /etc/kde4/kdm/kdmrc as there's a lot of interesting stuff in that file.

Help us defend colombian's digital rights from entertainment lobbies

Hi!

Colombia has become one of the places where the entertainment industry is trying to overtake things as basic as the right to access internet from people in order to protect their money (as if the law is going to keep big-buck copyright infringers from doing it). You can help us try to stop them from pulling the strings to get some crazy laws (two-strikes??? Not even three? That's because baseball is not a popular sport here, otherwise...) passed here in Colombia by signing this petition online (petition in english is here).

Thanks in advance for your help and support.

miércoles, 3 de agosto de 2011

My wife has died

I'm sorry to announce that Lina Marcela "La Nena" Salgado, my wife, died on July 8th. She fought cancer corageously but ultimately the disease defeated her.


Nena: siempre tendrás un lugar muy especial en mi corazón y siempre te recordaré. Te amo!

lunes, 1 de agosto de 2011

Kubuntu 11.04: After updating to kde 4.7, things are back to normal

Hi!

You might remember I wrote quite a rant a few months back about the sorry state of kubuntu 11.04 when it was released. There were so many complains I had.

Well, after I updated to kde 4.7 yesterday things have mostly fallen into place. No more kded4 going crazy when I mess around with my usb dongle, my desktop starts with 3d effects enabled and everything looks fine and dandy. If I notice other things, I'll let you know.

There's something I haven't tested yet but it's not related to kde or kubuntu per se. The driver of my wireless card crashes my netbook (apparently, it's a driver bug... I haven't used the wireless card in a couple of months so I don't know if it's solved... launchpad bug report is here).

Update: Thanks to Sam for advicing me to remove the comment about my wife. I created another blog entry for her.

domingo, 22 de mayo de 2011

How to perform automatic actions after a connection is established with wvdial/ppp

Hi!

I'm on kubuntu Natty and I'm pretty glad with the distro overall. However, there are a couple  of bugs that bug me more often than I'd like them to. One of them is that, for whatever reason, when I establish an internet connection with wvdial/ppp, squid doesn't go through it. I have to restart he service once the connection is set up so that traffic starts pouring from squid. What I realized was that it is possible to do this action automatically.

There is one directory where you can put scripts to be run when a new connection is established and when a connection is dropped. I wanted to do something when the connection was established, so had to upt the script in /etc/ppp/ip-up.d:

$ cat /etc/ppp/ip-up.d/9999squid
#!/bin/bash

/etc/init.d/squid3 restart

Pretty straightforward, right? Make sure the script has the executable flag set up and you are done.

Additionally, the script get the following information as parameters (in the order they are received):
Network Interface
TTY
Speed
Local IP address
Peer IP address
Additiona Parameter (as received by pppd).

There are some environment variables that I think are available for the script, but I haven't tested them: PPP_IFACE, PPP_TTY, PPP_SPEED, PPP_LOCAL, PPP_REMOTE y PPP_IPPARAM.

Note: Given that the hack is implemented on ppp, this should probably work with network connections set up on NetworkManager that use ppp (like broadband).

lunes, 9 de mayo de 2011

How to install django (or run it without installing it at all) without administrative permissions

Hi!

I'm giving my first baby steps at learning Django. Right up front I saw the installation procedure and it talked about requiring an administrator to do the installation or copy the django directory inside the Djando tar ball to site-packages.... I personally don't like doing these kind of things so I sat down for a while to see how it could be done without requiring running setup.py at all. It's like this.

In my environment, I unpackaged the Django tarball that created this directory:

$ ls -l /home/antoranz/Downloads/Django/Django-1.3
total 72
-rw-r--r--  1 antoranz antoranz 19166 2011-03-21 20:38 AUTHORS
drwxr-xr-x 17 antoranz antoranz  4096 2011-05-09 09:16 django
drwxr-xr-x 14 antoranz antoranz  4096 2011-03-23 00:08 docs
drwxr-xr-x  2 antoranz antoranz  4096 2011-03-23 00:08 extras
-rw-r--r--  1 antoranz antoranz   592 2009-10-30 03:24 INSTALL
-rw-r--r--  1 antoranz antoranz  1558 2008-08-09 09:40 LICENSE
-rw-r--r--  1 antoranz antoranz  1494 2011-03-16 14:02 MANIFEST.in
-rw-r--r--  1 antoranz antoranz  1228 2011-03-23 00:08 PKG-INFO
-rw-r--r--  1 antoranz antoranz  1786 2011-01-28 17:07 README
drwxr-xr-x  2 antoranz antoranz  4096 2011-03-23 00:08 scripts
-rw-r--r--  1 antoranz antoranz   108 2010-08-05 08:00 setup.cfg
-rw-r--r--  1 antoranz antoranz  4325 2011-03-23 00:06 setup.py
drwxr-xr-x  5 antoranz antoranz  4096 2011-03-23 00:08 tests

This is the place you should run setup.py from to do django's installation, right?.... you can just skip it completely.

Now, without doing anything but just extracting the tarball, you won't be able to do much with it. From a small project I'm working on (following the tutorial):

$ python manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 2, in
    from django.core.management import execute_manager
ImportError: No module named django.core.management

Too bad. But if you just export the PYTHONPATH to include the django directory you are done:

$ export PYTHONPATH=/home/antoranz/Downloads/Django/Django-1.3/
$ python manage.py runserver

Validating models...

0 errors found
Django version 1.3, using settings 'django1.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

And that's it. If you need to call django's binaries (django-admin.py and so on), use the full path to reach them or add the required path to PATH environment variable so that it's available.

I staill haven't tried to run django from apache without doing the instalation..... but will be publishing it (if possible) once I reach that part of the tutorial.

miércoles, 4 de mayo de 2011

Will kubuntu natty stabilize? Ever?

Hi!

First off, let me tell you something before I start my rant on kubuntu: I've been a kubuntu user for 6 years now... and I don't intend to switch to gnome (ubuntu) or xfce (xubuntu) or any other of the other variants anytime soon. I like KDE and I'm willing to put up with the nag that I have to go through in order to continue using it

Back when I installed natty 'bout a couple of weeks ago I had a few complaints but we were in beta, right?... but it's been a few days since release time and things feel worse and worse. At first I didn't use gl-based screensavers because they made the graphics go completely crazy (it's a samsung netbook with intel chipset) so I used a simple screensaver instead (though I had desktops effects turned on and they tend to work pretty well)... then updates started to come in. gl screensavers started to be stable some days ago and I could start/stop it at will... only sometimes it crashed KWin.... but yesterday there was another update and things have gone to hell. Every single time I start the screensaver it crashes KWin... now gkrellm doesn't remember it's on desktop 6 when KDE starts.... When KDE starts it always turns off my desktop effects (which I think didn't happen when I updated to natty), hell... this is just too much for my taste. Are we experimenting here? I haven't tested if kded4 goes crazy when I come back from sleeping/hibernating yet... but something tells me it's not going to be pretty.

Guys, could you please stabilize this whole thing and not make us kde users feel like third class citizens in the ubuntu world and keep us in second class at least?

martes, 19 de abril de 2011

Updated minibd driver for linux (sbull.c)

Hi!

I'm embarking myself in a journey to write a block driver for linux (raid5 recovery stuff, anyone? Doesn't ring a bell? Look around this blog).

My firsts steps have involved trying to figure out how linux's block layer api works... so I looked for the simplest example I could find.... and it was in the sbull.c of the minibd drive. It's a dull ram-based block driver where the basics for the API are set in place for people to see how a driver is created.

I started working with it but it was written for older versions of the kernel and the block layer API has received an overhaul that made the sbull.c driver as I got it unusable so I sat down to modify the driver to make it work while trying to figure out how things work... I hopefully did both... but even if I didn't get to understand how the API works, I did make the driver work. How well am I getting the API? Guess will have to wait for my real driver to come out to know for sure.

Here it goes. First, the Makefile so you don't have to reinvent the wheel:
obj-m := sbull.o

PWD := $(shell pwd)
KDIR := /lib/modules/$(shell uname -r)/build

all:
        make -C $(KDIR) M=$(PWD) modules
clean:
        make -C $(KDIR) M=$(PWD) clean


That's it... and now the driver (sbull.c):

/*
* Mini-block driver.
*
* this code is based on one example from LWN.NET: http://lwn.net/Articles/31513/
*
* Copyright 2003 Eklektix, Inc.  Redistributable under the terms
* of the GNU GPL.
*
* Update to new block layer api by Edmundo Carmona
* works on linux 2.6.38.3 tested on UML.
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include


MODULE_LICENSE("Dual BSD/GPL");

/*
* some values that could have been configurable... but aren't (at least,
* not in the revision of the driver).
*/
#define KERNEL_SECTOR_SIZE 512
#define MAJOR_NUM 240 /* a free major number, according to devices.txt */
#define MINIBD_MINORS 16 /* number of possible partitions */
#define N_SECTORS 1024 /* number of sectors in our block device */
#define MINIBLOCK_SECTOR_SIZE 512 /* sector size */

/*
* request queue of our mini-block device.
*/
static struct request_queue *miniblock_queue;

/*
* Internal representation of our device.
*/
static struct miniblock_device {
        unsigned long size;
        spinlock_t lock;
        u8 *data;
        struct gendisk *gd;
};

static struct miniblock_device *Miniblock = NULL;

/*
* Real handling in our device of IO Requests.
*/
static void miniblock_transfer(struct miniblock_device *dev, struct request * req)
{
    unsigned long offset = blk_rq_pos(req) * MINIBLOCK_SECTOR_SIZE;
    unsigned long nbytes = blk_rq_cur_bytes(req);

    if ((offset + nbytes) > dev->size) {
        printk (KERN_NOTICE "minibd: working past the end of the block device (%ld %ld)\n", offset, nbytes);
        return;
    }
   
    if (rq_data_dir(req) == WRITE) {
        memcpy(dev->data + offset, req->buffer, nbytes);
    } else {
        memcpy(req->buffer, dev->data + offset, nbytes);
    }
}

/*
* driver handler of requests.
*/
static void miniblock_request(struct request_queue *q)
{
    struct request *req;

    req = blk_fetch_request(q);
    while (req != NULL) {
   
        if (req->cmd_type != REQ_TYPE_FS) {
            printk (KERN_NOTICE "Skip non-CMD request\n");
            blk_end_request_all(req, -EIO);
            continue;
        }
       
        miniblock_transfer(Miniblock, req);
   
    // if there are no more requests, _do not call_ blk_fetch_request
        if (!blk_end_request_cur(req, 0)) {
        req = blk_fetch_request(q);
    }
    }
}

/*
* custom Ioctls for our device.
*/
int miniblock_ioctl (struct inode *inode, struct file *filp,
                unsigned int cmd, unsigned long arg)
{
        long size;
        struct hd_geometry geo;

        switch(cmd) {
            case HDIO_GETGEO:
                size = Miniblock->size*(MINIBLOCK_SECTOR_SIZE/KERNEL_SECTOR_SIZE);
                geo.cylinders = (size & ~0x3f) >> 6;
                geo.heads = 4;
                geo.sectors = 16;
                geo.start = 4;
                if (copy_to_user((void *) arg, &geo, sizeof(geo)))
                        return -EFAULT;
                return 0;
    }

    return -ENOTTY;
}

/*
* operations associated for our device.
*/
static struct block_device_operations miniblock_ops = {
    .owner          = THIS_MODULE,
    .ioctl          = miniblock_ioctl
};

/*
* Module init.
*/
static int __init miniblock_init(void)
{
        static int ret;

        ret = register_blkdev(MAJOR_NUM, "minibd");
        if (ret < 0) {
                printk(KERN_WARNING "minibd: error assigning major number\n");
                return -EBUSY;
        }

        printk(KERN_DEBUG "minibd: Successfully registeres driver\n");

        Miniblock = kmalloc(sizeof(struct miniblock_device), GFP_KERNEL);
        if (Miniblock == NULL) {
                printk(KERN_WARNING "minidb: error assigning memory with kmalloc\n");
                goto out_unregister;
        }

        /*
        * Initializing our device.
        */
        memset(Miniblock, 0, sizeof(struct miniblock_device));
        Miniblock->size = N_SECTORS*MINIBLOCK_SECTOR_SIZE;
        Miniblock->data = vmalloc(Miniblock->size);
        if (Miniblock->data == NULL) {
                printk(KERN_WARNING "minidb: error assigning memory with vmalloc\n");
                kfree(Miniblock);
                goto out_unregister;
        }
        spin_lock_init(&Miniblock->lock);

        /*
        * Create our request queue (one block per device).
        */
        miniblock_queue = blk_init_queue(miniblock_request, &Miniblock->lock);
        if (miniblock_queue == NULL) {
                printk(KERN_WARNING "minibd: error on blk_init_queue\n");
                goto out_free;
        }

        blk_queue_logical_block_size(miniblock_queue, MINIBLOCK_SECTOR_SIZE);

        /*
        * Fill out our gendisk structure
        */
        Miniblock->gd = alloc_disk(MINIBD_MINORS);
        if (!Miniblock->gd) {
                printk(KERN_WARNING "minibd: error on alloc_disk\n");
                goto out_free;
        }

        Miniblock->gd->major = MAJOR_NUM;
        Miniblock->gd->first_minor = 0;
        Miniblock->gd->fops = &miniblock_ops;
        Miniblock->gd->private_data = Miniblock;
        snprintf(Miniblock->gd->disk_name, 10, "%s", "minibd0");
        set_capacity(Miniblock->gd, N_SECTORS*(MINIBLOCK_SECTOR_SIZE/KERNEL_SECTOR_SIZE));
        Miniblock->gd->queue = miniblock_queue;

        add_disk(Miniblock->gd);

        return 0;

out_free:
        vfree(Miniblock->data);
        kfree(Miniblock);
out_unregister:
        unregister_blkdev(MAJOR_NUM, "minibd");

        return -ENOMEM;
}

/*
* module removal
*/
static void __exit miniblock_exit(void)
{
        del_gendisk(Miniblock->gd);
        put_disk(Miniblock->gd);

        unregister_blkdev(MAJOR_NUM, "minibd");
        blk_cleanup_queue(miniblock_queue);

        vfree(Miniblock->data);
        kfree(Miniblock);

        printk(KERN_DEBUG "minibd: driver removed successfully\n");
}

module_init(miniblock_init);
module_exit(miniblock_exit);

lunes, 18 de abril de 2011

My journey updating to natty

Updating to a new version of ubuntu always has its glitches.... I hate doing clean installs (this is not Windows after all, right? So we should be able to do updates while working on the box) so I always do dist-upgrades in order to move to a new release of ubuntu (and don't try to change my mind... I'm stubborn and won't do it).

In my case, I wanted to update because I was having a small glitch with my intel graphics related to refreshing of the screen on my Samsung N150P plus netbook. Sometimes I had to switch to a different virtual desktop and come back in order to force the refresh of the whole screen to see things right... and I was tired of it.

I'm using kubuntu, anyway... so here's the journey so far.

First, going to /etc/apt/ and edit sources.list in order to change all "maverick"s in the file for "natty" (as a matter of fact, this is not what I do but the results are exactly that).

Then, performing the actual upgrade (you are on your own if you choose to do it this way, so no whining is accepted if something breaks):

sudo apt-get update
sudo apt-get dist-upgrade -y --force-yes -f

Give it time to download the stuff it has to download (about 800+ MBs for me), then answer a few question for a few packages, then the upgrade is finished (by the way... I normally had to run the dist-upgade a couple of times in order to get all packages installed... there was always a glitch... but not this time... it was flawless).

And here is where things get tricky. I reboot my computer and it fails to boot with the natty kernel with a kernel panic. Damn... it's never going to give itself away easily, is it? Aparently it doesn't understand where the root partition is. So I start booting with the maverick kernel that's still installed. Fortunately it does boot and I'm able to start kde normally..... except that graphics are a MESS (in order to keep the article PG-13). I had to disable desktop effects in order to have something usable. Ugh! And I thought natty would get rid of the refresh problem.

So I file a bug to complain about it (come on, guys! Natty is almost out there and the graphics on my netbook are awful!)... and when I'm about to finish the submission process, it hits me like a truck: old kernel. :-S I better start the new kernel to see if the graphics are better there. I file the bug anywhere with a comment at the end.

And then a new chapter of education begings. After a few attempts of trying to solve the problem by hand, I end up running update-grub to see what happens... and then I see that there's an error when trying to generate a new grub.cfg file:

$ sudo update-grub
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.38-8-generic
Found initrd image: /boot/initrd.img-2.6.38-8-generic
Found linux image: /boot/vmlinuz-2.6.35-28-generic
Found initrd image: /boot/initrd.img-2.6.35-28-generic
Found memtest86+ image: /boot/memtest86+.bin
error: syntax error.
error: Incorrect command.
error: syntax error.
error: line no: 143
Syntax errors are detected in generated GRUB config file.
Ensure that there are no errors in /etc/default/grub
and /etc/grub.d/* files or please file a bug report with
/boot/grub/grub.cfg.new file attached.
done

What do we have in the new broken grub.cfg file (grub.cfg.new) around line 143?

submenu "Xen 3.3" {
}

Well, well.... who knows why this is... but this xen stuff is going out. So I chmod -x /etc/grub.d/20_linux_xen and try again:

$ sudo update-grub
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.38-8-generic
Found initrd image: /boot/initrd.img-2.6.38-8-generic
Found linux image: /boot/vmlinuz-2.6.35-28-generic
Found initrd image: /boot/initrd.img-2.6.35-28-generic
Found memtest86+ image: /boot/memtest86+.bin
done

Much better now.... Now I'm able to reboot with the natty kernel and we are fine. And let me tell you that graphics are much better now... I have noticed a couple of things so far (I have to restart squid3 after I reboot in order to make it work, when the screensaver starts, sometimes it kills the whole kde session) but I'll look around to see if updates arrive that solve this problems or if there are easy fixes for them (besides not using them, of course).

jueves, 14 de abril de 2011

Internet connection through (GSM) USB Modem with wvdial

Hi!

Just tonight I'm having problems to start my internet connection with the NetworkManager on kubuntu maverick. The connection has been working like a charm these days so I'd think it's some kind of hiccups.

I had taken the time to install wvdial on my box hoping I wasn't going to need it... normally console based applications are much more verbose on the kind of problems they are facing to do things so they are a very good fallback method when you have problems and so given the current situation, I'll give wvdial a shot.

So, here's the recipe for it. First, set up a simple text file with the configuration you will be using.. it depends on the carrier you are using. I have COMCEL (in colombia) and so this is the content of the file:

[Dialer Defaults]
        Modem = /dev/ttyUSB0
        Phone = *99#
        Username = COMCELWEB
        Password = COMCELWEB

Phone, username and password depend on your carrier but it's fairly simple, right? Say the file is called comcel.txt, then call wvdial supplying this file name as the config file:

$ wvdial -C comcel.txt
A while later, you will be connected.... this is the output for me:

--> WvDial: Internet dialer version 1.60
--> Cannot get information for serial port.
--> Initializing modem.
--> Sending: ATZ
OK
--> Modem initialized.
--> Sending: ATDT*99#
--> Waiting for carrier.
ATDT*99#
CONNECT
--> Carrier detected.  Waiting for prompt.
--> Don't know what to do!  Starting pppd and hoping for the best.
--> Starting pppd at Thu Apr 14 21:46:29 2011
--> Pid of pppd: 2594
--> Using interface ppp0
--> local  IP address x.x.x.x
--> remote IP address y.y.y.y
--> primary   DNS address z.z.z.z
--> secondary DNS address w.w.w.w

And that's how I made this post. Perhaps I could set up a little DB with the configuration in different carriers. Do you use wvdial to set up internet connection through a usb modem (through GSM)? Want to give it up? I'll update this post.

sábado, 26 de marzo de 2011

Is Microsoft trying to equate selling computers without Windows to software piracy as a new world policy?

Hi!

Very recently (as recently as 23rd of March) there was a small event in Mexico. An independent computer builder and a Microsoff legal representative had a meeting at the Legal Direction of Mexico's National Institute of Author's Rights. Apparently Microsoft wanted to make a statement specifying that they could take any legal action Microsoft considered pertinent given the builder's lack of a Microsoft certificate of authenticity or original license included along with a computer built/sold by the independent builder. The builder states that given that they sell their computers with Free Software instead of Windows, the software has licenses and that Microsoft doesn't have anything to complain about given that they don't own copyrights for said software.

If it had been an isolated event, I'd have been tepted to consider this as just a case of a legal/marketing staff messing up but given Microsoft's attempts to equate selling computers without operating system to piracy in other parts of the world, I'm starting to wonder if this is a deliverate attempt to try to equate both in the public mind to spread a little FUD around Free Software?

I'll try to get in touch with the independent builder to see what they have to say. Mary-Jo Foley, is it possible that you take care of Microsoft to see what they have to say about it?

sábado, 12 de marzo de 2011

My (first) 10 years of linux usage

Hi!

Just about these days it's my 10th anniversary as a GNU/Linux user and it all started, irony of ironies, as a consequence of BSA's activities (or so the gossip said at the time). I was doing my internship at a small Java development company in Mérida, Venezuela, a rather small city but with a promising future (at the time) in the technology field. Those days BSA was pretty active arriving at businesses and asking for licenses of which, in what is pretty normal in Latinamerica, businesses didn't have any. Material raided plus fines, etc etc. You know the story.

Given that this small office had licensing problems of their own, it was decided that some of the computers at the office had to be switched to GNU/Linux.... so a few days later I arrived at the office and my computer had been switched to Mandrake. And let me tell you something: it was hard! Fortunately I was working with Francisco Andrades, who we used to call JGuru and not only was he good at java but on GNU/Linux as well. So I bothered him as much as I could to try to learn what I could. A few months went by and I headed back to my beloved Maracaibo to finish my engineering degree stuff.

I didn't install GNU/Linux on my computer for a few months... but I certainly had the will to do it. So when I wasn't doing anything important on my personal computer I installed Mandrake on it (about 6 months later) to try to get used to it. First months I had to force myself into using it... really. When there was something I couldn't do on GNU/Linux, I went to Windows and when I finished it, I headed back to Mandrake. In the beginning, I switched often but as months went by, it was less frequent... eventually I just didn't do it anymore.

From my first experience on GNU/Linux in Mérida, I remember very clearly the sensation of not being under control of the computer (unlike another popular OS for end users were one is at the mercy of it). I felt the power was there, at my fingertips and I just didn't know how to take advantage of it... but exploring the power would take time... and eventually I did learn how to use it.

In these ten years I have learned many many things, hacked a broken RAID to get back from it plus a lot more.

Bottomline: BSA, I want to thank you for putting me on this track... I'm sure that's not the desired outcome you have in mind when you go after license violators everywhere. I just hope more people follow suit.

viernes, 18 de febrero de 2011

International Free Software Community has been proposed for Príncipe de Asturias Prize

Hi!

I just learned that CENATIC has proposed the International Free Software Community as a whole as candidates for the Príncipe de Asturias Prize.

There's a web page where people can support this proposal. In it, it can be read (my personal translation) that:

"The International Free Software Community is the group of people and organizations from around the world that contribute to free software through a collaborative and open model based on freedom, sharing of knowledge, collaboration, meritocracy and respect for authors' rights with actions like development, disclosure, promotion, documentation, testing, organization, support and marketing of free software. Free Software has allowed generalization of knowledge and access to technology worldwide getting rid of economical, social, cultural, and language barriers".

It'd be nice if you provided your support for this proposal. On the left side of the page, there's a blue square bellow a text that says "Apoya la candidatura". The boxes are:

- Name
- Lastname
- ID Card (???)
- Entity (organization, I suppose)
- Country
- email (required)
- Brief comment
- Then a checkbox specifying that you have read the legal warning.
- Submission button.

Hope you find it worthy of your support. Remember, it's here.

lunes, 24 de enero de 2011

It took a little more than a year.... but Novell crumbled nevertheless

Do you remember when you opened your browser to get the latest news on Nov 3rd 2006? I do. I just couldn't believed my eyes when I learned that Novell had signed this deal with Microsoft..... and if that's not enough, how about bad mouth developers of FLOSS everywhere (the same guys who largely develop the product Novell was trying to get money from) saying that if you (we... I still do a little FLOSS development as personal side projects) didn't want to get into trouble you better do your work for free? Ain't that lovely? As a summary, it was a very deceptive turn of events.

I remember back then that someone from Red Hat made a comment somewhere (it's not a press release, I think.... I checked on their site for the press releases around the time) that they felt comfortable with the move. That within a year Novell would have been zapped into oblivion as each and everyone of the previous partners Microsoft had gone to bed with had.

I found this article (from Dan Lyon's) while trying to find the quote I'm telling you about and it's basically the same thing. Well... it took a little more that one year but Novell did crumble after all.

I wonder if there are other companies out there that are still willing to change their luck with a Microsoft partnership.

PS In the Dan Lyon's article, there's a note for Red Hat: When companies start talking about Microsoft "validating" their market, they're usually about to be validated out of existence. I say, it sounds like it's going to take a little more than RH talking about Microsoft validating their market in order to throw the company down.

martes, 4 de enero de 2011

Stop complaining about Unity and suck it up!

It's been a couple of months since Mark Shuttleworth dropped the bomb that Canonical intends to use Unity instead of the GNOME shell as the default shell in Ubuntu.... and I'm still reading about how the GNOME community could be torn apart by this decision.

Have these same people sat down to think how the people involved with KDE feel about Canonical's push for GNOME instead of KDE in Ubuntu? It's no secret that Kubuntu is not the best KDE-based distribution out there (I'll give you up that I'm a Kubuntu user myself, I use the PPA for KDE for Kubuntu and I don't use GNOME that much). Then why so much hair pulling because of Canonical's push for Unity instead of the GNOME shell? These people might just as well suck it up, get off the ground, remove the dust from their shoulders and continue working on their beloved environment.... you know, the way the developers of KDE do.