Technical article 125359

The LKP home directory appears to change unexpectedly. What is happening?

UnixWare 7.1.2UnixWare 7.1.3Open UNIX 8

Written · Last revised

Problem

A user logs into a Unix Shell via telnet, rlogin, etc. They type "linux" (from the user's home directory /home/foo) to enter the Linux (LKP) environment.

The user types `pwd` and gets /unixware/home/foo
The user then types `cd` then `pwd` and then gets /home/foo

Solution

This is consistent with what is expected with LKP.

This is what is happening:

All of the Linux environment is under /linux while in a Unix shell. Likewise, all of the Unix environment is under /unixware while in a Linux shell.

Now when you change from a Unix shell to a Linux shell, your directory should remain the same, right? In order to do this the kernel plays tricks with the command `pwd`.

The key thing to understand here is that when you change from Unix to Linux there is a chroot call made. (see man 2 chroot)

In our case "chroot /linux /bin/bash."

So say for example your directory in a Unix shell is /usr/bin. If you type "linux" to change your shell to a Linux shell, your world has changed as well as your root directory.

So what has happened? /linux is now the root directory /.
Your current  directory has changed from /usr/bin to
/unixware/usr/bin, because your shell has changed. So the
kernel has done the right thing. It has put you in the
same directory that you were in, but now it has a
different name.
Now the only way to escape a chroot call, is to use
lxuwfs. It is a special file system that can remount the real root
directory to /unixware. So you can for example use linux binaries to
modify files in the Unix environment. There are other
mount points that use lxuwfs and they are listed in the
mount table. "grep lxuwfs /etc/vfstab"

Things work no differently in /home, but /linux/home is mounted to /home using lxuwfs, so that users no matter what their shell (Unix or Linux or OpenServer via OKP) can go to $HOME and their files will be there.

WORKAROUND:
To automatically have your `pwd` reflect a home directory of
"/home/foo" on login to Linux namespace, do the following;
echo "cd $HOME" >> ~/.bashrc

See also

TA114681 "Open Unix 8, In LKP running Linux binaries on files with relatives pathnames yields confusing results"

From the Xinuos technical article database, record 125359. Reproduced with permission. The original is at www.sco.com/ta/125359, which is reachable but blocked from search engines.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.