Juli 2011 Archive

Old Noodle Soup

| Keine Kommentare
I forgot to throw away the rest of my noodle soup a few days ago. The result was not as gross as I expected. It resulted in an interesting structure:

Finding Holes in Files - The FIBMAP ioctl

| Keine Kommentare
At least the ext[2-4] filesystems support files with holes. They can be created in several ways, one possibility is the seek-argument of the dd command:

$ dd if=/dev/urandom of=test bs=4096 count=10 seek=10
10+0 records in
10+0 records out
40960 bytes (41 kB) copied, 0.0126733 s, 3.2 MB/s
$ wc -c test
81920 test


So I was interested in whether it is possible to actally find these holes. ZFS and XFS have their own API for that.

For ext*, there is also a possibility to find holes. Basing on the FIBMAP Ioctl (and similar), you need to have the CAP_SYS_RAWIO capability (that is, usually you have to be root). If you only want to watch the holes in the files, you can use for example hdparm (as shown here):

$ sudo hdparm --fibmap test

test:
 filesystem blocksize 4096, begins at LBA 0; assuming 512 byte sectors.
 byte_offset  begin_LBA    end_LBA    sectors
       40960    8928120    8928199         80


Another possibility is to use the filefrag-utility, which is contained in the debian squeeze package e2fsprogs (as shown here):

$ sudo filefrag -v test
Filesystem type is: ef53
File size of test is 81920 (20 blocks, blocksize 4096)
 ext logical physical expected length flags
   0      10  1116015              10 eof
test: 2 extents found


Now if you really want to use your own program, here is a nice example code I found, on which I based my own code:


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <linux/fs.h>


int main (int argc, char* argv[]) {
  int fd, blocknum, blocksize;
  struct stat fileinfo;

  if (argc < 1) {
    fprintf(stderr, "Syntax Errof\n");
    exit(EXIT_FAILURE);
  }

  if ((fd = open(argv[1], O_RDONLY)) < 0) {
    int errnum = errno;
    fprintf(stderr, "Cannot open '%s': %s\n", argv[1], strerror(errnum));
    exit(EXIT_FAILURE);
  }

  if (ioctl(fd, FIGETBSZ, &blocksize) < 0 ) {
    int errnum = errno;
    fprintf(stderr, "Cannot get blocksize: %s\n", strerror(errnum));
    exit(EXIT_FAILURE);
  }

  if (fstat(fd, &fileinfo) < 0) {
    int errnum = errno;
    fprintf(stderr, "Stat failed: %s\n", strerror(errnum));
    exit(EXIT_FAILURE);
  }

  blocknum = (fileinfo.st_size + blocksize - 1) / blocksize;

  printf("Filename: %s\nBlocksize: %d\nBlocknum: %d\n",
         argv[1], blocksize, blocknum);
 
  int i;
  for (i = 0; i < blocknum; i++) {
    int block = i;
    if (ioctl(fd, FIBMAP, &block)) {
      printf("ioctl failed: %s\n", strerror(errno));
    }
    printf("%10d\t", block);
  }
  close(fd);
  printf("\n");
  exit(EXIT_SUCCESS);
}


The output:

$ sudo ./fibmap test
Filename: test
Blocksize: 4096
Blocknum: 20
         0
         0
         0
         0
         0
         0
         0
         0
         0
         0
   1116015
   1116016
   1116017
   1116018
   1116019
   1116020
   1116021
   1116022
   1116023
   1116024


And that is indeed a list of ten null-pointers and ten consecutive blocks.

No seats at the Munich Central Station

| Keine Kommentare
They apparently removed (!!!) some seats from the central raliway station. WTF? The central raliway station of the capital of Bavaria, the longest platforms I know in Germany, and not a single seat on most of them.

This is a new low mark. As usual, I am now sitting in an ICE train, which is of course delayed and overcrowded, and of course there is only slow internet access which will probably break during the next few stations (in some of these trains there is wireless, but this is way too expensive if you do not use it every day).

And now, I cannot even sit (or at least envy the sitting) anymore while waiting for it.

CDF ... what the world needs (?)

| Keine Kommentare
The Wolfram Blog announces some sort of new document format CDF, the "Computable Document Format". Quote:

"CDF binds together and refines lots of technologies and ideas from our last 20+ years into a single standard—knowledge apps, symbolic documents, automation layering, and democratized computation, to name a few."

Well, this reminds me of the current xkcd. The first time I read it I thought this would be something that is exportable to JavaScript. But actually, the only thing it seems to have to do with JS:

"JavaScript is required to use this form!"

You need JS to download the "free player", and they want your mail adress. At least there is a linux version - a shell script with a lot of binary data after its exit point. I do not want to run it on my computer, but probably the whole thing is not open source, otherwise they would have released the source.

Now that is what the world needed. After Java, Flash, Silverlight, Unity, JavaFX... Where others work on 3d Graphics being available through JavaScript, they create a new format.

