getchroot: rewrite using functions and case clause

Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>