Correct implementation of getwd.

TODO: we check for err AND n < 0. I bet the second test
is not needed.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>