realpath(): Properly fail "." or ".." components after non-directories.

If realpath() is called on pathnames like "/dev/null/." or "/dev/null/..",
it should fail with [ENOTDIR]. Pathnames like "/dev/null/" already failed as
they should.

Also, put the check for non-directories after lstatting the previous
component instead of when the empty component (consecutive or trailing
slashes) is detected, saving an lstat() call and some lines of code.

PR:		kern/82980
MFC after:	2 weeks
Avoid double free in f_acl().

CID:		1018508
Found with:	Coverity Prevent(tm)
MFC after:	1 week
Avoid double close() of a file descriptor.

CID:		1006089
Found with:	Coverity Prevent(tm)
MFC after:	1 week