--- researchv9/libc/gen/opendir.c 2018/04/24 17:22:00 1.1.1.1 +++ researchv9/libc/gen/opendir.c 2018/04/24 17:35:46 1.1.1.2 @@ -15,6 +15,7 @@ char *name; { int i; register DIR *dirp; register char *p; + struct stat st; dirp = (DIR *)malloc(sizeof(DIR)); if(!dirp) @@ -45,16 +46,24 @@ char *name; p = dirp->dd_buf; if(p[8] != '.') { old: - dirp->dd_type = TOLD; + if (fstat(dirp->dd_fd, &st) < 0) { + close(dirp->dd_fd); + free(dirp); + return(0); + } + if (st.st_ino == *(ino_t *)dirp->dd_buf) + dirp->dd_type = TOLD; + else + dirp->dd_type = TOLDSWAP; return(dirp); } if(p[20] == '.' && p[21] == '.') { /* bsd-like or bogus */ - if(p[4] == 0 && p[5] == 12) { - dirp->dd_type = TSUN; + if(*(short *)&p[4] == 0x000c) { + dirp->dd_type = TBSD; return(dirp); } - if(p[4] == 12 && p[5] == 0) { - dirp->dd_type = TBSD; + if(*(short *)&p[4] == 0x0c00) { + dirp->dd_type = TBSDSWAP; return(dirp); } dirp->dd_type = TUNK;