More correct pathname resolution.

These multiple changes make pathname resolution more correct and fail early if errors detected.
The following shell commands show examples of errors fixed. Run them inside sb2 session.
```sh
# preparation
$ ln -s /opt /tmp/opt
$ touch /tmp/testfile
$ mkdir /tmp/testdir
$ touch /tmp/testdir/testfile
# test cases
$ readlink /tmp/opt/../opt  # was checking "/tmp/opt", now checks "/opt"
$ ls -l /tmp/nonexistent/../testdir  # was listing "/tmp/testdir" contents, now shows "no such file or directory" error
$ ls -l /tmp/testdir// # was showing "no such file or directory" error after first 5 commits, now lists "/tmp/testdir"
$ ls -l /tmp/testfile/../testdir # was showing contents of "/tmp/testdir", now "not a directory error"
$ cd /
$ ls -l tmp/testfile  # was showing "no such file or directory" error, now lists "/tmp/testfile"
```