Opened 6 years ago

Closed 5 years ago

Last modified 5 years ago

#285 closed enhancement (fixed)

Add env.var. for entering unix penthouse

Reported by: dmik Owned by:
Priority: lowest Milestone: libc-0.6.6
Component: libc Version: 0.6.5
Severity: trivial Keywords:


Currently, in order to better support the Unix-like file system structure (which in turn simplifies porting of many Unix software to OS/2) the /@unixroot path rewrite rule is used. This pseudo-path is replaced with the value of the UNIXROOT environment variable which makes it possible to move the Unix file system from drive to drive w/o breaking software.

However, this technique still requires one change to the original Unix sources: you have to replace each / which is meant as the root of the Unix file system tree along the sources and makefiles with /@unixroot. This is quite annoying (as there may be dozens of places where this change is needed) and error prone (you may forget one place and this will break everything).

I suggest to extend UNIXROOT support by changing the path rewriter so that it will always treat paths starting with / as Unix-like paths and therefore replace / with the value of UNIXROOT. This will eliminate the need of prepending /@unixroot to them. In theory, many programs should just build and work out-of-the-box.

The only thing that we will lose with such a change is the original meaning of / as a reference to the root directory of the current drive. Though I don't think that this feature is really used by any software, it may be expected by the end user. So it sounds reasonable to make it optional (and even off by default).

Attachments (1)

unixroot_full.diff (638 bytes) - added by dmik 6 years ago.

Download all attachments as: .zip

Change History (7)

Changed 6 years ago by dmik

Attachment: unixroot_full.diff added

comment:1 Changed 6 years ago by dmik

Note that I had been using this patch for quite some time in the past on my working (i.e. "production") machine and it showed almost no problems. I saw the problem only once — AFAIR when using some YUM command (I can't recall which one, unfortunately). What I saw could be related to problems described in #267, #283 or #284 though. So those problems should be certainly fixed before adding this feature.

One thing that puzzles me is the fact that according to our logic (used in other cases) stat("/") should return the S_IFLNK bit set and realpath("/") should return "C:/" (or whatever UNIXROOT is set to). Given that / may never be a symlink in the real Unix world, I wonder what side effects our approach can have.

comment:2 Changed 6 years ago by bird

Milestone: libc-0.6.6
Priority: highlowest
Severity: blockertrivial

comment:3 Changed 6 years ago by dmik

Priority: lowestnormal
Severity: trivialnormal
Type: enhancementdefect

JFYI. The lack of this mapping causes us to do ugly fixes like these:, over and over again. There are so many places like that so that it's practically impossible to fix them all.

comment:4 Changed 6 years ago by dmik

Priority: normallowest
Severity: normaltrivial
Type: defectenhancement

comment:5 Changed 5 years ago by bird

Resolution: fixed
Status: newclosed

Implemented a little differently in r3911 & r3912 (both trunk + branch). The primary environment variable we're checking for being present and not empty is UNIXROOT_CHROOTED. As the name implies it's pretending an parent process did chroot($UNIXROOT), and unless UNIXROOT_OUTSIDE is set, we'll really enter the The Unix Penthouse Apartment if the current directory (and drive) is inside (under) the UNIXROOT.

Say UNIXROOT=e:/libc, UNIXROOT_CHROOTED=1 and current directory e:/libc/svn/trunk, then the difference that UNIXROOT_OUTSIDE makes is this:

e:\libc\svn\trunk>set UNIXROOT_OUTSIDE=
e:\libc\svn\trunk>kmk_ash -c "pwd"
e:\libc\svn\trunk>set UNIXROOT_OUTSIDE=1
e:\libc\svn\trunk>kmk_ash -c "pwd"

comment:6 Changed 5 years ago by bird

Summary: Make / an alias for /@unixrootAdd env.var. for entering unix penthouse
Note: See TracTickets for help on using tickets.