public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* mapping root directory to SystemDrive / CurrentDrive
@ 2004-08-02 12:52 Gernot Hillier
  2004-08-03 10:51 ` Corinna Vinschen
  0 siblings, 1 reply; 9+ messages in thread
From: Gernot Hillier @ 2004-08-02 12:52 UTC (permalink / raw)
  To: cygwin

Hi!

We use some Cygwin tools without Cygwin mounts. The reason for this is (was) 
that we use several Cygwin versions from different network shares in parallel 
(i.e. we have different \Cygwin trees on different drives on our Windows 
hosts).

With earlier Cygwin versions, this worked without any problem as Cygwin always 
mapped "/" to the CurrentDrive (not the SystemDrive, as it is documented in 
http://www.cygwin.com/cygwin-ug-net/using.html). With the current Cygwin 
version, this seems to be mixed: the open() call seems to map "/" to the 
SystemDrive while stat() maps "/" to the current drive.

I can certainly understand that it was our fault to rely on something which 
was not documented. Nevertheless, this was a real nice workaround for us to 
be able to use different Cygwin tools based on different Cygwin trees easily 
(it was even possible to let them run in parallel).

And anyway, I assume that it is a bug that both system calls behave different, 
right?

But - for us - even more important: is there any way to revert to the old 
behaviour (mapping / to CurrentDrive)? 

For the sake of completeness, here are our test cases for interested parties: 
save a.c and b.c to the root of any Windows drive, compile them to different 
binaries. Place a file \test\test.cpp in this drive. Umount / and start both. 
a.c should output an error, b.c not.

----------------- a.c ------------------------------
#include <stdio.h>

int main(void)
{
        int fd;
        fd = open("/test/test.cpp", "rt");
        if (fd == -1) {
                perror("open");
                exit(2);
        }
        return 0;
}
----------------- /a.c ------------------------------


----------------- b.c ------------------------------
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>

int main(void)
{
        struct stat s;
        if (stat("/test/test.cpp", &s) == -1) {
                perror("stat");
                exit(2);
        }
        return 0;
}
----------------- /b.c ------------------------------

-- 
Bye,

Gernot Hillier
CT SE 2
Siemens AG, Mch P

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: mapping root directory to SystemDrive / CurrentDrive
  2004-08-02 12:52 mapping root directory to SystemDrive / CurrentDrive Gernot Hillier
@ 2004-08-03 10:51 ` Corinna Vinschen
  2004-08-03 11:17   ` Gernot Hillier
  0 siblings, 1 reply; 9+ messages in thread
From: Corinna Vinschen @ 2004-08-03 10:51 UTC (permalink / raw)
  To: cygwin

On Aug  2 14:52, Gernot Hillier wrote:
> Hi!
> 
> We use some Cygwin tools without Cygwin mounts. The reason for this is (was) 
> that we use several Cygwin versions from different network shares in parallel 
> (i.e. we have different \Cygwin trees on different drives on our Windows 
> hosts).
> 
> With earlier Cygwin versions, this worked without any problem as Cygwin always 
> mapped "/" to the CurrentDrive (not the SystemDrive, as it is documented in 
> http://www.cygwin.com/cygwin-ug-net/using.html). With the current Cygwin 
> version, this seems to be mixed: the open() call seems to map "/" to the 
> SystemDrive while stat() maps "/" to the current drive.
> 
> I can certainly understand that it was our fault to rely on something which 
> was not documented. Nevertheless, this was a real nice workaround for us to 
> be able to use different Cygwin tools based on different Cygwin trees easily 
> (it was even possible to let them run in parallel).
> 
> And anyway, I assume that it is a bug that both system calls behave different, 
> right?

That's a result of using NtCreateFile instead of CreateFile.  Native NT
calls behave slightly different than Win32 calls.  However, as you said,
you're relying on undocumented behaviour.  I'm sorry but we won't revert
to Win32 calls just to keep an undocumented behaviour running.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Co-Project Leader          mailto:cygwin@cygwin.com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: mapping root directory to SystemDrive / CurrentDrive
  2004-08-03 10:51 ` Corinna Vinschen
@ 2004-08-03 11:17   ` Gernot Hillier
  2004-08-03 11:50     ` Corinna Vinschen
  0 siblings, 1 reply; 9+ messages in thread
From: Gernot Hillier @ 2004-08-03 11:17 UTC (permalink / raw)
  To: cygwin

Hi Corinna!

Thx for your quick reply!

Am Dienstag, 3. August 2004 12:51 schrieb Corinna Vinschen:
> > And anyway, I assume that it is a bug that both system calls behave
> > different, right?
>
> That's a result of using NtCreateFile instead of CreateFile.  Native NT
> calls behave slightly different than Win32 calls.  However, as you said,
> you're relying on undocumented behaviour.  

