This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

1.3.6-5: BUG: stat() returns 0 when errno != 0


I've discovered an inconsistency in the way stat() treats windows-style
paths (e.g., "z:/foo") and unix-style paths ("/z/foo").  If the drive
doesn't exist, stat() returns 0 with a windows path and -1 with a unix
path.  errno != 0 in both cases.  This behavior exists in the latest
1.3.6 dll but not in the latest 1.3.5 dll.

I discovered the problem while tracking down why the xemacs
file-exists-p function wasn't working as expected.  It always returned t
for windows-style paths with invalid drives.  Unfortunately, I have at
least one xemacs package that uses windows-style paths with cygwin.

Anyway, here's a test program that demonstrates the problem.

---------------------------------------------------
#include <stdio.h>
#include <sys/stat.h>
#include <errno.h>

int main (int argc, char** argv)
{
    struct stat buf;
    int retval = stat(argv[1], &buf);
    printf("retval = %d\n", retval);
    return errno;
}
---------------------------------------------------

Here's some output using 1.3.6-5.  In my environment, there is no drive
Z and there is a drive C.

,---[./statcheck z:/foo]
| retval = 0, errno = 2 
`---

,---[./statcheck /z/foo]
| retval = -1, errno = 2 
`---

,---[./statcheck c:/foo]
| retval = -1, errno = 2 
`---

,---[./statcheck /c/foo]
| retval = -1, errno = 2 
`---

I think this may be related to the cygwin_posix_to_win32_path_list()
problems reported earlier, but I'm not sure.  If it helps, here's the
output from my pathconvtest.c program, included below.

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

int main (int argc, char** argv)
{
    char* name = argv[1];
    char* tmp;
    tmp = alloca (cygwin_posix_to_win32_path_list_buf_size(name));
    cygwin_posix_to_win32_path_list(name, tmp);
    printf("%s -> %s\n", name, tmp);
    return 0;
}
-----------------------------------------------------------------------

,---[./pathconvtest z:/foo]
| z:/foo -> z;C:\cygwin\foo
`---

,---[./pathconvtest /z/foo]
| /z/foo -> C:\cygwin\z\foo
`---

,---[./pathconvtest c:/foo]
| c:/foo -> c;C:\cygwin\foo
`---

,---[./pathconvtest /c/foo]
| /c/foo -> c:\foo
`---

Here's my cygcheck output...

