- Timestamp:
- Feb 5, 2006, 2:53:28 AM (20 years ago)
- Location:
- branches/libc-0.6/src/emx
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/libc-0.6/src/emx/include/emx/io.h
r2439 r2522 320 320 /** Does the file system automatically zero the new space when a file is extended? */ 321 321 unsigned fZeroNewBytes : 1; 322 /** Does the file system provide sufficient EA support for UNIX attributes? */ 323 unsigned fUnixEAs : 1; 322 324 /** Device number of the device the filesystem resides on. 323 325 * On OS/2 the device number is derived from the driveletter. */ -
branches/libc-0.6/src/emx/src/lib/sys/b_fs.h
r2328 r2522 411 411 412 412 /** 413 * Gets the fs info object for the specfied path. 414 * 415 * @returns Pointer to info object for the path, if it got one. 416 * @param pszNativePath The native path as returned by the resolver. 417 */ 418 __LIBC_PFSINFO __libc_back_fsInfoObjByPath(const char *pszNativePath); 419 420 /** 421 * Gets the fs info object for the specfied path, with cache. 422 * 423 * @returns Pointer to info object for the path, if it got one. 424 * @param pszNativePath The native path as returned by the resolver. 425 * @param pCached An cached fs info object reference. Can be NULL. 426 */ 427 __LIBC_PFSINFO __libc_back_fsInfoObjByPathCached(const char *pszNativePath, __LIBC_PFSINFO pCached); 428 429 /** 413 430 * Adds a reference to an existing FS info object. 414 431 * … … 428 445 void __libc_back_fsInfoObjRelease(__LIBC_PFSINFO pFsInfo); 429 446 447 /** 448 * Checks if the path supports Unix EAs or not. 449 * 450 * @returns true / false. 451 * @param pszNativePath The native path to check. 452 */ 453 int __libc_back_fsInfoSupportUnixEAs(const char *pszNativePath); 454 430 455 __END_DECLS 431 456 -
branches/libc-0.6/src/emx/src/lib/sys/b_fsDirCreate.c
r2313 r2522 69 69 */ 70 70 PEAOP2 pEaOp2 = NULL; 71 if (__predict_true( !__libc_gfNoUnix))71 if (__predict_true(__libc_back_fsInfoSupportUnixEAs(szNativePath))) 72 72 { 73 73 Mode &= ~__libc_gfsUMask; -
branches/libc-0.6/src/emx/src/lib/sys/b_fsFileModeSetFH.c
r2313 r2522 121 121 * If in unix mode we'll have to update/add the MODE too. 122 122 */ 123 if (!__libc_gfNoUnix) 123 if ( !__libc_gfNoUnix 124 && pFH->pFsInfo 125 && pFH->pFsInfo->fUnixEAs) 124 126 { 125 127 struct stat st = {0}; -
branches/libc-0.6/src/emx/src/lib/sys/b_fsFileStatFH.c
r2316 r2522 71 71 LIBCLOG_ERROR_RETURN_INT(rc); 72 72 73 int fUnixEAs = !__libc_gfNoUnix && pFH->pFsInfo && pFH->pFsInfo->fUnixEAs; 73 74 if (/*!pFH->pOps*/ 1) 74 75 { … … 110 111 if (__libc_gpfnDosOpenL) 111 112 { 112 rc = DosQueryFileInfo(fh, FIL_QUERYEASIZEL, &info, sizeof(info.fsts4L)); 113 if (fUnixEAs) 114 rc = DosQueryFileInfo(fh, FIL_QUERYEASIZEL, &info, sizeof(info.fsts4L)); 115 else 116 rc = -1; 113 117 if (rc) 114 118 { … … 121 125 #endif 122 126 { 123 rc = DosQueryFileInfo(fh, FIL_QUERYEASIZE, &info, sizeof(info.fsts4)); 127 if (fUnixEAs) 128 rc = DosQueryFileInfo(fh, FIL_QUERYEASIZE, &info, sizeof(info.fsts4)); 129 else 130 rc = -1; 124 131 if (rc) 125 132 { … … 175 182 176 183 /* If in unix mode we'll check the EAs (if any). */ 177 if ( !__libc_gfNoUnix184 if ( fUnixEAs 178 185 && (fLarge ? info.fsts4L.cbList : info.fsts4.cbList) >= LIBC_UNIX_EA_MIN) 179 186 __libc_back_fsUnixAttribsGet(fh, pFH->pszNativePath, pStat); -
branches/libc-0.6/src/emx/src/lib/sys/b_fsNativeFileModeSet.c
r2313 r2522 89 89 FS_SAVE_LOAD(); 90 90 int rc; 91 #if OFF_MAX > LONG_MAX 92 if (__libc_gpfnDosOpenL) 93 { 94 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_QUERYEASIZEL, &info, sizeof(info.fsts4L)); 95 fLarge = 1; 91 const int fUnixEAs = __libc_back_fsInfoSupportUnixEAs(pszNativePath); 92 if (fUnixEAs) 93 { 94 #if OFF_MAX > LONG_MAX 95 if (__libc_gpfnDosOpenL) 96 { 97 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_QUERYEASIZEL, &info, sizeof(info.fsts4L)); 98 fLarge = 1; 99 } 100 else 101 #endif 102 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_QUERYEASIZE, &info, sizeof(info.fsts4)); 103 /* If the file is open in write mode, we cannot even get the EA size. stupid. 104 * It'll fail with ERROR_SHARING_VIOLATION, which we handle rigth below. */ 96 105 } 97 106 else 98 #endif 99 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_QUERYEASIZE, &info, sizeof(info.fsts4)); 100 /* Now, if the file is open in write mode, we cannot even get the EA size. stupid. */ 107 rc = ERROR_SHARING_VIOLATION; /* take the fallback path if we don't want EAs. */ 101 108 if (rc == ERROR_SHARING_VIOLATION) 102 109 { … … 150 157 * If in unix mode we'll have to update/add the MODE too. 151 158 */ 152 if ( !__libc_gfNoUnix)159 if (fUnixEAs) 153 160 { 154 161 struct stat st = {0}; -
branches/libc-0.6/src/emx/src/lib/sys/b_fsNativeFileStat.c
r2316 r2522 86 86 */ 87 87 /** @todo copy device check from the path resolver. */ 88 88 89 /* 89 90 * Get path info. … … 91 92 FS_SAVE_LOAD(); 92 93 int rc; 93 #if OFF_MAX > LONG_MAX 94 if (__libc_gpfnDosOpenL) 95 { 96 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_QUERYEASIZEL, &info, sizeof(info.fsts4L)); 97 fLarge = 1; 98 } 99 else 100 #endif 101 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_QUERYEASIZE, &info, sizeof(info.fsts4)); 94 const int fUnixEAs = __libc_back_fsInfoSupportUnixEAs(pszNativePath); 95 if (fUnixEAs) 96 { 97 #if OFF_MAX > LONG_MAX 98 if (__libc_gpfnDosOpenL) 99 { 100 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_QUERYEASIZEL, &info, sizeof(info.fsts4L)); 101 fLarge = 1; 102 } 103 else 104 #endif 105 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_QUERYEASIZE, &info, sizeof(info.fsts4)); 106 /* If the file is open in write mode, we cannot even get the EA size. stupid. 107 * It'll fail with ERROR_SHARING_VIOLATION, which we handle rigth below. */ 108 } 109 else 110 rc = ERROR_SHARING_VIOLATION; /* take the fallback path if we don't want EAs. */ 111 102 112 /* Now, if the file is open in write mode, we cannot even get the EA size. stupid. */ 103 113 if (rc == ERROR_SHARING_VIOLATION) … … 198 208 /* If in unix mode we'll check the EAs (if any). */ 199 209 rc = 1; 200 if ( !__libc_gfNoUnix210 if ( fUnixEAs 201 211 && (fLarge ? info.fsts4L.cbList : info.fsts4.cbList) >= LIBC_UNIX_EA_MIN) 202 212 rc = __libc_back_fsUnixAttribsGet(-1, pszNativePath, pStat); -
branches/libc-0.6/src/emx/src/lib/sys/b_ioFileOpen.c
r2424 r2522 259 259 Mode &= ACCESSPERMS; 260 260 Mode |= S_IFREG; 261 if (flOpenFlags & (OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS)) 261 if ( (flOpenFlags & (OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS)) 262 && __libc_back_fsInfoSupportUnixEAs(szNativePath)) 262 263 { 263 264 pEaOp2 = alloca(sizeof(EAOP2) + sizeof(__libc_gFsUnixAttribsCreateFEA2List)); -
branches/libc-0.6/src/emx/src/lib/sys/b_nativeSymlinkCreate.c
r2498 r2522 58 58 BYTE fSymlinkEA; 59 59 BYTE cbSymlinkName; 60 USHORT usSymlinkValue;60 USHORT cbSymlinkValue; 61 61 CHAR szSymlinkName[sizeof(EA_SYMLINK)]; 62 62 USHORT usSymlinkType; … … 112 112 113 113 /* 114 * Do we have UnixEAs on this path? 115 */ 116 if (__predict_false(!__libc_back_fsInfoSupportUnixEAs(pszNativePath))) 117 LIBCLOG_ERROR_RETURN(-ENOTSUP, "ret -ENOTSUP - no Unix EAs on '%s'\n", pszNativePath); 118 119 /* 114 120 * Allocate FEA buffer. 115 121 */ … … 126 132 *pFEas = __libc_gFsUnixAttribsCreateSymlinkFEA2List; 127 133 __libc_back_fsUnixAttribsInit(&pFEas->Core, pszNativePath, S_IFLNK | S_IRWXO | S_IRWXG | S_IRWXU); 128 pFEas->Core.cbList = cchTarget + sizeof(USHORT) * 2; 129 pFEas->cbSymlinkData = cchTarget; 134 pFEas->Core.cbList = cchTarget + sizeof(__libc_gFsUnixAttribsCreateSymlinkFEA2List) - 1; 135 pFEas->cbSymlinkValue += cchTarget; 136 pFEas->cbSymlinkData = cchTarget; 130 137 memcpy(pFEas->szSymlink, pszTarget, cchTarget); 131 138 -
branches/libc-0.6/src/emx/src/lib/sys/fs.c
r2496 r2522 637 637 LIBCLOG_ENTER("pszUserPath=%p:{%s} pszNativePath=%p *pfInUnixTree=%p\n", 638 638 (void *)pszUserPath, pszUserPath, (void *)pszNativePath, (void *)pfInUnixTree); 639 const char *pszUserPathIn = pszUserPath; 640 char _achBuffer[SIZEOF_ACHBUFFER + 4]; 641 char *pachBuffer = (char *)((uintptr_t)&_achBuffer[3] & ~3); 642 unsigned cLoopsLeft = 8; 643 int fInUnixTree = __libc_gfInUnixTree; 644 int rcRet = 0; 645 HDIR hDir = HDIR_CREATE; 639 const char *pszUserPathIn = pszUserPath; 640 char _achBuffer[SIZEOF_ACHBUFFER + 4]; 641 char *pachBuffer = (char *)((uintptr_t)&_achBuffer[3] & ~3); 642 unsigned cLoopsLeft = 8; 643 int fInUnixTree = __libc_gfInUnixTree; 644 int rcRet = 0; 645 HDIR hDir = HDIR_CREATE; 646 __LIBC_PFSINFO pFsInfo = NULL; 647 int fUnixEAs; 646 648 FS_VAR() 647 649 FS_SAVE_LOAD(); … … 889 891 iRoot = psz - pszNativePath; 890 892 psz = strchr(psz, '/'); 893 894 /* We don't do UNIX EAs on UNCs */ 895 fUnixEAs = 0; 891 896 } 892 897 else … … 898 903 pszPrev = &pszNativePath[iRoot + 1]; 899 904 psz = strchr(pszPrev, '/'); 905 906 /* Unix EAs? */ 907 pFsInfo = __libc_back_fsInfoObjByPathCached(pszNativePath, pFsInfo); 908 LIBC_ASSERTM(pFsInfo, "%s\n", pszNativePath); 909 fUnixEAs = pFsInfo ? pFsInfo->fUnixEAs : 0; 900 910 } 901 911 LIBC_ASSERTM(pszPrev - pszNativePath >= iRoot, "iRoot=%d pszPrev offset %d pszNativePath=%s\n", iRoot, pszPrev - pszNativePath, pszNativePath); … … 975 985 * This is a little bit messed up since we'll have to use wildcard for 976 986 * getting the casing resolved. 987 * 988 * The two find buffers are assumed to be equal down thru attrFile. 977 989 */ 978 990 //LIBC_ASSERT(psz - pszNativePath == cchNativePath); - figure this one. 979 PFILEFINDBUF4 pFindBuf = (PFILEFINDBUF4)pachBuffer; 991 PFILEFINDBUF4 pFindBuf4 = (PFILEFINDBUF4)pachBuffer; 992 PFILEFINDBUF3 pFindBuf3 = (PFILEFINDBUF3)pachBuffer; 980 993 ULONG cFiles = 1; 981 994 char chNext = psz[1]; … … 983 996 psz[1] = '\0'; 984 997 int rc = DosFindFirst((PCSZ)pszNativePath, &hDir, FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM | FILE_DIRECTORY | FILE_ARCHIVED, 985 p FindBuf, SIZEOF_ACHBUFFER, &cFiles, FIL_QUERYEASIZE);998 pachBuffer, SIZEOF_ACHBUFFER, &cFiles, fUnixEAs ? FIL_QUERYEASIZE : FIL_STANDARD); 986 999 psz[0] = '\0'; 987 1000 psz[1] = chNext; 988 1001 if (rc || cFiles == 0) 989 1002 hDir = HDIR_CREATE; 990 while (!rc && cFiles == 1 && pFindBuf->cchName!= psz - pszPrev)991 rc = DosFindNext(hDir, p FindBuf, SIZEOF_ACHBUFFER, &cFiles);1003 while (!rc && cFiles == 1 && (fUnixEAs ? pFindBuf4->cchName : pFindBuf3->cchName) != psz - pszPrev) 1004 rc = DosFindNext(hDir, pachBuffer, SIZEOF_ACHBUFFER, &cFiles); 992 1005 if (rc || cFiles == 0) 993 1006 { … … 1002 1015 break; 1003 1016 } 1004 memcpy(pszPrev, pFindBuf->achName, psz - pszPrev);1005 int fIsDirectory = (pFindBuf ->attrFile & FILE_DIRECTORY) != 0;1017 memcpy(pszPrev, fUnixEAs ? pFindBuf4->achName : pFindBuf3->achName, psz - pszPrev); 1018 int fIsDirectory = (pFindBuf4->attrFile & FILE_DIRECTORY) != 0; 1006 1019 1007 1020 /* 1008 1021 * Try querying the symlink EA value. 1009 * (This operation will reuse the achBuffer overwriting the pFindBuf data!)1022 * (This operation will reuse the achBuffer overwriting the pFindBuf[3/4] data!) 1010 1023 * 1011 1024 * Yeah, we could do this in the same operation as the DosFindFirst() but … … 1017 1030 * cases anyway... very nice. 1018 1031 */ 1019 if ( pFindBuf->cbList > sizeof(USHORT) * 2 + 1 1032 if ( fUnixEAs 1033 && pFindBuf4->cbList > sizeof(USHORT) * 2 + 1 1020 1034 && ( (fFlags & BACKFS_FLAGS_RESOLVE_FULL) 1021 1035 || chSlash) 1022 && !(pFindBuf ->attrFile & FILE_DIRECTORY))1036 && !(pFindBuf4->attrFile & FILE_DIRECTORY)) 1023 1037 { 1024 1038 PEAOP2 pEaOp2 = (PEAOP2)pachBuffer; … … 1188 1202 1189 1203 /* 1190 * Cleanup find handle .1204 * Cleanup find handle and fs object. 1191 1205 */ 1192 1206 if (hDir != HDIR_CREATE) 1193 1207 DosFindClose(hDir); 1208 if (pFsInfo) 1209 __libc_back_fsInfoObjRelease(pFsInfo); 1194 1210 FS_RESTORE(); 1195 1211 … … 1502 1518 /* init the structure */ 1503 1519 pFsInfo->fZeroNewBytes = 0; 1520 pFsInfo->fUnixEAs = 0; 1504 1521 pFsInfo->Dev = Dev; 1505 1522 pFsInfo->szName[0] = '\0'; … … 1517 1534 if ( !strcmp(pFsInfo->szName, "JFS") 1518 1535 || !strcmp(pFsInfo->szName, "HPFS") 1519 || !strcmp(pFsInfo->szName, "FAT") 1520 || !strcmp(pFsInfo->szName, "LAN")) 1521 pFsInfo->fZeroNewBytes = 1; /* RAMFS does not do this. */ 1522 LIBCLOG_MSG2("fsInfoObjUpdate: dev:%#x mp:%s fsd:%s fZeroNewBytes=%d\n", 1523 pFsInfo->Dev, pFsInfo->szMountpoint, pFsInfo->szName, pFsInfo->fZeroNewBytes); 1536 || !strcmp(pFsInfo->szName, "FAT")) 1537 { 1538 pFsInfo->fZeroNewBytes = 1; 1539 pFsInfo->fUnixEAs = 1; 1540 } 1541 else if (!strcmp(pFsInfo->szName, "LAN")) 1542 { 1543 /* should find a way of getting the remote fs... */ 1544 pFsInfo->fZeroNewBytes = 1; /* for performance reasons, assume it zeros. */ 1545 pFsInfo->fUnixEAs = 0; 1546 } 1547 else if (!strcmp(pFsInfo->szName, "RAMFS")) 1548 { 1549 pFsInfo->fZeroNewBytes = 0; 1550 pFsInfo->fUnixEAs = 1; /* but it doesn't zero */ 1551 } 1552 /*else if (!strcmp(pFsInfo->szName, "FAT32")) 1553 { 1554 pFsInfo->fZeroNewBytes = 0; 1555 pFsInfo->fUnixEAs = 0; 1556 }*/ 1557 else 1558 { 1559 pFsInfo->fZeroNewBytes = 0; 1560 pFsInfo->fUnixEAs = 0; 1561 } 1562 1563 LIBCLOG_MSG2("fsInfoObjUpdate: dev:%#x mp:%s fsd:%s fZeroNewBytes=%d fUnixEAs=%d\n", 1564 pFsInfo->Dev, pFsInfo->szMountpoint, pFsInfo->szName, pFsInfo->fZeroNewBytes, 1565 pFsInfo->fUnixEAs); 1524 1566 FS_RESTORE(); 1525 1567 } … … 1559 1601 1560 1602 1561 #if 01562 1603 /** 1563 1604 * Gets the fs info object for the specfied path. … … 1582 1623 return __libc_back_fsInfoObjByDev(Dev); 1583 1624 } 1584 #endif 1625 1626 1627 /** 1628 * Gets the fs info object for the specfied path, with cache. 1629 * 1630 * @returns Pointer to info object for the path, if it got one. 1631 * @param pszNativePath The native path as returned by the resolver. 1632 * @param pCached An cached fs info object reference. Can be NULL. 1633 */ 1634 __LIBC_PFSINFO __libc_back_fsInfoObjByPathCached(const char *pszNativePath, __LIBC_PFSINFO pCached) 1635 { 1636 /* 1637 * Calc device. 1638 */ 1639 dev_t Dev; 1640 char chDrv = *pszNativePath; 1641 if (chDrv == '/' || chDrv == '\\') 1642 Dev = makedev('U', 0); /* U as in UNC */ 1643 else 1644 { 1645 LIBC_ASSERT(chDrv >= 'A' && chDrv <= 'Z'); 1646 Dev = makedev('V', chDrv); /* V as in Volume */ 1647 } 1648 if (!pCached) 1649 return __libc_back_fsInfoObjByDev(Dev); 1650 if (pCached->Dev == Dev) 1651 return pCached; 1652 __libc_back_fsInfoObjRelease(pCached); 1653 return __libc_back_fsInfoObjByDev(Dev); 1654 } 1585 1655 1586 1656 … … 1617 1687 LIBC_ASSERT(cRefs > 1); (void)cRefs; 1618 1688 } 1689 } 1690 1691 1692 /** 1693 * Checks if the path supports Unix EAs or not. 1694 * 1695 * @returns true / false. 1696 * @param pszNativePath The native path to check. 1697 */ 1698 int __libc_back_fsInfoSupportUnixEAs(const char *pszNativePath) 1699 { 1700 if (__libc_gfNoUnix) 1701 return 0; 1702 1703 __LIBC_PFSINFO pFsInfo = __libc_back_fsInfoObjByPath(pszNativePath); 1704 const int fUnixEAs = pFsInfo && pFsInfo->fUnixEAs; 1705 __libc_back_fsInfoObjRelease(pFsInfo); 1706 return fUnixEAs; 1619 1707 } 1620 1708
Note:
See TracChangeset
for help on using the changeset viewer.