getcwd: use TERRNO flag rather than manual errno=%d

Signed-off-by: Mike Frysinger <vapier@gentoo.org>