Changeset 1947
- Timestamp:
- May 2, 2005, 5:00:19 AM (21 years ago)
- Location:
- trunk/src/emx/src/lib/sys
- Files:
-
- 8 edited
-
b_fs.h (modified) (1 diff, 1 prop)
-
b_fsDirRemove.c (modified) (1 diff, 1 prop)
-
b_fsRename.c (modified) (1 diff, 1 prop)
-
b_fsSymlinkModeSet.c (modified) (1 diff, 1 prop)
-
b_fsSymlinkRead.c (modified) (1 diff, 1 prop)
-
b_fsSymlinkStat.c (modified) (1 diff, 1 prop)
-
b_fsUnlink.c (modified) (1 diff, 1 prop)
-
fs.c (modified) (17 diffs, 1 prop)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/src/lib/sys/b_fs.h
-
Property cvs2svn:cvs-rev
changed from
1.4to1.5
r1946 r1947 119 119 * @{ */ 120 120 /** Resolves the path up to but not including the last component. */ 121 #define BACKFS_FLAGS_RESOLVE_PARENT 0121 #define BACKFS_FLAGS_RESOLVE_PARENT 0 122 122 /** Resolves and verfies the entire path. */ 123 #define BACKFS_FLAGS_RESOLVE_FULL 1 123 #define BACKFS_FLAGS_RESOLVE_FULL 0x01 124 /** Resolves and verfies the entire path, but don't resolve any symlink in the last component. */ 125 #define BACKFS_FLAGS_RESOLVE_FULL_SYMLINK 0x02 126 /** Internal, use BACKFS_FLAGS_RESOLVE_FULL_MAYBE. */ 127 #define BACKFS_FLAGS_RESOLVE_FULL_MAYBE_ 0x08 124 128 /** Resolves and verfies the entire path but it's ok if the last component doesn't exist. */ 125 #define BACKFS_FLAGS_RESOLVE_FULL_MAYBE (BACKFS_FLAGS_RESOLVE_FULL | BACKFS_FLAGS_RESOLVE_FULL_MAYBE_)126 /** Internal, use BACKFS_FLAGS_RESOLVE_FULL_MAYBE. */127 #define BACKFS_FLAGS_RESOLVE_FULL_ MAYBE_ 2129 #define BACKFS_FLAGS_RESOLVE_FULL_MAYBE ) 130 /** . */ 131 #define BACKFS_FLAGS_RESOLVE_FULL_ 128 132 /** The specified path is a directory. */ 129 #define BACKFS_FLAGS_RESOLVE_DIR 4 133 #define BACKFS_FLAGS_RESOLVE_DIR 0x10 134 /** Internal, use BACKFS_FLAGS_RESOLVE_DIR_MAYBE. */ 135 #define BACKFS_FLAGS_RESOLVE_DIR_MAYBE_ 0x80 130 136 /** The specified path maybe a directory. */ 131 #define BACKFS_FLAGS_RESOLVE_DIR_MAYBE (BACKFS_FLAGS_RESOLVE_DIR | BACKFS_FLAGS_RESOLVE_DIR_MAYBE_) 132 /** Internal, use BACKFS_FLAGS_RESOLVE_DIR_MAYBE. */ 133 #define BACKFS_FLAGS_RESOLVE_DIR_MAYBE_ 8 137 #define BACKFS_FLAGS_RESOLVE_DIR_MAYBE (BACKFS_FLAGS_RESOLVE_DIR_MAYBE_ | BACKFS_FLAGS_RESOLVE_DIR) 134 138 /** @} */ 135 139 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_fsDirRemove.c
-
Property cvs2svn:cvs-rev
changed from
1.6to1.7
r1946 r1947 58 58 */ 59 59 char szNativePath[PATH_MAX]; 60 int rc = __libc_back_fsResolve(pszPath, BACKFS_FLAGS_RESOLVE_ PARENT| BACKFS_FLAGS_RESOLVE_DIR, &szNativePath[0], NULL);60 int rc = __libc_back_fsResolve(pszPath, BACKFS_FLAGS_RESOLVE_ | BACKFS_FLAGS_RESOLVE_DIR, &szNativePath[0], NULL); 61 61 if (rc) 62 62 LIBCLOG_RETURN_INT(rc); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_fsRename.c
-
Property cvs2svn:cvs-rev
changed from
1.2to1.3
r1946 r1947 66 66 */ 67 67 char szNativePathOld[PATH_MAX]; 68 int rc = __libc_back_fsResolve(pszPathOld, BACKFS_FLAGS_RESOLVE_ PARENT| BACKFS_FLAGS_RESOLVE_DIR_MAYBE, &szNativePathOld[0], NULL);68 int rc = __libc_back_fsResolve(pszPathOld, BACKFS_FLAGS_RESOLVE_ | BACKFS_FLAGS_RESOLVE_DIR_MAYBE, &szNativePathOld[0], NULL); 69 69 if (rc) 70 70 LIBCLOG_RETURN_INT(rc); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_fsSymlinkModeSet.c
-
Property cvs2svn:cvs-rev
changed from
1.1to1.2
r1946 r1947 51 51 */ 52 52 char szNativePath[PATH_MAX]; 53 int rc = __libc_back_fsResolve(pszPath, BACKFS_FLAGS_RESOLVE_ PARENT| BACKFS_FLAGS_RESOLVE_DIR_MAYBE, szNativePath, NULL);53 int rc = __libc_back_fsResolve(pszPath, BACKFS_FLAGS_RESOLVE_ | BACKFS_FLAGS_RESOLVE_DIR_MAYBE, szNativePath, NULL); 54 54 if (!rc) 55 55 rc = __libc_back_fsNativeFileModeSet(szNativePath, Mode); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_fsSymlinkRead.c
-
Property cvs2svn:cvs-rev
changed from
1.3to1.4
r1946 r1947 59 59 */ 60 60 char szNativePath[PATH_MAX]; 61 int rc = __libc_back_fsResolve(pszPath, BACKFS_FLAGS_RESOLVE_ PARENT, &szNativePath[0], NULL);61 int rc = __libc_back_fsResolve(pszPath, BACKFS_FLAGS_RESOLVE_, &szNativePath[0], NULL); 62 62 if (!rc) 63 63 rc = __libc_back_fsNativeSymlinkRead(szNativePath, pachBuf, cchBuf); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_fsSymlinkStat.c
-
Property cvs2svn:cvs-rev
changed from
1.4to1.5
r1946 r1947 53 53 */ 54 54 char szNativePath[PATH_MAX]; 55 int rc = __libc_back_fsResolve(pszPath, BACKFS_FLAGS_RESOLVE_ PARENT| BACKFS_FLAGS_RESOLVE_DIR_MAYBE, szNativePath, NULL);55 int rc = __libc_back_fsResolve(pszPath, BACKFS_FLAGS_RESOLVE_ | BACKFS_FLAGS_RESOLVE_DIR_MAYBE, szNativePath, NULL); 56 56 if (!rc) 57 57 rc = __libc_back_fsNativeFileStat(szNativePath, pStat); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_fsUnlink.c
-
Property cvs2svn:cvs-rev
changed from
1.1to1.2
r1946 r1947 65 65 */ 66 66 char szNativePath[PATH_MAX]; 67 int rc = __libc_back_fsResolve(pszPath, BACKFS_FLAGS_RESOLVE_ PARENT| BACKFS_FLAGS_RESOLVE_DIR_MAYBE, &szNativePath[0], NULL);67 int rc = __libc_back_fsResolve(pszPath, BACKFS_FLAGS_RESOLVE_ | BACKFS_FLAGS_RESOLVE_DIR_MAYBE, &szNativePath[0], NULL); 68 68 if (rc) 69 69 LIBCLOG_RETURN_INT(rc); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/fs.c
-
Property cvs2svn:cvs-rev
changed from
1.14to1.15
r1946 r1947 187 187 *******************************************************************************/ 188 188 static int fsResolveUnix(const char *pszUserPath, unsigned fFlags, char *pszNativePath, int *pfInUnixTree); 189 189 190 static uint32_t crc32str(const char *psz); 190 191 static uint32_t djb2(const char *str); … … 192 193 193 194 194 195 #ifndef STANDALONE_TEST 195 196 /** 196 197 * Init the file system stuff. … … 365 366 } 366 367 368 367 369 368 370 /** … … 668 670 if (!__libc_gfNoUnix) 669 671 return fsResolveUnix(pszUserPath, fFlags, pszNativePath, pfInUnixTree); 670 671 /* __libc_back_fsResolveOS2(): */ 672 673 LIBCLOG_ENTER("pszUserPath=%p:{%s} fFlags=%x pszNativePath=%p pfInUnixTree=%p\n", 674 (void *)pszUserPath, pszUserPath, fFlags, (void *)pszNativePath, (void *)pfInUnixTree); 675 676 /* 677 * Apply rewrite rule. 678 */ 679 int cch = __libc_PathRewrite(pszUserPath, pszNativePath, sizeof(pszNativePath)); 680 if (cch < 0) 681 LIBCLOG_RETURN_INT(-EINVAL); 682 if (cch == 0) 683 { 684 cch = strlen(pszUserPath); 685 if (cch >= PATH_MAX) 686 LIBCLOG_RETURN_INT(-ENAMETOOLONG); 687 memcpy(pszNativePath, pszUserPath, cch + 1); 688 } 689 690 /* 691 * Convert slashes. 692 */ 693 char *psz = strchr(pszNativePath, '/'); 694 while (psz) 695 { 696 *psz++ = '\\'; 697 psz = strchr(psz, '/'); 698 } 699 700 /** @todo Validate the path? hopefully not necessary. */ 701 702 if (pfInUnixTree) 703 *pfInUnixTree = 0; 704 705 LIBCLOG_RETURN_INT(0); 672 else 673 return fsResolveOS2(pszUserPath, fFlags, pszNativePath, pfInUnixTree); 706 674 } 707 675 … … 719 687 * @param pfInUnixTree Where to store the result-in-unix-tree indicator. Optional. 720 688 */ 721 int fsResolveUnix(const char *pszUserPath, unsigned fFlags, char *pszNativePath, int *pfInUnixTree)689 int fsResolveUnix(const char *pszUserPath, unsigned fFlags, char *pszNativePath, int *pfInUnixTree) 722 690 { 723 691 LIBCLOG_ENTER("pszUserPath=%p:{%s} pszNativePath=%p *pfInUnixTree=%p\n", … … 744 712 fInUnixTree = __libc_gfInUnixTree; 745 713 } 746 else if ( pszUserPath[0] && pszUserPath[1] == ':'714 else if (pszUserPath[0] && pszUserPath[1] == ':' 747 715 && (pszUserPath[2] == '/' || pszUserPath[2] == '\\')) 748 716 { … … 898 866 899 867 /* 900 * Expand unix root .868 * Expand unix root. 901 869 */ 902 if (szTmp[0] == '/' && szTmp[1] != '/' && __libc_gcchUnixRoot) 903 { 904 iRoot = __libc_gcchUnixRoot; 905 if (cchTmp + iRoot >= PATH_MAX) 906 { 907 rcRet = -ENAMETOOLONG; 908 break; 909 } 870 if (szTmp[0] == '/' && szTmp[1] != '/') 871 { 910 872 memcpy(pachBuffer, szTmp, cchTmp + 1); 911 memcpy(szTmp, __libc_gszUnixRoot, iRoot); 873 if (__libc_gcchUnixRoot) 874 { 875 iRoot = __libc_gcchUnixRoot; 876 if (cchTmp + iRoot >= PATH_MAX) 877 { 878 rcRet = -ENAMETOOLONG; 879 break; 880 } 881 memcpy(szTmp, __libc_gszUnixRoot, iRoot); 882 fInUnixTree = 1; 883 } 884 else 885 { 886 iRoot = 2; 887 ULONG ulDisk = 0; 888 ULONG ul; 889 DosQueryCurrentDisk(&ulDisk, &ul); 890 if (cchTmp + iRoot >= PATH_MAX) 891 { 892 rcRet = -ENAMETOOLONG; 893 break; 894 } 895 szTmp[0] = ulDisk + 'A' - 1; 896 szTmp[1] = ':'; 897 } 912 898 if (cchTmp != 1 || iRoot <= 2) 913 899 memcpy(&szTmp[iRoot], pachBuffer, cchTmp + 1); … … 915 901 szTmp[iRoot] = '\0'; 916 902 cchTmp += iRoot; 917 918 fInUnixTree = 1;919 903 } 920 904 … … 962 946 else 963 947 { 948 949 950 951 964 952 pszPrev = &szTmp[iRoot + 1]; 965 953 psz = strchr(pszPrev, '/'); … … 968 956 /* If only one component, we'll check if the fVerifyLast was requested. */ 969 957 if ( !psz 970 && (fFlags & BACKFS_FLAGS_RESOLVE_FULL)958 && (fFlags & ) 971 959 && *pszPrev) 972 960 psz = strchr(szTmp, '\0'); … … 1014 1002 else 1015 1003 { 1016 if (!(fFlags & BACKFS_FLAGS_RESOLVE_FULL))1004 if (!(fFlags & )) 1017 1005 { 1018 1006 rcRet = 0; … … 1038 1026 * Find the correct name and to check if it is a directory or not. 1039 1027 * This'll of course also provide proper verification of the path too. :-) 1028 1029 1030 1040 1031 */ 1032 1041 1033 PFILEFINDBUF4 pFindBuf = (PFILEFINDBUF4)pachBuffer; 1042 1034 ULONG cFiles = 1; 1035 1036 1037 1043 1038 int rc = DosFindFirst((PCSZ)&szTmp[0], &hDir, FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM | FILE_DIRECTORY | FILE_ARCHIVED, 1044 1039 pFindBuf, SIZEOF_ACHBUFFER, &cFiles, FIL_QUERYEASIZE); 1040 1041 1045 1042 if (rc || cFiles == 0) 1046 1043 { 1047 LIBCLOG_MSG("DosFindFirst('%s',,,,,) -> %d resolving '%s'\n", szTmp, rc, pszUserPathIn); 1044 hDir = HDIR_CREATE; 1045 } 1046 while (!rc && cFiles == 1 && pFindBuf->cchName != psz - pszPrev) 1047 rc = DosFindNext(hDir, pFindBuf, SIZEOF_ACHBUFFER, &cFiles); 1048 if (rc || cFiles == 0) 1049 { 1050 LIBCLOG_MSG("DosFindFirst/Next('%s',,,,,) -> %d resolving '%s'\n", szTmp, rc, pszUserPathIn); 1048 1051 if ((fFlags & BACKFS_FLAGS_RESOLVE_FULL_MAYBE_) && !chSlash) 1052 1053 1049 1054 rcRet = 0; 1055 1050 1056 else 1051 1057 rcRet = rc == ERROR_FILE_NOT_FOUND && chSlash ? -ENOENT : -__libc_native2errno(rc); 1052 hDir = HDIR_CREATE;1053 1058 break; 1054 1059 } … … 1057 1062 1058 1063 /* 1059 * Try querying the symlink EA value .1064 * Try querying the symlink EA value 1060 1065 * (This operation will reuse the achBuffer overwriting the pFindBuf data!) 1061 1066 * … … 1065 1070 * is rather clumsily laid out. So, I decided not to try my luck on it. 1066 1071 */ 1067 if (pFindBuf->cbList > sizeof(USHORT) * 2 + 1) 1072 if ( pFindBuf->cbList > sizeof(USHORT) * 2 + 1 1073 && ( (fFlags & BACKFS_FLAGS_RESOLVE_FULL) 1074 || chSlash)) 1068 1075 { 1069 1076 EAOP2 EaOp; … … 1163 1170 else 1164 1171 { 1165 if (!(fFlags & BACKFS_FLAGS_RESOLVE_FULL))1172 if (!(fFlags & )) 1166 1173 { 1167 1174 rcRet = 0; … … 1201 1208 if (!*psz) 1202 1209 { 1203 if (!(fFlags & BACKFS_FLAGS_RESOLVE_FULL))1210 if (!(fFlags & )) 1204 1211 { 1205 1212 rcRet = 0; … … 1244 1251 pszUserPathIn = pszUserPathIn; 1245 1252 } 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1246 1305 1247 1306 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.