Ok, so there's no easy way to switch to the old behaviour. Bad for us, but 
well - our problem... :-(

But still there's one open question for me: are there plans to change the 
behaviour of stat(), too?

Because I think it's not good when in such a situation open("/a/b") refers to 
another file than stat("/a/b").

I can imagine quite some problems caused in Linux programs by such behaviour 
of the system...

> I'm sorry but we won't revert to Win32 calls just to keep an undocumented
> behaviour running. 

Hmmm, is there any other way how one can use two different Cygwin 
installations in parallel beside using no mounts?

-- 
Mit freundlichen Grüßen,

Gernot Hillier
CT SE 2
Siemens AG, Mch P

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: mapping root directory to SystemDrive / CurrentDrive
  2004-08-03 11:17   ` Gernot Hillier
@ 2004-08-03 11:50     ` Corinna Vinschen
  2004-08-03 12:00       ` Gernot Hillier
  0 siblings, 1 reply; 9+ messages in thread
From: Corinna Vinschen @ 2004-08-03 11:50 UTC (permalink / raw)
  To: cygwin

On Aug  3 13:17, Gernot Hillier wrote:
> Hi Corinna!
> 
> Thx for your quick reply!
> 
> Am Dienstag, 3. August 2004 12:51 schrieb Corinna Vinschen:
> > > And anyway, I assume that it is a bug that both system calls behave
> > > different, right?
> >
> > That's a result of using NtCreateFile instead of CreateFile.  Native NT
> > calls behave slightly different than Win32 calls.  However, as you said,
> > you're relying on undocumented behaviour.  
> 
> Ok, so there's no easy way to switch to the old behaviour. Bad for us, but 
> well - our problem... :-(
> 
> But still there's one open question for me: are there plans to change the 
> behaviour of stat(), too?
> 
> Because I think it's not good when in such a situation open("/a/b") refers to 
> another file than stat("/a/b").

Actually it doesn't in the first place.  stat() tries to open the file first,
the same as when calling open().  But since the file doesn't exist, opening
it fails and stat() falls back to standard Win32 calls which treat the path
differently, as you observed.  If we wouldn't do that, another problem would
occur; stat() would fail in cases where it shouldn't.  Ok, there might be a
way to workaround that, but it would require somebody interested to patch it.
http://cygwin.com/acronyms/#PTC

> I can imagine quite some problems caused in Linux programs by such behaviour 
> of the system...

Keep in mind that this only happens if / isn't mounted -> back to undocumented
behaviour.

> > I'm sorry but we won't revert to Win32 calls just to keep an undocumented
> > behaviour running. 
> 
> Hmmm, is there any other way how one can use two different Cygwin 
> installations in parallel beside using no mounts?

I'm sorry, but that's generally not supported.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Co-Project Leader          mailto:cygwin@cygwin.com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: mapping root directory to SystemDrive / CurrentDrive
  2004-08-03 11:50     ` Corinna Vinschen
@ 2004-08-03 12:00       ` Gernot Hillier
  2004-08-03 13:45         ` mapping root directory to SystemDrive / CurrentDrive (documentation change needed) Christopher Faylor
  0 siblings, 1 reply; 9+ messages in thread
From: Gernot Hillier @ 2004-08-03 12:00 UTC (permalink / raw)
  To: cygwin

Hi!

Am Dienstag, 3. August 2004 13:50 schrieb Corinna Vinschen:
> > Because I think it's not good when in such a situation open("/a/b")
> > refers to another file than stat("/a/b").
>
> Actually it doesn't in the first place.  stat() tries to open the file
> first, the same as when calling open().  But since the file doesn't exist,
> opening it fails and stat() falls back to standard Win32 calls which treat
> the path differently, as you observed.  If we wouldn't do that, another
> problem would occur; stat() would fail in cases where it shouldn't.  Ok,
> there might be a way to workaround that, but it would require somebody
> interested to patch it. http://cygwin.com/acronyms/#PTC

Ah, thanks for the explanation!

> > I can imagine quite some problems caused in Linux programs by such
> > behaviour of the system...
>
> Keep in mind that this only happens if / isn't mounted -> back to
> undocumented behaviour.

Well, this is not undocumented. The case without mounts is explicitly 
documented on http://www.cygwin.com/cygwin-ug-net/using.html which says "By 
default, the POSIX root / points to the system partition [...]". 

And this is (IMHO) a little bit in contrary to the current stat() behaviour...

But I certainly can see and understand your point that it requires some work 
which is not done yet... ;-)

-- 
Thx again,

Gernot Hillier
CT SE 2
Siemens AG, Mch P

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: mapping root directory to SystemDrive / CurrentDrive (documentation change needed)
  2004-08-03 12:00       ` Gernot Hillier
@ 2004-08-03 13:45         ` Christopher Faylor
  2004-12-27 18:09           ` Joshua Daniel Franklin
  0 siblings, 1 reply; 9+ messages in thread
From: Christopher Faylor @ 2004-08-03 13:45 UTC (permalink / raw)
  To: cygwin

On Tue, Aug 03, 2004 at 02:00:08PM +0200, Gernot Hillier wrote:
>Am Dienstag, 3. August 2004 13:50 schrieb Corinna Vinschen:
>>Keep in mind that this only happens if / isn't mounted -> back to
>>undocumented behaviour.
>
>Well, this is not undocumented.  The case without mounts is explicitly
>documented on http://www.cygwin.com/cygwin-ug-net/using.html which says
>"By default, the POSIX root / points to the system partition [...]".

Joshua, would you mind fixing the documentation?

Thanks,
cgf

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: mapping root directory to SystemDrive / CurrentDrive (documentation change needed)
  2004-08-03 13:45         ` mapping root directory to SystemDrive / CurrentDrive (documentation change needed) Christopher Faylor