,---[cygcheck -s -r]
| 
| Cygnus Win95/NT Configuration Diagnostics
| Current System Time: Fri Dec 07 10:46:44 2001
| 
| Windows 2000 Professional Ver 5.0 Build 2195 Service Pack 2
| 
| Path:	~\bin
| 	C:\cygwin\usr\local\bin
| 	C:\cygwin\bin
| 	c:\jdk1.2.2\bin
| 	C:\cygwin\bin
| 	C:\cygwin\usr\local\bin\i686-pc-cygwin
| 	c:\Oracle\Ora81\bin
| 	c:\Program Files\Oracle\jre\1.1.7\bin
| 	c:\WINNT\system32
| 	c:\WINNT
| 	c:\WINNT\System32\Wbem
| 	c:\Program Files\Network Associates\PGPNT
| 	c:\Program Files\Rational\common
| 	c:\Program Files\Rational\Rational Test
| 	c:\Program Files\Rational\ClearCase\bin
| 	c:\Program Files\Hummingbird\Connectivity\7.00\Accessories\
| 	c:\Program Files\Rational\ClearQuest
| 	c:\Program Files\Executive Software\DiskeeperWorkstation\
| 	c:\PROGRA~1\RATIONAL\RATION~1\NUTCROOT\bin
| 	c:\PROGRA~1\RATIONAL\RATION~1\NUTCROOT\bin\x11
| 	c:\PROGRA~1\RATIONAL\RATION~1\NUTCROOT\mksnt
| 	c:\users\daver\bin
| 	c:\Program Files\SSH Communications Security\SSH Secure Shell
| 
| SysDir: C:\WINNT\System32
| WinDir: C:\WINNT
| 
| CYGWIN = `tty ntsec'
| HOME = `c:\users\daver'
| MAKE_MODE = `unix'
| PWD = `/home/daver/tmp'
| USER = `daver'
| 
| HKEY_CURRENT_USER\Software\Cygnus Solutions
| HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin
| HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\mounts v2
|   (default) = `/cygdrive'
|   cygdrive flags = 0x00000020
| HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\Program Options
|
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Start
Menu\Programs\Cygnus Solutions
|   (default) = (unsupported type)
|
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Start
Menu\Programs\Development\Cygnus Solutions
|   (default) = (unsupported type)
| HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions
| HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin
| HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2
|   (default) = `/cygdrive'
|   cygdrive flags = 0x00000028
| HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/
|   (default) = `C:/cygwin'
|   flags = 0x00000008
| HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/c
|   (default) = `c:'
|   flags = 0x00000008
| HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/e
|   (default) = `e:'
|   flags = 0x00000008
| HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/h
|   (default) = `h:'
|   flags = 0x00000008
| HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/home
|   (default) = `c:/users'
|   flags = 0x00000008
| HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/m
|   (default) = `m:'
|   flags = 0x00000008
| HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/p
|   (default) = `p:'
|   flags = 0x00000008
| HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/u
|   (default) = `u:'
|   flags = 0x00000008
| HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/usr/bin
|   (default) = `C:/cygwin/bin'
|   flags = 0x00000008
| HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/usr/lib
|   (default) = `C:/cygwin/lib'
|   flags = 0x00000008
| HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\Program Options
| 
| a:  fd           N/A    N/A                    
| c:  hd  NTFS   19594Mb  52% CP CS UN PA FC     
| d:  cd           N/A    N/A                    
| e:  hd  NTFS   78159Mb  46% CP CS UN PA FC     External
| h:  net NTFS   19594Mb  52% CP CS UN PA FC     
| m:  net MVFS    1000Mb  50% CP CS              CCase
| p:  net NTFS    7134Mb  64% CP CS    PA        .
| u:  net NTFS   43974Mb  28% CP CS UN PA FC     DATA2
| 
| .              /cygdrive  user    textmode,noumount
| C:/cygwin      /          system  textmode
| c:             /c         system  textmode
| e:             /e         system  textmode
| h:             /h         system  textmode
| c:/users       /home      system  textmode
| m:             /m         system  textmode
| p:             /p         system  textmode
| u:             /u         system  textmode
| C:/cygwin/bin  /usr/bin   system  textmode
| C:/cygwin/lib  /usr/lib   system  textmode
| .              /cygdrive  user    textmode,noumount
| 
| Found: C:\cygwin\bin\bash.exe
| Found: C:\cygwin\bin\cat.exe
| Found: C:\cygwin\bin\cpp.exe
| Found: c:\PROGRA~1\RATIONAL\RATION~1\NUTCROOT\bin\cpp.exe
| Found: C:\cygwin\bin\find.exe
| Found: C:\cygwin\bin\gcc.exe
| Found: C:\cygwin\bin\gdb.exe
| Found: C:\cygwin\bin\ld.exe
| Found: C:\cygwin\bin\ls.exe
| Found: C:\cygwin\bin\make.exe
| Found: C:\cygwin\bin\sh.exe
| 
|    56k 2000/12/03 C:\cygwin\bin\cygbz21.0.dll
|   821k 2001/11/19 C:\cygwin\bin\cygcrypto.dll
|    99k 2001/11/20 C:\cygwin\bin\cygcurl-2.dll
|    45k 2001/04/25 C:\cygwin\bin\cygform5.dll
|    34k 2001/09/30 C:\cygwin\bin\cygform6.dll
|    18k 2000/10/23 C:\cygwin\bin\cyggdbm.dll
|    17k 2001/06/28 C:\cygwin\bin\cyghistory4.dll
|    21k 2001/06/28 C:\cygwin\bin\cyghistory5.dll
|    21k 2001/06/20 C:\cygwin\bin\cygintl.dll
|    81k 2001/10/20 C:\cygwin\bin\cygitcl30.dll
|    35k 2001/10/20 C:\cygwin\bin\cygitk30.dll
|    45k 2001/07/04 C:\cygwin\bin\cygjbig1.dll
|   119k 2001/06/06 C:\cygwin\bin\cygjpeg6b.dll
|    26k 2001/04/25 C:\cygwin\bin\cygmenu5.dll
|    19k 2001/09/30 C:\cygwin\bin\cygmenu6.dll
|   156k 2001/04/25 C:\cygwin\bin\cygncurses++5.dll
|   175k 2001/09/30 C:\cygwin\bin\cygncurses++6.dll
|   226k 2001/04/25 C:\cygwin\bin\cygncurses5.dll
|   201k 2001/09/30 C:\cygwin\bin\cygncurses6.dll
|    15k 2001/04/25 C:\cygwin\bin\cygpanel5.dll
|    12k 2001/09/30 C:\cygwin\bin\cygpanel6.dll
|    40k 2001/11/21 C:\cygwin\bin\cygpcre.dll
|    39k 2001/11/21 C:\cygwin\bin\cygpcreposix.dll
|   163k 2001/05/06 C:\cygwin\bin\cygpng2.dll
|   108k 2001/06/28 C:\cygwin\bin\cygreadline4.dll
|   135k 2001/06/28 C:\cygwin\bin\cygreadline5.dll
|    66k 2001/11/20 C:\cygwin\bin\cygregex.dll
|   231k 2001/11/19 C:\cygwin\bin\cygssl.dll
|   390k 2001/10/20 C:\cygwin\bin\cygtcl80.dll
|     5k 2001/10/20 C:\cygwin\bin\cygtclpip80.dll
|    10k 2001/10/20 C:\cygwin\bin\cygtclreg80.dll
|   245k 2001/06/12 C:\cygwin\bin\cygtiff3.dll
|   623k 2001/10/20 C:\cygwin\bin\cygtk80.dll
|    41k 2001/07/04 C:\cygwin\bin\cygXpm-noX4.dll
|    45k 2001/07/04 C:\cygwin\bin\cygXpm-X4.dll
|    49k 2001/02/03 C:\cygwin\bin\cygz.dll
|   720k 2001/12/07 C:\cygwin\bin\cygwin1.dll
|     Cygwin DLL version info:
|         DLL version: 1.3.6
|         DLL epoch: 19
|         DLL bad signal mask: 19005
|         DLL old termios: 5
|         DLL malloc env: 28
|         API major: 0
|         API minor: 47
|         Shared data: 3
|         DLL identifier: cygwin1
|         Mount registry: 2
|         Cygnus registry name: Cygnus Solutions
|         Cygwin registry name: Cygwin
|         Program options name: Program Options
|         Cygwin mount registry name: mounts v2
|         Cygdrive flags: cygdrive flags
|         Cygdrive prefix: cygdrive prefix
|         Cygdrive default prefix: 
|         Build date: Fri Dec 7 00:15:11 EST 2001
|         CVS tag: cygwin-1-3-6-5
|         Shared id: cygwin1S3
| 
| 
| Cygwin Package Information
| Package             Version             
| ash                 20011018-1          
| autoconf            2.52-5              
| autoconf-devel      2.52-4              
| autoconf-stable     2.13-4              
| automake            1.5a-1              
| automake-devel      1.5-5               
| automake-stable     1.4p5-5             
| bash                2.05a-2             
| binutils            20011002-1          
| bison               1.28-1              
| byacc               0.0                 
| bzip2               1.0.1-6             
| clear               1.0                 
| cpio                2.4.2               
| cron                3.0.1-5             
| crypt               1.0-1               
| ctags               5.0.1-1             
| curl                7.9.1-2             
| cvs                 1.11.0-1            
| cygrunsrv           0.94-2              
| cygutils            0.9.7-1             
| cygutils-src        0.9.7-1             
| cygwin              1.3.6-5             
| dejagnu             20010117-1          
| diff                0.0                 
| expect              20010117-1          
| file                3.33-1              
| fileutils           4.1-1               
| findutils           4.1                 
| flex                2.5.4-1             
| gawk                3.0.4-1             
| gcc                 2.95.3-5            
| gdb                 20010428-3          
| gdbm                1.8.0-3             
| gettext             0.10.38-2           
| ghostscript         6.51-1              
| gperf               0.0                 
| grep                2.4.2-1             
| groff               1.17.2-1            
| gzip                1.3.2-1             
| indent              2.2.6-2             
| inetutils           1.3.2-15            
| irc                 20010101-1          
| jbigkit             1.2-4               
| jpeg                6b-4                
| less                358-3               
| libncurses5         5.2-1               
| libncurses6         5.2-2               
| libpng              1.0.11-1            
| login               1.4-2               
| lynx                2.8.4-1             
| m4                  0.0                 
| make                3.79.1-5            
| man                 1.5g-2              
| mingw               20010917-1          
| mingw-runtime       1.1-1               
| mktemp              1.4-1               
| mt                  2.0.1-1             
| mutt                1.2.5i-5            
| nano                1.0.6-1             
| ncftp               3.0.2-2             
| ncurses             5.2-7               
| newlib-man          20001118-1          
| opengl              1.1.0-5             
| openssh             3.0.1p1-2           
| openssh-src         3.0.1p1-2           
| openssl             0.9.6b-2            
| patch               2.5-2               
| pcre                3.7-1               
| perl                5.6.1-2             
| popt                1.6.2-1             
| postgresql          7.1.3-1             
| python              2.1.1-2             
| readline            4.2-3               
| regex               4.4-2               
| rsync               2.4.6-3             
| rxvt                2.7.2-6             
| sed                 3.02-1              
| sh-utils            2.0-2               
| sharutils           4.2.1-1             
| shutdown            1.2-2               
| squid               2.4-STABLE20010508  
| ssmtp               2.38.7-3            
| tar                 1.13.19-1           
| tcltk               20001125-1          
| tcsh                6.10.00-3           
| termcap             20010825-1          
| terminfo            5.2-1               
| tetex-beta          20001218-1          
| texinfo             4.0-5               
| textutils           2.0.16-1            
| tiff                3.5.6beta-2         
| time                1.7-1               
| unzip               5.41-1              
| vim                 6.0.93-1            
| w32api              1.1-1               
| wget                1.7-1               
| which               1.5-1               
| xpm-nox             4.1.0-1             
| zip                 2.3-1               
| zlib                1.1.3-6             
| 
| Use -h to see help about each section
`---

Dave

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]