#21 opendir() failed (mingw-runtime-0.4-20001204)

WSL
closed
None
Feature
fixed
Feature_in_WSL_4.0
False
2015-02-20
2001-01-03
No

This test program doesn't work (under win2k at least) :
<BEGIN tstopendir.c>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#if defined(__MINGW32__)||defined(__CYGWIN__)||defined(_unix)
#include <unistd.h>
#endif
#include <dirent.h>

// Mingw32 doesn't seem to have S_IFLNK defined
#if !defined(S_IFLNK)
# define S_IFLNK 0xa000
#endif
#if !defined(PATH_MAX)
#define PATH_MAX 254
#endif

int proc(const char *szDirPath)
{
char cType,
fname[PATH_MAX],
str[PATH_MAX];
DIR *pDir;
struct dirent *pDirent;
struct stat Stat;

printf\("tstopendir : opendir\(\"%s\"\)\n",szDirPath\);

// opendir() gives an errno=2 if the path has an / or \ at
// the end, else it gives a segfault
pDir=opendir(szDirPath);
printf("opendir returned %s\n",pDir?"true":"false");
if(!pDir)
{
fprintf(stderr,"%s: can't opendir (errno=%u=0x%0x)\n",
szDirPath,errno,errno);
return 2;
}

for(*fname=0;;)
{
pDirent=readdir(pDir);
if(!pDirent)
break;

    strcpy\(fname,pDirent->d\_name\);

    // Ask for more informations about the file
    sprintf\(str,"%s/%s",szDirPath,fname\);
    stat\(str,&Stat\);

    if\(Stat.st\_mode&S\_IFDIR\)
        cType='d';
    else
        if\(Stat.st\_mode&S\_IFREG\)
            cType='-';
        else
            if\(Stat.st\_mode&S\_IFLNK\)
                cType='l';
            else
                cType='?';

    printf\("%c %12lu %s\n",cType,Stat.st\_size,fname\);
\}

closedir\(pDir\);
return  0;

}

int main(int argc,char **argv)
{
if(argc!=2)
{
fprintf(stderr,"usage: %s path",argv[0]);
return 1;
}

return  proc\(argv\[1\]\);

}
<END tstopendir.c>

Discussion

  • Hervé PARISSI

    Hervé PARISSI - 2001-02-02

    Now it works back with mingw-runtime-0.4.tar.gz !

     
  • Earnie Boyd

    Earnie Boyd - 2001-04-12

    Logged In: YES
    user_id=15438

    Is this still an issue???

    Earnie.

     
  • Hervé PARISSI

    Hervé PARISSI - 2001-04-12

    Logged In: YES
    user_id=25461

    Hi, no it's no more an issue, it only failed with mingw-
    runtime-0.4-20001204, I never understood why.
    So you can consider this case closed!

     
  • Earnie Boyd

    Earnie Boyd - 2001-06-07
    • status: open --> closed
     
  • Earnie Boyd

    Earnie Boyd - 2001-06-07
    • assigned_to: nobody --> earnie
    • status: closed --> closed-fixed
     
  • Earnie Boyd

    Earnie Boyd - 2013-02-04
    • status: closed-fixed --> closed
    • resolution: --> fixed
    • category: --> Known_bugs
    • milestone: --> WSL
     
  • Keith Marshall

    Keith Marshall - 2013-02-04

    Although closed, it may be worth noting that the dirent.c module, (which provides opendir() and friends), has been completely reworked for WSL; the reworked version is not ABI compatible with the old.

     
  • Earnie Boyd

    Earnie Boyd - 2013-02-04

    We should note this in the Release Notes and we'll need to release a new GCC/binutils set at the same time.

     
  • Earnie Boyd

    Earnie Boyd - 2013-02-04
    • status: closed --> pending
     
  • Earnie Boyd

    Earnie Boyd - 2013-02-11
    • labels: --> release notes
    • type: --> Support
    • category: Known_bugs --> Feature_in_WSL_4.0
    • patch_attached: --> False
     
  • Earnie Boyd

    Earnie Boyd - 2013-02-11
    • type: Support --> Feature
     
  • Earnie Boyd

    Earnie Boyd - 2013-02-16
    • status: pending --> closed
     
  • Earnie Boyd

    Earnie Boyd - 2013-02-23
    • labels: release notes -->
     
  • Earnie Boyd

    Earnie Boyd - 2013-02-23

    Added to NEWS file.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks