locktest: consolidate do_lock and do_unlock, and add ability to F_GETLK