Replace destructive guess_device()

Many thanks to Edilbert Kirk for providing this patch.

The previous version did overwrite random data:
static char devicename[80] = "/dev/"; [...]
devicename[80] = 0;