Do not misunderstand me: I believe them that their format can show 3d animations and can interact with the user, and maybe it does some things better than everything before. And probably it integrates well into other stuff made by Wolfram Research. It is just that I think the last thing the world needs is another proprietary format with a closed source player. It will take hours of work for administrators to install this stuff properly. It will produce a lot of files that will probably not be readable anymore in 20 years since all the old players do not run anymore.

I would be rather surprised if CDF really spreads. The people using Mathematica usually use it for science rather than for creating multimedia bullshit. Especially, telling some persons to install a player - even though it is free - is hard, and there must be a great advantage for this, and I do not really see this advantage.

They should have better written an export to JS, and use Flash for the parts that do not yet work properly with plain JS, instead of creating a whole new standard. That would have been a "document format" almost everybody supports, and therefore, the inhibitions to use it would not be that strong.

Contented

| Keine Kommentare

... schaffen Ordnung in der Welt

| Keine Kommentare
Ich fühle mich irgendwie auf den Arm genommen.

Darum ein wie ich finde passendes YouTube-Video:

(Direktlink)
Er hat Millionen Euro GEZ-Gebühren gerettet. Anstatt, wie für GEZ-Gebühren üblich, dazu verwendet zu werden Dinge zu produzieren die niemand sehen will hat er die Gelder heimlich dem Staatshaushalt zugeschoben, damit davon Staatsschulden zurückgezahlt werden können, damit unsere Kinder einmal nicht so viele Schulden und Schuldzinsen zurückzahlen müssen. Ein gutes Ziel, auf die Idee kam er vermutlich durch seine Position als Manager des Kinderkanals, da er sich wirklich mit den Belangen der Kinder auseinandergesetzt hatte. Allerdings hatte er natürlich noch das Problem, wie er die geretteten Gelder wirklich in den Staatshaushalt einbringen kann, eine Spende wäre doch recht auffällig gewesen. Aber zum Glück gibt es ja eine anonymisierte Spendemöglichkeit an den Staatshaushalt, genannt Spielbank. Doch, wie für unser Land üblich, kann man natürlich nicht akzeptieren, daß jemand was sinnvolles macht, insbesondere wenn jemand dafür seine Gesundheit aufs Spiel setzt (durch die unzähligen Spielbankbesuche, die er machen mußte um das Geld dem Staate zuschieben zu können zo er sich nämlich eine schwere Glücksspielsucht zu). Darum wurde er zu fünf Jahren und drei Monaten Haft verurteilt.

Preimplantation genetic diagnosis

| Keine Kommentare

Source: krautchan.net

Green Tomatoes

| Keine Kommentare
It has been a while, but now I have green tomatoes:

Amazing.
Erst zwei Tage ist es her seit die Spur des gefährlichen EHEC-Erregers nach Ägypten führte, schon ist dessen Quelle lokalisiert - und stellt die Forscher vor Rätsel. Der Mineraldünger, den der ägyptische Sprossenzüchterbetrieb verwendete, stammt offenbar von einem dänischen Betrieb, der sich auf die Anreicherung von Pflanzennährstoffen aus Meerwasser spezialisiert hat.

In diesem Verfahren wird neben diversem Gestein und Kleintier das aus dem Meer gefischt wird auch Bernstein in eine Häckselanlage geführt. Im Rahmen einer norwegischen Studie aus der paläontologischen Grundlagenforschung fanden Forscher in von dort stammendem fossilem Bernstein Spuren von EHEC-Genen. Deren genauer Ursprung ist bisher ungeklärt, und wirft viele Fragen auf.

Unter Anderem ist der EHEC-Erreger nach bisherigen Erkenntnissen bei Weitem nicht so alt, man geht gemeinhin davon aus dass ein moderner Verdauungstrakt wie ihn Säuger haben eine Voraussetzung für die Verbreitung und Entwicklung von Escherichia Coli gewesen ist, und es sich beim agressiven EHEC-Erreger um eine Mutation, die Erdgeschichtlich erst der Neuzeit zuzuordnen ist, handelt.

Diese Theorie muss nun möglicherweise verworfen werden, Forscher hoffen erwartungsvoll auf eine Bernsteinquelle die fossile Verdauungsprodukte enthält, und weitere Aufschlüsse über die Entwicklung der Verdauung bringt. Gleichzeitig wurde das dänische Werk vorerst geschlossen.

Die Forschergruppe des königlich norwegischen paläontologischen Instituts, die diesen Fund gemacht hat, wurde nun von den dänischen Behörden beauftragt, weitere Abklärung zu schaffen, und kooperiert mit den dänischen Forschungseinrichtungen.

Bis es genauere Ergebnisse dazu gibt wird geraten, auf Gemüse, das mit aus Meerwasser gewonnenem Mineraldünger gezogen wurde, zu verzichten.