Ticket #314: dasd.diff

File dasd.diff, 3.9 KB (added by KO Myung-Hun, 10 years ago)

patch for dasd open

  • src/emx/src/lib/sys/b_fsFileStat.c

    diff --git a/src/emx/src/lib/sys/b_fsFileStat.c b/src/emx/src/lib/sys/b_fsFileStat.c
    index d544018..b49339f 100755
    a b int __libc_Back_fsFileStat(const char *pszPath, struct stat *pStat) 
    5353    char szNativePath[PATH_MAX];
    5454    int rc = __libc_back_fsResolve(pszPath, BACKFS_FLAGS_RESOLVE_FULL | BACKFS_FLAGS_RESOLVE_DIR_MAYBE, szNativePath, NULL);
    5555    if (!rc)
     56    {
     57        /*
     58         * Check if DASD mode is requested.
     59         */
     60        if (pszPath[1] == ':' && pszPath[2] == '\0')
     61            szNativePath[2] = '\0';
     62
    5663        rc = __libc_back_fsNativeFileStat(szNativePath, pStat);
     64    }
    5765
    5866    if (!rc)
    5967        LIBCLOG_RETURN_INT(rc);
  • src/emx/src/lib/sys/b_fsFileStatFH.c

    diff --git a/src/emx/src/lib/sys/b_fsFileStatFH.c b/src/emx/src/lib/sys/b_fsFileStatFH.c
    index b987bde..3f7a9fb 100755
    a b int __libc_Back_fsFileStatFH(int fh, struct stat *pStat) 
    8686        pStat->st_nlink = 1;
    8787        pStat->st_blksize = 4096*12; /* 48KB */
    8888
    89         if ((pFH->fFlags & __LIBC_FH_TYPEMASK) == F_FILE)
     89        int   fDasdMode = 0;
     90        ULONG fulMode;
     91
     92        if (!DosQueryFHState(fh, &fulMode))
     93            fDasdMode = fulMode & OPEN_FLAGS_DASD;
     94
     95        if ((pFH->fFlags & __LIBC_FH_TYPEMASK) == F_FILE && !fDasdMode)
    9096        {
    9197            /*
    9298             * Regular OS/2 file.
  • src/emx/src/lib/sys/b_fsNativeFileStat.c

    diff --git a/src/emx/src/lib/sys/b_fsNativeFileStat.c b/src/emx/src/lib/sys/b_fsNativeFileStat.c
    index 713bf5c..9f9e8a8 100755
    a b int __libc_back_fsNativeFileStat(const char *pszNativePath, struct stat *pStat) 
    116116    }
    117117
    118118    /*
     119     * If a drive in DASD mode, make a fake unix sutff
     120     */
     121    if (    (pszNativePath[0] >= 'A' && pszNativePath[0] <= 'Z')
     122        &&  (pszNativePath[1] == ':' && !pszNativePath[2]))
     123    {
     124        ULONG      ulDiskNum = pszNativePath[0] - 'A' + 1;
     125        FSALLOCATE fsalloc;
     126        FSINFO     fsinfo;
     127        int        rc;
     128
     129        rc = DosQueryFSInfo(ulDiskNum, FSIL_ALLOC, &fsalloc, sizeof(fsalloc));
     130        if (rc)
     131        {
     132            rc = -__libc_native2errno(rc);
     133            LIBCLOG_ERROR_RETURN_INT(rc);
     134        }
     135
     136        /* fake unix stuff */
     137        /** @todo this doesn't entirely match the open and file handle stat code.
     138         * Fortunately, the user will not see that unless won't have the filename... */
     139        pStat->st_dev = __libc_back_fsPathCalcInodeAndDev(pszNativePath, &pStat->st_ino);
     140        pStat->st_attr = FILE_NORMAL;
     141        pStat->st_mode = S_IFREG | S_IRWXO | S_IRWXG | S_IRWXU;
     142        pStat->st_uid = 0;
     143        pStat->st_gid = 0;
     144        pStat->st_rdev = 0; /* b_ioFileOpen depends on this being 0 for devices! */
     145        pStat->st_nlink = 1;
     146        pStat->st_size = (off_t)fsalloc.cUnit * fsalloc.cSectorUnit * fsalloc.cbSector;
     147        pStat->st_blocks = pStat->st_size / S_BLKSIZE;
     148        pStat->st_blksize = 4096 * 12; /* 48kb */
     149        pStat->st_atime = 0;
     150        pStat->st_mtime = 0;
     151        pStat->st_ctime = 0;
     152        pStat->st_birthtime = 0;
     153        LIBCLOG_RETURN_INT(0);
     154    }
     155
     156    /*
    119157     * Get path info.
    120158     */
    121159    FS_SAVE_LOAD();
  • src/emx/src/lib/sys/b_ioFileOpen.c

    diff --git a/src/emx/src/lib/sys/b_ioFileOpen.c b/src/emx/src/lib/sys/b_ioFileOpen.c
    index cf2b05c..7cdb43a 100755
    a b int __libc_Back_ioFileOpen(const char *pszFile, unsigned fLibc, int fShare, off_ 
    153153    if (rc)
    154154        LIBCLOG_ERROR_RETURN_INT(rc);
    155155
     156    /*
     157     * Check if DASD mode is requsted.
     158     */
     159    if (pszFile[1] == ':' && !pszFile[2])
     160    {
     161        szNativePath[2] = '\0';
     162        flOpenMode |= OPEN_FLAGS_DASD;
     163    }
     164
    156165    dev_t   Dev = 0;
    157166    ino_t   Inode = 0;
    158167    PEAOP2 pEaOp2 = NULL;