Thursday, December 26, 2013

This is England

This 2006 British film is set in the England of the early 1980's. It shows the skinhead subculture through a group of bored youths in a nondescript English town. One of the members is of Caribbean descent and they all seem to get along fine, with the characteristic dress code, pins etc. Apart from their looks, what distinguishes them from the rest of society may be the language where 'f***' and 'f***ing' appear obligatory in every sentence. At least once, but possibly more often.

Problems appear when the group is invited to join some far-right National Front sympathizers, thus illustrating how part of the skinhead movement got contaminated by the extreme right. Some of the original group decide to go with the psychopath that takes them to a pathetic National Front meeting. After that, things become more violent and the film does not have a happy ending.

The sound track is very good.

Overall, the film provides a fascinating glimpse of the skinhead subculture.

☆☆☆☆

Tuesday, December 24, 2013

Birth date: getting the creation time of an ext4 file

The ext4 file system type stores the actual birth date/time of a file, unlike most other Linux file system types. Normally, one would expect that, using the stat system call, the corresponding stat command would be able to show this birth date.

Unfortunately, this is not the case, as illustrated next (see an earlier post for the code of devof). We use blkid to obtain the type of the file system stored on a device.

$ sudo blkid $(devof file)
/dev/sda2: UUID="bla-bla" TYPE="ext4"
$ stat --format="%w" file
-

It seems that the programs that can/should show a file's birth date are not yet updated. According to this stack exchange entry, only debugfs can currently be used to actually show the birth date.

$ ls -id file # get inode number of file
12061569 file 
$ sudo debugfs -R 'stat <12061569>' $(devof file)
Inode: 12061569   Type: regular    Mode:  0664   Flags: 0x80000
Generation: 2431365914    Version: 0x00000000:00000001
User:  1001   Group:  1001   Size: 551
File ACL: 0    Directory ACL: 0
Links: 1   Blockcount: 8
Fragment:  Address: 0    Number: 0    Size: 0
 ctime: 0x52b9e4e6:597d4918 -- Tue Dec 24 20:47:50 2013
 atime: 0x52b9ebd9:429a6374 -- Tue Dec 24 21:17:29 2013
 mtime: 0x52b9e4e6:57950118 -- Tue Dec 24 20:47:50 2013
crtime: 0x52b9e049:977a1be0 -- Tue Dec 24 20:28:09 2013
Size of extra inode fields: 28
EXTENTS:
(0):27330211

The following lscrtime script shows the birth date for each argument file in such a form that is easy to sort.

#!/bin/bash
readonly USAGE="lscrtime file.."

function fatal() {
  echo "fatal error: $1" 2>&1; exit 1
}

for f
do
  [ -e "$f" ] || fatal "$f not a file";
  ff=$(readlink -f "$f") # follows symlink, yields full path
  inode=$(ls -di "$ff" | awk '{ print $1}')
  dev=$(devof "$ff")
  fstype=$(sudo blkid ${dev} | sed -e 's/.*TYPE="//' -e 's/".*//')

  [ "$fstype" == "ext4" ] || fatal "works only with ext4 FS"

  crtime=$(sudo debugfs -R "stat <${inode}>" $dev 2>/dev/null |
    grep 'crtime:' | sed -e 's/.*-- //'
    )
  birth=$(date --date="$crtime" +"%F %T") # yyy-mm-dd hh:mm:ss
  echo "$birth $f"
done

Le Fils

A gripping Dardenne film about Olivier, a father who, by chance, meets the teenager Francis, who, 5 years ago, killed his son in a bungled theft. The two meet because Francis wants to learn carpentry which is taught by the father. The film's pace is slow and pleasant: as a viewer you only learn about the murder background after 30 minutes or so. Although nothing much happens, I was glued to the screen, fascinated by the evolution of the relationship between Francis and Olivier.

☆☆☆☆

Saturday, December 14, 2013

Finding the device where a file is stored.

Most references that I found while searching for a simple way to find the device where a particular file is stored pointed to the df command. However, this does not work if the file is managed by a 'virtual' file system type such as ecryptfs that automatically encrypts its stored contents.

  me@pc :~$ df file.txt
  Filesystem        1K-blocks     Used Available Use% Mounted on
  /home/me/.Private 237996696 173473232 52433916 77% /home/me 

One solution could be to take the 'virtual' filesystem and use df to find its underlying file system etc. until a 'real' file system representing a storage device is found.

  me@pc :~$ df /home/me/.Private
  Filesystem     1K-blocks      Used Available Use% Mounted on
  /dev/sda1      237996696 173473824  52433324  77% /

Another way is based on the full pathname of the file: simply find the longest prefix of the file's pathname that corresponds to a mounted device from /dev.
The bash script shown below shows how to do this:
  1. Use the readlink command to obtain the full 'canonical' pathname of the input file name.
  2. Select all /dev devices that are currently mounted from /etc/mtab. The second column of /etc/mtab, referenced as $2 in the awk program, contains the mount point. Since the first character of a string is at index 1 in awk (instead of 0, as in C), the test
    (index(fnm, $2) == 1)
    succeeds iff fnm, which was imported into the awk program using -v fnm=$path, has the mount point $2 as a prefix. In such a case, the mount point path is printed.
  3. After sort, the mount point that is the longest prefix is the last line of the output, selected using the tail command into the $mpoint variable.
  4. It only remains to retrieve the device mounted on $mpoint by selecting appropriately from /etc/mtab.

#!/bin/bash
readonly USAGE="devof file"

function fatal() {
  echo "$1" 2>&1; exit 1
}

