copied partition-generic.c from kernel