fix another overflow bug
review solaris device mapping initialization

-> readdir is okay, sg_init() should be called from main
   (if we want support sg_init() can be called from threads, we must
    fix that, otherwise we'll get stack overflow)
-> cleanup code a bit to understand better what's going on ...