[Patch] override-able installation_root

Shaddy Baddah helium@shaddybaddah.name
Wed Nov 25 14:03:00 GMT 2009


Hi,

Please find attached a patch to allow for override-able 
installation_root. I actually wrote this patch for release 1.7.0-52 
motivated by the thread I started " [1.7] Alternative root directory. 
Sort of a regression." 
[http://cygwin.com/ml/cygwin/2009-07/msg00904.html]. I have forward 
ported it.

The idea behind this patch is as follows. Presently, the 
installation_root is fixed to be based off of the path to the cygwin 
dll. This also means that the /etc/fstab must be located exactly at 
..\etc\fstab relative path to the path of the folder containing the 
cygwin dll.

I wished/qwish to shared a single Cygwin installation on my host, with 
my guest Windows in VirtualBox. However, I need and wanted a) a 
different path to home directories (because I wanted to ensure read-only 
sharing) b) generally alternative configuration from /etc. This is why I 
needed both an alternative /etc/fstab and /etc directory in general. 
These both imply an alternative installation_root, as this is how these 
"bootstrap" locations are determined.

The patch works by checking for a supplementary, manually added registry 
entry, which indicates that the rootdir set by the Cygwin setup 
application should be considered the installation_root. The idea is that 
on the Cygwin installation "client", the administrator would manually 
setup both .../Cygwin/Setup/rootdir and 
.../Cygwin/Setup/rootdir_is_installation_dir.

Note, in forward porting, I had to discard a change I made to reg_key 
(registry.{h,cc}) in deference to a change Corinna made that partly 
mirrored my own. I am talking about the addition of the following method 
(and its associates):

  int get_string (const PWCHAR, PWCHAR, size_t, const PWCHAR);

However, I have found this to be slightly problematic. It resulted in me 
having to explicitly cast as in:

      && (setup_reg.get_string ((const PWCHAR)L"rootdir",
                setup_installation_root, PATH_MAX,
                (const PWCHAR)L"") == ERROR_SUCCESS))

When faced with the same situation, to avoid the cast, I had to alter 
the method to look like this:

  int get_string (PCWCH, PWCHAR buf, size_t len, PCWCH def);

To be honest, I don't totally understand why it was necessary, even 
though I am aware of the difference between const positioning. Perhaps 
this needs a second look at? By the way, this problem pricked my 
curiosity leading me to ask about "regtool/registry interfacing and 
charset support" [http://cygwin.com/ml/cygwin/2009-07/msg00930.html].

winsup/cygwin/ChangeLog

2009-11-25  Shaddy Baddah  <helium@shaddybaddah.name>

    * include/cygwin/version.h: Added CYGWIN_INFO_SETUP_NAME registry
    name for consistency
    * shared.cc (init_installation_root): Switches in the setup
    rootdir as the installation_root when a boolean registry entry
    "rootdir_is_installation_root" is set true.


Thanks in advance for (fingers crossed, thoughtfully) considering this 
patch,
Shaddy

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: override-able_installation_root.diff
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20091125/6affe928/attachment.ksh>


More information about the Cygwin-patches mailing list