@ 2004-12-27 18:09           ` Joshua Daniel Franklin
  2004-12-27 21:08             ` Pierre A. Humblet
  0 siblings, 1 reply; 9+ messages in thread
From: Joshua Daniel Franklin @ 2004-12-27 18:09 UTC (permalink / raw)
  To: cygwin

On Tue, 3 Aug 2004 09:45:24 -0400, Christopher Faylor wrote:
> On Tue, Aug 03, 2004 at 02:00:08PM +0200, Gernot Hillier wrote:
> >Am Dienstag, 3. August 2004 13:50 schrieb Corinna Vinschen:
> >>Keep in mind that this only happens if / isn't mounted -> back to
> >>undocumented behaviour.
> >
> >Well, this is not undocumented.  The case without mounts is explicitly
> >documented on http://www.cygwin.com/cygwin-ug-net/using.html which says
> >"By default, the POSIX root / points to the system partition [...]".
> 
> Joshua, would you mind fixing the documentation?

Well, this is embarrassing but I'm just getting caught up on last
August's email. How does this sound?

Since Windows uses drive letters instead of a single filesystem
root, the POSIX root <filename>/</filename> must be set to a directory
in the Windows file system using the <command>mount</command> command.
Without a <filename>/</filename> mount, Cygwin processes cannot
distinguish between the Windows CurrentDrive and SystemDrive.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: mapping root directory to SystemDrive / CurrentDrive (documentation change needed)
  2004-12-27 18:09           ` Joshua Daniel Franklin
@ 2004-12-27 21:08             ` Pierre A. Humblet
  2004-12-28  0:13               ` Joshua Daniel Franklin
  0 siblings, 1 reply; 9+ messages in thread
From: Pierre A. Humblet @ 2004-12-27 21:08 UTC (permalink / raw)
  To: cygwin

On Mon, Dec 27, 2004 at 10:09:15AM -0800, Joshua Daniel Franklin wrote:
> On Tue, 3 Aug 2004 09:45:24 -0400, Christopher Faylor wrote:
> > On Tue, Aug 03, 2004 at 02:00:08PM +0200, Gernot Hillier wrote:
> > >Am Dienstag, 3. August 2004 13:50 schrieb Corinna Vinschen:
> > >>Keep in mind that this only happens if / isn't mounted -> back to
> > >>undocumented behaviour.
> > >
> > >Well, this is not undocumented.  The case without mounts is explicitly
> > >documented on http://www.cygwin.com/cygwin-ug-net/using.html which says
> > >"By default, the POSIX root / points to the system partition [...]".
> > 
> > Joshua, would you mind fixing the documentation?
> 
> Well, this is embarrassing but I'm just getting caught up on last
> August's email. How does this sound?
> 
> Since Windows uses drive letters
   and UNC paths
> instead of a single filesystem
> root, the POSIX root <filename>/</filename> must be set to a directory
> in the Windows file system using the <command>mount</command> command.
In absence of such a mount, Cygwin maps / to the root of the current 
Windows working directory (e.g. H:\ or \\computer\share)

[this is the long standing behavior, see
 http://cygwin.com/ml/cygwin/2004-08/msg00016.html]

Pierre

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: mapping root directory to SystemDrive / CurrentDrive (documentation change needed)
  2004-12-27 21:08             ` Pierre A. Humblet
@ 2004-12-28  0:13               ` Joshua Daniel Franklin
  0 siblings, 0 replies; 9+ messages in thread
From: Joshua Daniel Franklin @ 2004-12-28  0:13 UTC (permalink / raw)
  To: cygwin

On Mon, 27 Dec 2004 16:02:41 -0500, Pierre A. Humblet wrote:
> In absence of such a mount, Cygwin maps / to the root of the current
> Windows working directory (e.g. H:\ or \\computer\share)
> 
> [this is the long standing behavior, see
>  http://cygwin.com/ml/cygwin/2004-08/msg00016.html]

Thanks Pierre, I see that you provided a patch on September 5:

http://cygwin.com/ml/cygwin-patches/2004-q3/msg00082.html

I take it that this formerly "undocumented" behavior is now 
here to stay.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2004-12-28  0:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-02 12:52 mapping root directory to SystemDrive / CurrentDrive Gernot Hillier
2004-08-03 10:51 ` Corinna Vinschen
2004-08-03 11:17   ` Gernot Hillier
2004-08-03 11:50     ` Corinna Vinschen
2004-08-03 12:00       ` Gernot Hillier
2004-08-03 13:45         ` mapping root directory to SystemDrive / CurrentDrive (documentation change needed) Christopher Faylor
2004-12-27 18:09           ` Joshua Daniel Franklin
2004-12-27 21:08             ` Pierre A. Humblet
2004-12-28  0:13               ` Joshua Daniel Franklin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).