[[ $# == 1 ]] || fatal "usage: $USAGE"
[[ -e "$1" ]] || fatal "'$1' not a file";

# readlink -f: follow symbolic links
path=$(readlink -f "$1")
# get paths that are mount points of /dev/* devices
# select those mount points that are a prefix of $path
# grab the longest prefix path $mpoint
mpoint=$(egrep '^/dev' /etc/mtab |
awk -v "fnm=$path" \
    '{ if (index(fnm, $2) == 1) print $2 }' |
  sort | tail --lines=1
)
# now print the device that is mounted on $mpoint
egrep '^/dev' /etc/mtab |
  awk -v "m=$mpoint" '{ if ($2 == m ) print $1 }'

If you are interested in learning more about bash, I can highly recommend this Bash Guide, which assumes that you already know the basics, as explained e.g. in this tutorial.

Saving Grace

A British comedy (2000) set in pittoresque Cornwal, mostly in the village of Port Isaac. Coincidentally, this is the same village where, later, also Doc Martin would be filmed. The main character of the series, Martin Clunes, plays the village doctor in 'Saving Grace' as well.

As in the Doc Martin series, Cornish people all seem to be eccentrics, so one wonders whether this is actually true. The story is simple: a recent widow discovers that her late husband left her with lots of debts and tries to save her house by growing marijuana. This leads to a number of predicatable jokes, e.g. most of the village's inhabitants unknowingly getting stoned.

I was not impressed.

☆☆

Tuesday, December 10, 2013

Google options and alternatives

Like most people, I knew that it is possible to restrict the domain of the results of a google search. E.g.
site:.fr unpopular president
which would only show results from France.
It turns out that there are plenty of other options (indicated by a keyword such as site followed by a colon (:). The best description I could find was in this Wikipedia article.
Here is a list of the options:
stocks: site: intext: allintitle: intitle: allinurl: inurl: cache: link: related: info: filetype:
The effect of each option should be clear from the name, e.g. allintitle: will only return pages that have all query terms in their title while filetype:pdf will only show pdf documents satisfying the query. See also xkcd about file extensions.

DuckDuckGo

If you're worried about privacy, an excellent alternative to Google is DuckDuckGo which promises, among other things, not to track you. The results I got were similar to Google's. In any case, you can have your search request forwarded to Google by adding !g to your query.

Some DuckDuckGo Options
There's lots of other interesting options, some of which are shown on the picture.

Monday, December 9, 2013

Parenti Serpenti

Also known as Dearest Relations, this is an excellent comedy. The scene is a small Italian town where an old couple receives their grown-up children and grandchildren for the end of year festivities. The film starts as a nice portrait of the local traditions surrounding Christmas etc. The relationships between the siblings, and their partners, are not perfect but that only adds to the charm. As does the fact that the old father is clearly loosing his marbles, which greatly annoys his wife.

Things get nasty when the old mother declares that she and her husband want to live with one of their offspring. This leads to a lively discussion among the children, none of them being keen on welcoming their old parents into their home. All will be resolved in the end, in a most hilarious (and cynical) manner.

☆☆☆☆

Tuesday, December 3, 2013

Pepi, Luci, Bom y otras chicas del monton

This is an early (1980) film by Pedro Almodóvar. It follows three women: Pepi, the lesbian rock singer Bom, and Luci, a masochist married to a Franquist policeman. The story is set in post-Franco Spain, illustrating the newly found sexual freedom that went with the reinstatement of democracy.

While there are some funny episodes, I found the film rather boring.


OECD's PISA report for 2012 is out

The results of the 2012 Program for International Student Assessment (or PISA) are out. The document "What 15-year-olds know and what they can do with what they know: Key results from PISA 2012" makes for very interesting reading, although it only details the results for Mathematics.

Flanders did rather well, again.

For Mathematics, it came, together with Switzerland, 9th (out of 64) after Shanghai, Singapore, Hong Kong, Taipei, Korea, Macao, Japan and Liechtenstein(!). The UK ended up 26th and the US 36th.

For Reading, Flanders got a score of 518, putting it in the 10th position after Shanghai (570), Hong Kong (545), Singapore (542), Japan (538), Korea (536), Finland (524), Taipei (523), Canada (523) and Ireland (523).

Finally, for Science it did rather less well and ended up with a score of 518, putting it in 17th place after Shanghai (580), Hong Kong (555), Singapore (551), Japan (547), Finland (545), Estonia (541), Korea (538), Vietnam (528), Poland (526), Canada (525), Liechtenstein (525), Taipei (523), Germany (524), The Netherlands (522), Macao (521), Australia (521).

Sunday, December 1, 2013

Les Femmes du 6ème étage

A film with two of my favorite French actors, Fabrice Luchini and Sandrine Kimberlain cannot be all bad. In fact, this is an excellent 'feel good' movie. The title "The women on the sixth floor" refers to the floor containing the "chambres de bonnes" in a building otherwise filled with large apartments for the bourgeois that employ the people living on the 6th floor.
The story is set in the early 1960's. Jean-Louis Joubert (Luchini), a financial advisor, becomes infatuated with the new Spanish maid, Maria, who has her own worries, including a child left behind in Spain. His wife (Kimberlain) suspects that he is having an affair with a society figure and kicks him out. He moves to a tiny room on the 6th floor in the same building. This is the first time in his life that he has his own room, and he enjoys it tremendously. He ingratiates himself with the other servants living there.
Unfortunately, Maria leaves for Spain to reunite with her son, without telling him. Still, all ends well (of course) after a while. A pleasure to watch.
☆☆☆☆