- Timestamp:
- Aug 28, 2005, 8:19:49 AM (20 years ago)
- Location:
- trunk/src/emx
- Files:
-
- 3 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/ChangeLog.LIBC
-
Property cvs2svn:cvs-rev
changed from
1.131
to1.132
r2312 r2313 5 5 2005-08-28: knut st. osmundsen <bird-gccos2-spam@anduin.net> 6 6 - libc: 7 o Fixed lot's of unix attribute (in EA) handling. 8 o Started preparing for open() to work on directories so 9 fchdir() can be implemented and opendir reimplemented. 10 This will break libsocket backwards compatability. 7 11 o Added _hstrdup. 12 8 13 2005-08-27: knut st. osmundsen <bird-gccos2-spam@anduin.net> 9 14 - libc: -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/emx/io.h
-
Property cvs2svn:cvs-rev
changed from
1.18
to1.19
r2312 r2313 61 61 /** Type - Socket. */ 62 62 #define F_SOCKET 0x04000000 63 /** Type - Directory. */ 64 #define F_DIR 0x05000000 63 65 /* FD_CLOEXEC 0x10000000 (when shifted) */ 64 66 /** The shift for the file descriptor part of __LIBC_FH::fFlags. */ … … 333 335 enmFH_Socket43, 334 336 /** Socket handle (BSD 4.4 stack). */ 335 enmFH_Socket44 337 enmFH_Socket44, 338 /** Directory handle. */ 339 enmFH_Directory 336 340 } __LIBC_FHTYPE; 337 341 … … 482 486 * this file resides on. This might be NULL... */ 483 487 __LIBC_PFSINFO pFsInfo; 488 /** Pointer to the native path to this file as specified in the open call. 489 * This is required to read the unix attributes from EAs if the file isn't 490 * opened with exclusive access. */ 491 char *pszNativePath; 484 492 } __LIBC_FH; 485 493 /** Pointer to filehandle. */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/libc.def
-
Property cvs2svn:cvs-rev
changed from
1.137
to1.138
r2312 r2313 1946 1946 "___libc_Back_gfProcessHandleHashBangScripts" @1944 1947 1947 "___libc_Back_gfProcessHandlePCBatchScripts" @1945 1948 "__hstrdup" @1946 1949 "___libc_Back_dirOpenNative" @1947 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__dup.c
-
Property cvs2svn:cvs-rev
changed from
1.10
to1.11
r2312 r2313 8 8 #include <errno.h> 9 9 #include <emx/io.h> 10 #include <emx/umalloc.h> 11 #include <sys/fcntl.h> 10 12 #include <emx/syscalls.h> 11 #include <sys/fcntl.h>12 13 #include "syscalls.h" 13 14 #include "b_fs.h" … … 64 65 pFHNew->Dev = pFH->Dev; 65 66 pFHNew->pFsInfo = __libc_back_fsInfoObjAddRef(pFH->pFsInfo); 67 pFHNew->pszNativePath = _hstrdup(pFH->pszNativePath); 66 68 67 69 /* -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/__dup2.c
-
Property cvs2svn:cvs-rev
changed from
1.9
to1.10
r2312 r2313 6 6 #include <os2emx.h> 7 7 #include <errno.h> 8 #include <string.h> 9 #include <emx/umalloc.h> 8 10 #include <emx/syscalls.h> 9 11 #include <emx/io.h> … … 97 99 pFHNew->Dev = pFH->Dev; 98 100 pFHNew->pFsInfo = __libc_back_fsInfoObjAddRef(pFH->pFsInfo); 101 pFHNew->pszNativePath = _hstrdup(pFH->pszNativePath); 99 102 100 103 /* -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_fs.h
-
Property cvs2svn:cvs-rev
changed from
1.8
to1.9
r2312 r2313 48 48 extern mode_t __libc_gfsUMask; 49 49 50 51 /** @name Unix Attribute EA Names 52 * @{ */ 53 /** Symlink EA name. */ 54 #define EA_SYMLINK "SYMLINK" 55 /** File EA owner. */ 56 #define EA_UID "UID" 57 /** File EA group. */ 58 #define EA_GID "GID" 59 /** File EA mode. */ 60 #define EA_MODE "MODE" 61 /** File EA i-node number. */ 62 #define EA_INO "INO" 63 /** File EA rdev number. */ 64 #define EA_RDEV "RDEV" 65 /** File EA gen number. */ 66 #define EA_GEN "GEN" 67 /** File EA user flags. */ 68 #define EA_FLAGS "FLAGS" 69 /** @} */ 70 50 71 /** The minimum EA size of a file for it to possibly contain any LIBC Unix EAs. */ 51 #define LIBC_UNIX_EA_MIN (1 + 1 + 2 + sizeof("LIBC.???") + 2 + 2 + sizeof(uint32_t)) 52 72 #define LIBC_UNIX_EA_MIN (1 + 1 + 2 + sizeof("???") + 2 + 2 + sizeof(uint32_t)) 53 73 54 74 #ifdef _OS2EMX_H 75 76 /** 77 * The prefilled FEA2LIST construct for creating all unix attributes except symlink. 78 */ 79 #pragma pack(1) 80 extern const struct __LIBC_FSUNIXATTRIBSCREATEFEA2LIST 81 { 82 ULONG cbList; 83 84 ULONG offUID; 85 BYTE fUIDEA; 86 BYTE cbUIDName; 87 USHORT cbUIDValue; 88 CHAR szUIDName[sizeof(EA_UID)]; 89 USHORT usUIDType; 90 USHORT cbUIDData; 91 uint32_t u32UID; 92 CHAR achUIDAlign[((sizeof(EA_UID) + 4) & ~3) - sizeof(EA_UID)]; 93 94 ULONG offGID; 95 BYTE fGIDEA; 96 BYTE cbGIDName; 97 USHORT usGIDValue; 98 CHAR szGIDName[sizeof(EA_GID)]; 99 USHORT usGIDType; 100 USHORT cbGIDData; 101 uint32_t u32GID; 102 CHAR achGIDAlign[((sizeof(EA_GID) + 4) & ~3) - sizeof(EA_GID)]; 103 104 ULONG offMode; 105 BYTE fModeEA; 106 BYTE cbModeName; 107 USHORT usModeValue; 108 CHAR szModeName[sizeof(EA_MODE)]; 109 USHORT usModeType; 110 USHORT cbModeData; 111 uint32_t u32Mode; 112 CHAR achModeAlign[((sizeof(EA_MODE) + 4) & ~3) - sizeof(EA_MODE)]; 113 114 ULONG offINO; 115 BYTE fINOEA; 116 BYTE cbINOName; 117 USHORT usINOValue; 118 CHAR szINOName[sizeof(EA_INO)]; 119 USHORT usINOType; 120 USHORT cbINOData; 121 uint64_t u64INO; 122 CHAR achINOAlign[((sizeof(EA_INO) + 4) & ~3) - sizeof(EA_INO)]; 123 124 ULONG offRDev; 125 BYTE fRDevEA; 126 BYTE cbRDevName; 127 USHORT usRDevValue; 128 CHAR szRDevName[sizeof(EA_RDEV)]; 129 USHORT usRDevType; 130 USHORT cbRDevData; 131 uint32_t u32RDev; 132 CHAR achGDAlign[((sizeof(EA_RDEV) + 4) & ~3) - sizeof(EA_RDEV)]; 133 134 ULONG offGen; 135 BYTE fGenEA; 136 BYTE cbGenName; 137 USHORT usGenValue; 138 CHAR szGenName[sizeof(EA_GEN)]; 139 USHORT usGenType; 140 USHORT cbGenData; 141 uint32_t u32Gen; 142 CHAR achGenAlign[((sizeof(EA_GEN) + 4) & ~3) - sizeof(EA_GEN)]; 143 144 ULONG offFlags; 145 BYTE fFlagsEA; 146 BYTE cbFlagsName; 147 USHORT usFlagsValue; 148 CHAR szFlagsName[sizeof(EA_FLAGS)]; 149 USHORT usFlagsType; 150 USHORT cbFlagsData; 151 uint32_t u32Flags; 152 CHAR achFlagsAlign[((sizeof(EA_FLAGS) + 4) & ~3) - sizeof(EA_FLAGS)]; 153 154 } __libc_gFsUnixAttribsCreateFEA2List; 155 #pragma pack() 156 157 158 /** 159 * The prefilled GEA2LIST construct for querying all unix attributes. 160 */ 161 #pragma pack(1) 162 extern const struct __LIBC_BACK_FSUNIXATTRIBSGEA2LIST 163 { 164 ULONG cbList; 165 166 ULONG offSymlink; 167 BYTE cbSymlinkName; 168 CHAR szSymlinkName[((sizeof(EA_SYMLINK) + 4) & ~3) - 1]; 169 170 ULONG offUID; 171 BYTE cbUIDName; 172 CHAR szUIDName[((sizeof(EA_UID) + 4) & ~3) - 1]; 173 174 ULONG offGID; 175 BYTE cbGIDName; 176 CHAR szGIDName[((sizeof(EA_GID) + 4) & ~3) - 1]; 177 178 ULONG offMode; 179 BYTE cbModeName; 180 CHAR szModeName[((sizeof(EA_MODE) + 4) & ~3) - 1]; 181 182 ULONG offINO; 183 BYTE cbINOName; 184 CHAR szINOName[((sizeof(EA_INO) + 4) & ~3) - 1]; 185 186 ULONG offRDev; 187 BYTE cbRDevName; 188 CHAR szRDevName[((sizeof(EA_RDEV) + 4) & ~3) - 1]; 189 190 ULONG offGen; 191 BYTE cbGenName; 192 CHAR szGenName[((sizeof(EA_GEN) + 4) & ~3) - 1]; 193 194 ULONG offFlags; 195 BYTE cbFlagsName; 196 CHAR szFlagsName[((sizeof(EA_FLAGS) + 4) & ~3) - 1]; 197 } __libc_gFsUnixAttribsGEA2List; 198 #pragma pack() 199 200 55 201 /** @group Large File Support - API pointers. 56 202 * Test if the function pointer is set before calling it. … … 62 208 extern ULONG (* _System __libc_gpfnDosSetFileLocksL)(HFILE hFile, __const__ FILELOCKL *pflUnlock, __const__ FILELOCKL *pflLock, ULONG ulTimeout, ULONG flFlags); 63 209 /** @} */ 64 #endif 210 211 #endif /* _OS2EMX_H */ 65 212 66 213 /** … … 139 286 140 287 141 /** 142 * Creates the unix EAs for a new file or directory. 143 * 144 * @returns 0 on success. 145 * @returns Negative errno on failure. 146 * @param hFile File handle to the newly created fs object. If no 147 * handle handy, set to -1. 148 * @param pszNativePath Native path to the newly created fs object. 149 * @param mode The specified file permission mode mask. 150 * @param pDev Where to store the dev number. 151 * @param pInode Where to store the calculated inode number. 152 */ 153 int __libc_back_fsUnixAttribsSet(int hFile, const char *pszNativePath, mode_t mode, dev_t *pDev, ino_t *pInode); 288 #ifdef _OS2EMX_H 289 /** 290 * Initializes a unix attribute structure before creating a new inode. 291 * The call must have assigned default values to the the structure before doing this call! 292 * 293 * @returns Device number. 294 * @param pFEas The attribute structure to fill with actual values. 295 * @param pszNativePath The native path, used to calculate the inode number. 296 * @param Mode The correct mode (the caller have fixed this!). 297 */ 298 dev_t __libc_back_fsUnixAttribsInit(struct __LIBC_FSUNIXATTRIBSCREATEFEA2LIST *pFEas, char *pszNativePath, mode_t Mode); 299 #endif /* _OS2EMX_H */ 154 300 155 301 /** … … 172 318 * 173 319 * @returns 0 on success. 174 * @returns -1 and errnoon failure.320 * @returns Negative error code (errno.h) on failure. 175 321 * @param pszTarget The target of the symlink link. 176 322 * @param pszNativePath The path to the symbolic link to create. 177 */ 178 int __libc_back_fsNativeSymlinkCreate(const char *pszTarget, const char *pszNativePath); 323 * This is not 'const' because the unix attribute init routine may have to 324 * temporarily modify it to read the sticky bit from the parent directory. 325 */ 326 int __libc_back_fsNativeSymlinkCreate(const char *pszTarget, char *pszNativePath); 179 327 180 328 /** -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_fsDirCreate.c
-
Property cvs2svn:cvs-rev
changed from
1.7
to1.8
r2312 r2313 37 37 #include "syscalls.h" 38 38 #include <errno.h> 39 #include <sys/stat.h> 40 #include <InnoTekLIBC/libc.h> 39 41 #include <InnoTekLIBC/backend.h> 40 42 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_FS … … 60 62 char szNativePath[PATH_MAX]; 61 63 int rc = __libc_back_fsResolve(pszPath, BACKFS_FLAGS_RESOLVE_PARENT | BACKFS_FLAGS_RESOLVE_DIR, &szNativePath[0], NULL); 62 if ( rc)64 if (__predict_false(rc != 0)) 63 65 LIBCLOG_ERROR_RETURN_INT(rc); 66 67 /* 68 * Unix attributes. 69 */ 70 PEAOP2 pEaOp2 = NULL; 71 if (__predict_true(!__libc_gfNoUnix)) 72 { 73 Mode &= ~__libc_gfsUMask; 74 Mode &= S_IRWXG | S_IRWXO | S_IRWXU | S_ISUID | S_ISGID | S_ISTXT | S_ISVTX; 75 Mode |= S_IFDIR; 76 77 pEaOp2 = alloca(sizeof(EAOP2) + sizeof(__libc_gFsUnixAttribsCreateFEA2List)); 78 struct __LIBC_FSUNIXATTRIBSCREATEFEA2LIST *pFEas = (struct __LIBC_FSUNIXATTRIBSCREATEFEA2LIST *)(pEaOp2 + 1); 79 *pFEas = __libc_gFsUnixAttribsCreateFEA2List; 80 __libc_back_fsUnixAttribsInit(pFEas, szNativePath, Mode); 81 pEaOp2->fpGEA2List = NULL; 82 pEaOp2->fpFEA2List = (PFEA2LIST)pFEas; 83 pEaOp2->oError = 0; 84 } 64 85 65 86 /* … … 67 88 */ 68 89 FS_SAVE_LOAD(); 69 rc = DosCreateDir((PCSZ)&szNativePath[0], NULL); 90 rc = DosCreateDir((PCSZ)&szNativePath[0], pEaOp2); 91 if (__predict_false(rc == ERROR_EAS_NOT_SUPPORTED)) 92 rc = DosCreateDir((PCSZ)&szNativePath[0], NULL); 70 93 FS_RESTORE(); 71 if (!rc) 72 { 73 __libc_back_fsUnixAttribsSet(-1, &szNativePath[0], Mode, NULL, NULL); 94 if (__predict_true(!rc)) 74 95 LIBCLOG_RETURN_INT(0); 75 }76 96 77 97 /* -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_fsFileModeSetFH.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r2312 r2313 31 31 #include "libc-alias.h" 32 32 #define INCL_FSMACROS 33 #define INCL_ERRORS 33 34 #include <os2emx.h> 34 35 #include "b_fs.h" … … 65 66 */ 66 67 PLIBCFH pFH; 67 68 68 int rc = __libc_FHEx(fh, &pFH); 69 69 if (rc) … … 83 83 LIBCLOG_RETURN_INT(0); 84 84 85 /* use the path access. */ 86 case F_DIR: 87 if (__predict_false(!pFH->pszNativePath)) 88 LIBCLOG_ERROR_RETURN_INT(-EINVAL); 89 rc = __libc_back_fsNativeFileModeSet(pFH->pszNativePath, Mode); 90 if (rc) 91 LIBCLOG_ERROR_RETURN_INT(rc); 92 LIBCLOG_RETURN_INT(rc); 93 85 94 /* treat */ 86 95 default: … … 96 105 FS_VAR(); 97 106 FS_SAVE_LOAD(); 98 union 99 { 100 FILESTATUS4 fsts4; 101 FILESTATUS4L fsts4L; 102 } info; 103 #if OFF_MAX > LONG_MAX 104 int fLarge = 0; 105 #endif 106 107 /* 108 * Get file info. 109 * We have a little hack here, temporarily, write only files 110 * cannot read EAs. 111 */ 112 #if OFF_MAX > LONG_MAX 113 if (__libc_gpfnDosOpenL) 114 { 115 rc = DosQueryFileInfo(fh, FIL_QUERYEASIZEL, &info, sizeof(info.fsts4L)); 116 if (rc) 117 { 118 rc = DosQueryFileInfo(fh, FIL_STANDARDL, &info, sizeof(FILESTATUS3L)); 119 info.fsts4L.cbList = ~0; 120 } 121 fLarge = 1; 122 } 123 else 124 #endif 125 { 126 rc = DosQueryFileInfo(fh, FIL_QUERYEASIZE, &info, sizeof(info.fsts4)); 127 if (rc) 128 { 129 rc = DosQueryFileInfo(fh, FIL_STANDARD, &info, sizeof(FILESTATUS3)); 130 info.fsts4.cbList = ~0; 131 } 132 } 107 FILESTATUS3 fsts3; 108 109 /* 110 * Get file info, we don't need EA size nor large file sizes. 111 */ 112 rc = DosQueryFileInfo(fh, FIL_STANDARD, &fsts3, sizeof(FILESTATUS3)); 133 113 if (rc) 134 114 { … … 138 118 } 139 119 140 /* If in unix mode we'll check the EAs (if any). */ 141 if ( !__libc_gfNoUnix 142 && (fLarge ? info.fsts4L.cbList : info.fsts4.cbList) >= LIBC_UNIX_EA_MIN) 120 /* 121 * If in unix mode we'll have to update/add the MODE too. 122 */ 123 if (!__libc_gfNoUnix) 143 124 { 144 //__libc_back_fsUnixAttribsGet(fh, 0, pStat); 145 /* Update unix attributes */ 125 struct stat st = {0}; 126 rc = __libc_back_fsUnixAttribsGet(fh, pFH->pszNativePath, &st); 127 if (__predict_true(!rc)) 128 { 129 /* correct the passed in Mode mask. */ 130 Mode &= ALLPERMS; /** @todo sticky bit and set uid/gid access validation... */ 131 Mode |= st.st_mode & ~ALLPERMS; 132 133 /* construct FEA2 stuff. */ 134 #pragma pack(1) 135 struct __LIBC_FSUNIXATTRIBSSETMODE 136 { 137 ULONG cbList; 138 ULONG off; 139 BYTE fEA; 140 BYTE cbName; 141 USHORT cbValue; 142 CHAR szName[sizeof(EA_MODE)]; 143 USHORT usType; 144 USHORT cbData; 145 uint32_t u32Mode; 146 } EAs = 147 { 148 sizeof(EAs), 0, FEA_NEEDEA, sizeof(EA_MODE) - 1, sizeof(uint32_t) + 4, EA_MODE, EAT_BINARY, sizeof(uint32_t), Mode 149 }; 150 #pragma pack() 151 EAOP2 EaOp2; 152 EaOp2.fpGEA2List = NULL; 153 EaOp2.fpFEA2List = (PFEA2LIST)&EAs; 154 EaOp2.oError = 0; 155 156 /* finally, try update / add the EA. */ 157 rc = DosSetFileInfo(fh, FIL_QUERYEASIZE, &EaOp2, sizeof(EaOp2)); 158 if (__predict_false(rc != NO_ERROR)) 159 { 160 LIBCLOG_ERROR("DosSetFileInfo(%d,,,,) -> %d, oError=%#lx\n", fh, rc, EaOp2.oError); 161 if (rc != ERROR_EAS_NOT_SUPPORTED && pFH->pszNativePath) 162 { 163 EaOp2.oError = 0; 164 int rc2 = DosSetPathInfo((PCSZ)pFH->pszNativePath, FIL_QUERYEASIZE, &EaOp2, sizeof(EaOp2), 0); 165 if (rc2) 166 LIBCLOG_ERROR("DosSetPathInfo('%s',,,,) -> %d, oError=%#lx\n", pFH->pszNativePath, rc2, EaOp2.oError); 167 } 168 if (rc == ERROR_EAS_NOT_SUPPORTED) 169 rc = 0; 170 else 171 rc = -__libc_native2errno(rc); 172 } 173 } 174 else if (rc == -ENOTSUP) 175 rc = 0; 176 177 if (__predict_false(rc != 0)) 178 { 179 FS_RESTORE(); 180 LIBCLOG_ERROR_RETURN_INT(rc); 181 } 146 182 } 147 183 … … 149 185 * Update OS/2 bits. 150 186 */ 151 #if OFF_MAX > LONG_MAX 152 if (fLarge) 153 { 154 if (Mode & S_IWRITE) 155 info.fsts4L.attrFile &= ~FILE_READONLY; 156 else 157 info.fsts4L.attrFile = FILE_READONLY; 158 rc = DosSetFileInfo(fh, FIL_STANDARDL, &info, sizeof(info.fsts4L) - sizeof(info.fsts4L.cbList)); 159 } 187 if (Mode & S_IWRITE) 188 fsts3.attrFile &= ~FILE_READONLY; 160 189 else 161 #endif 162 { 163 if (Mode & S_IWRITE) 164 info.fsts4.attrFile &= ~FILE_READONLY; 165 else 166 info.fsts4.attrFile |= FILE_READONLY; 167 rc = DosSetFileInfo(fh, FIL_STANDARD, &info, sizeof(info.fsts4) - sizeof(info.fsts4.cbList)); 168 } 190 fsts3.attrFile |= FILE_READONLY; 191 rc = DosSetFileInfo(fh, FIL_STANDARD, &fsts3, sizeof(fsts3)); 169 192 FS_RESTORE(); 170 193 if (rc) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_fsFileStatFH.c
-
Property cvs2svn:cvs-rev
changed from
1.8
to1.9
r2312 r2313 68 68 69 69 int rc = __libc_FHEx(fh, &pFH); 70 if ( !pFH)70 if (rc) 71 71 LIBCLOG_ERROR_RETURN_INT(rc); 72 72 73 if ( !pFH->pOps)73 if (/*!pFH->pOps*/ 1) 74 74 { 75 75 /* 76 * Standard OS/2 file handle.77 *78 76 * Use query handle type to figure out the file type. 79 77 */ 80 78 bzero(pStat, sizeof(*pStat)); 81 switch (pFH->fFlags & __LIBC_FH_TYPEMASK)82 {83 case F_DEV: pStat->st_mode = S_IFCHR; break;84 case F_SOCKET: pStat->st_mode = S_IFSOCK; break;85 /** @todo needs to check if it's a named pipe or not. */86 /* Anonymous pipes are AF_UNIX sockets on (some?) unix systems. */87 case F_PIPE: pStat->st_mode = S_IFSOCK; break;88 default:89 case F_FILE: pStat->st_mode = S_IFREG; break;90 }91 92 79 /* fake unix stuff */ 93 pStat->st_uid = 0;94 pStat->st_gid = 0;80 //pStat->st_uid = 0; 81 //pStat->st_gid = 0; 95 82 pStat->st_ino = pFH->Inode; 96 83 pStat->st_dev = pFH->Dev; 97 pStat->st_rdev = 0;84 //pStat->st_rdev = 0; 98 85 pStat->st_nlink = 1; 99 86 pStat->st_blksize = 4096*12; /* 48KB */ 100 87 101 FS_VAR(); 102 FS_SAVE_LOAD(); 103 if (pStat->st_mode == S_IFREG) 88 if ((pFH->fFlags & __LIBC_FH_TYPEMASK) == F_FILE) 104 89 { 90 /* 91 * Regular OS/2 file. 92 */ 105 93 union 106 94 { … … 111 99 int fLarge = 0; 112 100 #endif 101 pStat->st_mode = S_IFREG; 113 102 114 103 /* … … 117 106 * cannot read EAs. 118 107 */ 108 FS_VAR_SAVE_LOAD(); 119 109 #if OFF_MAX > LONG_MAX 120 110 if (__libc_gpfnDosOpenL) … … 138 128 } 139 129 } 130 FS_RESTORE(); 140 131 if (rc) 141 132 { 142 FS_RESTORE();143 133 rc = -__libc_native2errno(rc); 144 134 LIBCLOG_ERROR_RETURN_INT(rc); … … 180 170 pStat->st_attr = rc; 181 171 if (rc & FILE_READONLY) 182 pStat->st_mode |= (S_IREAD >> 6) * 0111;183 else 184 pStat->st_mode |= ((S_IREAD|S_IWRITE) >> 6) * 0111;172 pStat->st_mode |= S_IROTH | S_IRGRP | S_IRUSR; 173 else 174 pStat->st_mode |= S_IROTH | S_IRGRP | S_IRUSR | S_IWOTH | S_IWGRP | S_IWUSR; 185 175 186 176 /* If in unix mode we'll check the EAs (if any). */ 187 177 if ( !__libc_gfNoUnix 188 178 && (fLarge ? info.fsts4L.cbList : info.fsts4.cbList) >= LIBC_UNIX_EA_MIN) 189 __libc_back_fsUnixAttribsGet(fh, 0, pStat);179 __libc_back_fsUnixAttribsGet(fh, pFH->pszNativePath, pStat); 190 180 } 191 181 else 192 182 { 183 /* 184 * Use the native path if we've got it. 185 */ 186 if (pFH->pszNativePath) 187 { 188 struct stat st; 189 rc = __libc_back_fsNativeFileStat(pFH->pszNativePath, &st); 190 if (!rc) 191 { 192 *pStat = st; 193 LIBCLOG_RETURN_INT(0); 194 } 195 } 196 197 /* 198 * Ok, try fake something plausible from the handle data. 199 */ 193 200 if ((pFH->fFlags & O_ACCMODE) == O_RDONLY) 194 pStat->st_mode |= (S_IREAD >> 6) * 0111; 195 else 196 pStat->st_mode |= ((S_IREAD|S_IWRITE) >> 6) * 0111; 201 pStat->st_mode = S_IROTH | S_IRGRP | S_IRUSR; 202 else 203 pStat->st_mode = S_IROTH | S_IRGRP | S_IRUSR | S_IWOTH | S_IWGRP | S_IWUSR; 204 205 switch (pFH->fFlags & __LIBC_FH_TYPEMASK) 206 { 207 case F_DEV: 208 pStat->st_mode = S_IFCHR; 209 pStat->st_rdev = pFH->Inode; 210 break; 211 case F_SOCKET: 212 pStat->st_mode |= S_IFSOCK | S_IXUSR | S_IXGRP | S_IXOTH; 213 break; 214 case F_PIPE: 215 pStat->st_mode |= S_IFIFO; 216 pStat->st_mode &= ~(S_IRWXO | S_IRWXG); 217 break; 218 case F_DIR: 219 pStat->st_mode |= S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH; 220 break; 221 default: 222 LIBC_ASSERTM_FAILED("Unknown handle type %#x\n", pFH->fFlags & __LIBC_FH_TYPEMASK); 223 pStat->st_mode |= S_IFREG; 224 break; 225 } 197 226 } 198 199 FS_RESTORE();200 227 } 201 else 202 { 203 /* 204 * Non-standard handle - fail. 205 */ 206 LIBCLOG_ERROR_RETURN_INT(-EOPNOTSUPP); 207 } 228 //else 229 //{ 230 // rc = pFH->pOps->pfnStat(pFH, fh, pStat); 231 // if (rc) 232 // { 233 // if (rc > 0) 234 // rc = -__libc_native2errno(rc); 235 // LIBCLOG_ERROR_RETURN_INT(rc); 236 // } 237 //} 208 238 209 239 LIBCLOG_MSG("st_dev: %#x\n", pStat->st_dev); 210 LIBCLOG_MSG("st_ino: %# llx\n",pStat->st_ino);211 LIBCLOG_MSG("st_mode: %#x\n", pStat->st_mode);240 LIBCLOG_MSG("st_ino: %#018llx\n",pStat->st_ino); 241 LIBCLOG_MSG("st_mode: 0%o\n", pStat->st_mode); 212 242 LIBCLOG_MSG("st_nlink: %u\n", pStat->st_nlink); 213 243 LIBCLOG_MSG("st_uid: %u\n", pStat->st_uid); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_fsFileTimesSetFH.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r2312 r2313 88 88 LIBCLOG_RETURN_INT(0); 89 89 90 /* use the path access. */ 91 case F_DIR: 92 if (__predict_false(!pFH->pszNativePath)) 93 LIBCLOG_ERROR_RETURN_INT(-EINVAL); 94 rc = __libc_back_fsNativeFileTimesSet(pFH->pszNativePath, paTimes); 95 if (rc) 96 LIBCLOG_ERROR_RETURN_INT(rc); 97 LIBCLOG_RETURN_INT(rc); 98 90 99 /* treat */ 91 100 default: … … 122 131 FS_VAR(); 123 132 FS_SAVE_LOAD(); 124 union 125 { 126 FILESTATUS3 fsts3; 127 FILESTATUS3L fsts3L; 128 } info; 129 #if OFF_MAX > LONG_MAX 130 int fLarge = 0; 131 #endif 133 FILESTATUS3 fsts3; 132 134 133 135 /* 134 136 * Get file info. 135 * We have a little hack here, temporarily, write only files136 * cannot read EAs.137 137 */ 138 #if OFF_MAX > LONG_MAX 139 if (__libc_gpfnDosOpenL) 140 { 141 rc = DosQueryFileInfo(fh, FIL_STANDARDL, &info, sizeof(info.fsts3L)); 142 fLarge = 1; 143 } 144 else 145 #endif 146 rc = DosQueryFileInfo(fh, FIL_STANDARD, &info, sizeof(info.fsts3)); 138 rc = DosQueryFileInfo(fh, FIL_STANDARD, &fsts3, sizeof(fsts3)); 147 139 if (rc) 148 140 { … … 155 147 * Update OS/2 bits. 156 148 */ 157 #if OFF_MAX > LONG_MAX 158 if (fLarge) 149 __libc_back_timeUnix2FileTime(aTimes[0], &fsts3.ftimeLastAccess, &fsts3.fdateLastAccess); 150 __libc_back_timeUnix2FileTime(aTimes[1], &fsts3.ftimeLastWrite, &fsts3.fdateLastWrite); 151 rc = DosSetFileInfo(fh, FIL_STANDARD, &fsts3, sizeof(fsts3)); 152 if (rc && pFH->pszNativePath) 159 153 { 160 __libc_back_timeUnix2FileTime(aTimes[0], &info.fsts3L.ftimeLastAccess, &info.fsts3L.fdateLastAccess); 161 __libc_back_timeUnix2FileTime(aTimes[1], &info.fsts3L.ftimeLastWrite, &info.fsts3L.fdateLastWrite); 162 rc = DosSetFileInfo(fh, FIL_STANDARDL, &info, sizeof(info.fsts3L)); 163 } 164 else 165 #endif 166 { 167 __libc_back_timeUnix2FileTime(aTimes[0], &info.fsts3.ftimeLastAccess, &info.fsts3.fdateLastAccess); 168 __libc_back_timeUnix2FileTime(aTimes[1], &info.fsts3.ftimeLastWrite, &info.fsts3.fdateLastWrite); 169 rc = DosSetFileInfo(fh, FIL_STANDARD, &info, sizeof(info.fsts3)); 154 LIBCLOG_ERROR("DosSetFileInfo(%d,,,) -> %d\n", fh, rc); 155 rc = DosSetPathInfo((PCSZ)pFH->pszNativePath, FIL_STANDARD, &fsts3, sizeof(fsts3), 0); 156 if (rc) 157 LIBCLOG_ERROR("DosSetPathInfo('%s',,,) -> %d\n", pFH->pszNativePath, rc); 170 158 } 171 159 FS_RESTORE(); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_fsNativeFileModeSet.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r2312 r2313 110 110 #endif 111 111 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_STANDARD, &info, sizeof(info.fsts4) - sizeof(info.fsts4.cbList)); 112 info.fsts4L.cbList = 0;112 info.fsts4L.cbList = LIBC_UNIX_EA_MIN; 113 113 } 114 114 if (rc) … … 117 117 FS_RESTORE(); 118 118 LIBCLOG_ERROR_RETURN_INT(rc); 119 }120 121 /* If in unix mode we'll get the EAs (if any). */122 rc = -1;123 if ( !__libc_gfNoUnix124 && (fLarge ? info.fsts4L.cbList : info.fsts4.cbList) >= LIBC_UNIX_EA_MIN125 /*&& __libc_back_fsUnixAttribsGet(-1, pszNativePath, pStat) == 0*/)126 {127 /* Update unix attributes. */128 119 } 129 120 … … 149 140 rc = DosSetPathInfo((PCSZ)pszNativePath, FIL_STANDARD, &info, sizeof(info.fsts4) - sizeof(info.fsts4.cbList), 0); 150 141 } 151 142 if (__predict_false(rc != NO_ERROR)) 143 { 144 FS_RESTORE(); 145 rc = -__libc_native2errno(rc); 146 LIBCLOG_ERROR_RETURN_INT(rc); 147 } 148 149 /* 150 * If in unix mode we'll have to update/add the MODE too. 151 */ 152 if (!__libc_gfNoUnix) 153 { 154 struct stat st = {0}; 155 rc = __libc_back_fsUnixAttribsGet(-1, pszNativePath, &st); 156 if (__predict_true(!rc)) 157 { 158 /* correct the passed in Mode mask. */ 159 Mode &= ALLPERMS; /** @todo sticky bit and set uid/gid access validation... */ 160 Mode |= st.st_mode & ~ALLPERMS; 161 162 /* construct FEA2 stuff. */ 163 #pragma pack(1) 164 struct __LIBC_FSUNIXATTRIBSSETMODE 165 { 166 ULONG cbList; 167 ULONG off; 168 BYTE fEA; 169 BYTE cbName; 170 USHORT cbValue; 171 CHAR szName[sizeof(EA_MODE)]; 172 USHORT usType; 173 USHORT cbData; 174 uint32_t u32Mode; 175 } EAs = 176 { 177 sizeof(EAs), 0, FEA_NEEDEA, sizeof(EA_MODE) - 1, sizeof(uint32_t) + 4, EA_MODE, EAT_BINARY, sizeof(uint32_t), Mode 178 }; 179 #pragma pack() 180 EAOP2 EaOp2; 181 EaOp2.fpGEA2List = NULL; 182 EaOp2.fpFEA2List = (PFEA2LIST)&EAs; 183 EaOp2.oError = 0; 184 185 /* finally, try update / add the EA. */ 186 rc = DosSetPathInfo((PCSZ)pszNativePath, FIL_QUERYEASIZE, &EaOp2, sizeof(EaOp2), 0); 187 if (__predict_false(rc != NO_ERROR)) 188 { 189 LIBCLOG_ERROR("DosSetPathInfo('%s',,,,) -> %d, oError=%#lx\n", pszNativePath, rc, EaOp2.oError); 190 if (rc == ERROR_EAS_NOT_SUPPORTED) 191 rc = 0; 192 else 193 rc = -__libc_native2errno(rc); 194 } 195 } 196 else if (rc == -ENOTSUP) 197 rc = 0; 198 199 if (__predict_false(rc != 0)) 200 { 201 FS_RESTORE(); 202 LIBCLOG_ERROR_RETURN_INT(rc); 203 } 204 } 152 205 FS_RESTORE(); 153 if (!rc) 154 LIBCLOG_RETURN_INT(rc); 155 rc = -__libc_native2errno(rc); 156 LIBCLOG_ERROR_RETURN_INT(rc); 206 207 LIBCLOG_RETURN_INT(0); 157 208 } 158 209 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_fsNativeFileStat.c
-
Property cvs2svn:cvs-rev
changed from
1.9
to1.10
r2312 r2313 112 112 #endif 113 113 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_STANDARD, &info, sizeof(info.fsts4) - sizeof(info.fsts4.cbList)); 114 info.fsts4L.cbList = 0;114 info.fsts4L.cbList = LIBC_UNIX_EA_MIN; 115 115 } 116 116 FS_RESTORE(); … … 146 146 #endif 147 147 pStat->st_attr = fAttributtes; 148 #if OFF_MAX > LONG_MAX 149 if (fLarge) 150 { 151 pStat->st_size = info.fsts4L.cbFile; 152 pStat->st_blocks = info.fsts4L.cbFileAlloc / S_BLKSIZE; 153 } 154 else 155 #endif 156 { 157 pStat->st_size = info.fsts4.cbFile; 158 pStat->st_blocks = info.fsts4.cbFileAlloc / S_BLKSIZE; 159 } 148 160 if (fAttributtes & FILE_DIRECTORY) 149 161 { 150 162 /* directory */ 151 pStat->st_mode = S_IFDIR; 152 pStat->st_mode |= ((S_IREAD|S_IWRITE|S_IEXEC) >> 6) * 0111; 153 pStat->st_size = 0; 154 } 155 else 156 { 157 #if OFF_MAX > LONG_MAX 158 if (fLarge) 159 { 160 pStat->st_size = info.fsts4L.cbFile; 161 pStat->st_blocks = info.fsts4L.cbFileAlloc / S_BLKSIZE; 162 } 163 else 164 #endif 165 { 166 pStat->st_size = info.fsts4.cbFile; 167 pStat->st_blocks = info.fsts4.cbFileAlloc / S_BLKSIZE; 168 } 163 pStat->st_mode = S_IFDIR | S_IRWXO | S_IRWXG | S_IRWXU; 164 } 165 else 166 { 169 167 pStat->st_mode = S_IFREG; 170 168 if (rc & FILE_READONLY) … … 193 191 pStat->st_uid = 0; 194 192 pStat->st_gid = 0; 195 pStat->st_dev = __libc_back_fsPathCalcInodeAndDev(pszNativePath, &pStat->st_ino); 193 pStat->st_dev = 0; 194 pStat->st_ino = 0; 196 195 pStat->st_rdev = 0; 197 196 pStat->st_nlink = 1; 198 197 pStat->st_blksize = 4096 * 12; /* 48kb */ 199 198 /* If in unix mode we'll check the EAs (if any). */ 199 rc = 1; 200 200 if ( !__libc_gfNoUnix 201 201 && (fLarge ? info.fsts4L.cbList : info.fsts4.cbList) >= LIBC_UNIX_EA_MIN) 202 __libc_back_fsUnixAttribsGet(-1, pszNativePath, pStat); 202 rc = __libc_back_fsUnixAttribsGet(-1, pszNativePath, pStat); 203 if (rc) 204 pStat->st_dev = __libc_back_fsPathCalcInodeAndDev(pszNativePath, &pStat->st_ino); 203 205 204 206 LIBCLOG_MSG("st_dev: %#x\n", pStat->st_dev); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_fsNativeFileTimesSet.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r2312 r2313 64 64 paTimes ? paTimes[0].tv_sec : ~0, paTimes ? paTimes[0].tv_usec : ~0, 65 65 paTimes ? paTimes[1].tv_sec : ~0, paTimes ? paTimes[1].tv_usec : ~0); 66 union 67 { 68 FILESTATUS3 fsts3; 69 FILESTATUS3L fsts3L; 70 } info; 71 #if OFF_MAX > LONG_MAX 72 int fLarge = 0; 73 #endif 66 FILESTATUS3 fsts3; 74 67 FS_VAR(); 75 68 … … 116 109 */ 117 110 FS_SAVE_LOAD(); 118 int rc; 119 #if OFF_MAX > LONG_MAX 120 if (__libc_gpfnDosOpenL) 121 { 122 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_STANDARDL, &info, sizeof(info.fsts3L)); 123 fLarge = 1; 124 } 125 else 126 #endif 127 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_STANDARD, &info, sizeof(info.fsts3)); 111 int rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_STANDARD, &fsts3, sizeof(fsts3)); 128 112 if (rc) 129 113 { … … 136 120 * Update OS/2 attributes. 137 121 */ 138 #if OFF_MAX > LONG_MAX 139 if (fLarge) 140 { 141 __libc_back_timeUnix2FileTime(aTimes[0], &info.fsts3L.ftimeLastAccess, &info.fsts3L.fdateLastAccess); 142 __libc_back_timeUnix2FileTime(aTimes[1], &info.fsts3L.ftimeLastWrite, &info.fsts3L.fdateLastWrite); 143 rc = DosSetPathInfo((PCSZ)pszNativePath, FIL_STANDARDL, &info, sizeof(info.fsts3L), 0); 144 } 145 else 146 #endif 147 { 148 __libc_back_timeUnix2FileTime(aTimes[0], &info.fsts3.ftimeLastAccess, &info.fsts3.fdateLastAccess); 149 __libc_back_timeUnix2FileTime(aTimes[1], &info.fsts3.ftimeLastWrite, &info.fsts3.fdateLastWrite); 150 rc = DosSetPathInfo((PCSZ)pszNativePath, FIL_STANDARD, &info, sizeof(info.fsts3), 0); 151 } 152 122 __libc_back_timeUnix2FileTime(aTimes[0], &fsts3.ftimeLastAccess, &fsts3.fdateLastAccess); 123 __libc_back_timeUnix2FileTime(aTimes[1], &fsts3.ftimeLastWrite, &fsts3.fdateLastWrite); 124 rc = DosSetPathInfo((PCSZ)pszNativePath, FIL_STANDARD, &fsts3, sizeof(fsts3), 0); 153 125 FS_RESTORE(); 154 126 if (!rc) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_ioFileOpen.c
-
Property cvs2svn:cvs-rev
changed from
1.9
to1.10
r2312 r2313 4 4 * LIBC SYS Backend - open. 5 5 * 6 * Copyright (c) 2003-200 4knut st. osmundsen <bird@innotek.de>6 * Copyright (c) 2003-2005 knut st. osmundsen <bird@innotek.de> 7 7 * Copyright (c) 1992-1996 by Eberhard Mattes 8 8 * … … 35 35 #include <os2emx.h> 36 36 #include "b_fs.h" 37 #include "b_dir.h" 37 38 #include <string.h> 38 39 #include <errno.h> … … 40 41 #include <share.h> 41 42 #include <sys/stat.h> 43 #include <emx/umalloc.h> 42 44 #include <emx/syscalls.h> 43 45 #include <emx/io.h> … … 128 130 * Resolve the specified file path. 129 131 */ 130 char szNativePath[PATH_MAX ];132 char szNativePath[PATH_MAX + 5]; 131 133 int rc = __libc_back_fsResolve(pszFile, 132 134 (flOpenFlags & OPEN_ACTION_FAIL_IF_NEW 133 ? BACKFS_FLAGS_RESOLVE_FULL 134 : BACKFS_FLAGS_RESOLVE_FULL_MAYBE ),135 ? BACKFS_FLAGS_RESOLVE_FULL | BACKFS_FLAGS_RESOLVE_DIR_MAYBE 136 : BACKFS_FLAGS_RESOLVE_FULL_MAYBE | BACKFS_FLAGS_RESOLVE_DIR_MAYBE), 135 137 &szNativePath[0], 136 138 NULL); … … 138 140 LIBCLOG_ERROR_RETURN_INT(rc); 139 141 142 /* 143 * Create Unix attributes for a new file. 144 */ 145 dev_t Dev = 0; 146 ino_t Inode = 0; 147 PEAOP2 pEaOp2 = NULL; 148 if ( (flOpenFlags & (OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS)) 149 && !__libc_gfNoUnix) 150 { 151 Mode &= ~__libc_gfsUMask; 152 Mode &= S_IRWXG | S_IRWXO | S_IRWXU | S_ISUID | S_ISGID | S_ISTXT | S_ISVTX; 153 Mode |= S_IFREG; 154 155 pEaOp2 = alloca(sizeof(EAOP2) + sizeof(__libc_gFsUnixAttribsCreateFEA2List)); 156 struct __LIBC_FSUNIXATTRIBSCREATEFEA2LIST *pFEas = (struct __LIBC_FSUNIXATTRIBSCREATEFEA2LIST *)(pEaOp2 + 1); 157 *pFEas = __libc_gFsUnixAttribsCreateFEA2List; 158 Dev = __libc_back_fsUnixAttribsInit(pFEas, szNativePath, Mode); 159 Inode = pFEas->u64INO; 160 pEaOp2->fpGEA2List = NULL; 161 pEaOp2->fpFEA2List = (PFEA2LIST)pFEas; 162 pEaOp2->oError = 0; 163 } 140 164 141 165 /* … … 152 176 { 153 177 LONGLONG cbInitialTmp = cbInitial; 154 rc = __libc_gpfnDosOpenL((PCSZ)&szNativePath[0], &hFile, &ulAction, cbInitialTmp, flAttr, flOpenFlags, flOpenMode, NULL);178 rc = __libc_gpfnDosOpenL((PCSZ)&szNativePath[0], &hFile, &ulAction, cbInitialTmp, flAttr, flOpenFlags, flOpenMode, pEaOp2); 155 179 } 156 180 else … … 162 186 LIBCLOG_ERROR_RETURN_INT(-EOVERFLOW); 163 187 } 164 rc = DosOpen((PCSZ)&szNativePath[0], &hFile, &ulAction, cbInitialTmp, flAttr, flOpenFlags, flOpenMode, NULL);188 rc = DosOpen((PCSZ)&szNativePath[0], &hFile, &ulAction, cbInitialTmp, flAttr, flOpenFlags, flOpenMode, pEaOp2); 165 189 } 166 190 #else 167 191 { 168 192 ULONG cbInitialTmp = cbInitial; 169 rc = DosOpen((PCSZ)&szNativePath[0], &hFile, &ulAction, cbInitialTmp, flAttr, flOpenFlags, flOpenMode, NULL);193 rc = DosOpen((PCSZ)&szNativePath[0], &hFile, &ulAction, cbInitialTmp, flAttr, flOpenFlags, flOpenMode, pEaOp2); 170 194 } 171 195 #endif 196 /* Check for EA errors. */ 197 if (pEaOp2 && rc == ERROR_EAS_NOT_SUPPORTED) 198 { 199 pEaOp2 = NULL; 200 continue; 201 } 202 172 203 /* Check if we're out of handles. */ 173 204 if (rc != ERROR_TOO_MANY_OPEN_FILES) … … 189 220 if (!rc) 190 221 { 191 dev_t Dev;192 ino_t Inode;193 222 switch (fulType & 0xff) 194 223 { … … 197 226 fLibc |= F_FILE; 198 227 /* If a new file the unix EAs needs to be established. */ 199 if ( (ulAction == FILE_CREATED) 200 && !__libc_gfNoUnix) 201 __libc_back_fsUnixAttribsSet(hFile, szNativePath, Mode, &Dev, &Inode); 202 else 228 if ( !pEaOp2 229 || (ulAction != FILE_CREATED && ulAction != FILE_TRUNCATED)) /** @todo validate that FILE_TRUNCATED will have replaced EAs. */ 203 230 Dev = __libc_back_fsPathCalcInodeAndDev(szNativePath, &Inode); 204 231 break; … … 226 253 /* 227 254 * Register the handle and calc Dev and Inode. 228 * We calc the Dev/Inode regardless of whether it's stored in an EA or not.229 255 */ 230 rc = __libc_FHAllocate(hFile, fLibc, sizeof(LIBCFH), NULL, ppFH, NULL); 256 __LIBC_PFH pFH; 257 rc = __libc_FHAllocate(hFile, fLibc, sizeof(LIBCFH), NULL, &pFH, NULL); 231 258 if (!rc) 232 259 { 260 pFH->Inode = Inode; 261 pFH->Dev = Dev; 262 pFH->pFsInfo = __libc_back_fsInfoObjByDev(Dev); 263 pFH->pszNativePath = _hstrdup(szNativePath); 264 233 265 if (ppFH) 234 { 235 (*ppFH)->Inode = Inode; 236 (*ppFH)->Dev = Dev; 237 (*ppFH)->pFsInfo = __libc_back_fsInfoObjByDev(Dev); 238 } 239 LIBCLOG_MSG("hFile=%#lx fLibc=%#x fulType=%#lx ulAction=%lu Dev=%#x Inode=%#llx\n", 240 hFile, fLibc, fulType, ulAction, Dev, Inode); 266 *ppFH = pFH; 267 LIBCLOG_MSG("pFH=%p hFile=%#lx fLibc=%#x fulType=%#lx ulAction=%lu Dev=%#x Inode=%#llx\n", 268 (void *)pFH, hFile, fLibc, fulType, ulAction, Dev, Inode); 241 269 } 242 270 } 243 271 244 if ( rc)272 if (__predict_false(rc != NO_ERROR)) 245 273 DosClose(hFile); 246 274 } 275 #if 0 /** @todo Try open directories. */ 276 else if ( rc == ERROR_??? 277 && (fFlags & ...) == ... 278 ) 279 { 280 /* 281 * Try open directory. 282 */ 283 rc = __libc_Back_dirOpenNative(szNativePath, fLibc); 284 FS_RESTORE(); 285 LIBCLOG_RETURN_INT(rc); 286 } 287 #endif 247 288 FS_RESTORE(); 248 289 … … 250 291 * Handle any errors. 251 292 */ 252 if ( rc)293 if (__predict_false(rc != NO_ERROR)) 253 294 { 254 295 if (rc == ERROR_OPEN_FAILED) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/filehandles.c
-
Property cvs2svn:cvs-rev
changed from
1.23
to1.24
r2312 r2313 196 196 pFH->Dev = u.pStds->aHandles[i].Dev; 197 197 pFH->pFsInfo = __libc_back_fsInfoObjByDev(pFH->Dev); 198 pFH->pszNativePath = NULL; 198 199 } 199 200 u.pv = &u.pStds->aHandles[c]; … … 763 764 pFH->Dev = 0; 764 765 pFH->pFsInfo = NULL; 766 pFH->pszNativePath = NULL; 765 767 766 768 /* … … 882 884 * @param cb Size of the file handle. 883 885 * Must not be less than the mandatory size (sizeof(LIBCFH)). 884 * @param pOps Value of the pOps field , NULL not allowed.886 * @param pOps Value of the pOps field. 885 887 * @param ppFH Where to store the allocated file handle struct pointer. (NULL allowed) 886 888 * @param pfh Where to store the number of the filehandle allocated. -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/fs.c
-
Property cvs2svn:cvs-rev
changed from
1.22
to1.23
r2312 r2313 4 4 * LIBC SYS Backend - file system stuff. 5 5 * 6 * Copyright (c) 2004 knut st. osmundsen <bird@innotek.de>6 * Copyright (c) 2004-2005 knut st. osmundsen <bird@innotek.de> 7 7 * 8 8 * … … 42 42 #include <sys/stat.h> 43 43 #include <sys/fmutex.h> 44 #include <sys/smutex.h> 44 45 #include <emx/startup.h> 45 46 #include "syscalls.h" … … 74 75 int __libc_gcchUnixRoot = 0; 75 76 /** The current unix root. */ 76 char __libc_gszUnixRoot[PATH_MAX] ;77 char __libc_gszUnixRoot[PATH_MAX] = ""; 77 78 /** The umask of the process. */ 78 79 mode_t __libc_gfsUMask = 022; … … 83 84 ULONG (* _System __libc_gpfnDosSetFileSizeL)(HFILE hFile, LONGLONG cbSize) = NULL; 84 85 ULONG (* _System __libc_gpfnDosSetFileLocksL)(HFILE hFile, __const__ FILELOCKL *pflUnlock, __const__ FILELOCKL *pflLock, ULONG ulTimeout, ULONG flFlags) = NULL; 85 86 /** Symlink EA name. */87 #define EA_SYMLINK "SYMLINK"88 /** File EA owner. */89 #define EA_UID "UID"90 /** File EA group. */91 #define EA_GID "GID"92 /** File EA mode. */93 #define EA_MODE "MODE"94 /** File EA i-node number. */95 #define EA_INO "INO"96 /** File EA rdev number. */97 #define EA_RDEV "RDEV"98 /** File EA gen number. */99 #define EA_GEN "GEN"100 86 101 87 /** Symlink EA name. */ … … 113 99 /** Gen(eration) EA name. */ 114 100 static const char __libc_gszGenEA[] = EA_GEN; 115 116 /* GEA2LIST Structure, just a bit more conveniently laid out.. */ 101 /** User flags EA name. */ 102 static const char __libc_gszFlagsEA[] = EA_FLAGS; 103 104 /** 105 * The prefilled GEA2LIST construct for querying a symlink. 106 */ 107 #pragma pack(1) 117 108 static const struct 118 109 { … … 128 119 EA_SYMLINK 129 120 }; 130 131 /* GEA2LIST Structures, just a bit more conveniently laid out.. */ 132 static const struct GEA2LISTUNIXATTRIBS 133 { 134 ULONG cbList; 135 136 ULONG offSymlink; 137 BYTE cbSymlinkName; 138 CHAR szSymlinkName[sizeof(EA_SYMLINK)]; 139 140 ULONG offUID; 141 BYTE cbUIDName; 142 CHAR szUIDName[sizeof(EA_UID)]; 143 144 ULONG offGID; 145 BYTE cbGIDName; 146 CHAR szGIDName[sizeof(EA_GID)]; 147 148 ULONG offMode; 149 BYTE cbModeName; 150 CHAR szModeName[sizeof(EA_MODE)]; 151 152 ULONG offINO; 153 BYTE cbINOName; 154 CHAR szINOName[sizeof(EA_INO)]; 155 156 ULONG offRDev; 157 BYTE cbRDevName; 158 CHAR szRDevName[sizeof(EA_RDEV)]; 159 160 ULONG offGen; 161 BYTE cbGenName; 162 CHAR szGenName[sizeof(EA_GEN)]; 163 } gGEA2ListUnixAttribs = 164 { 165 sizeof(gGEA2ListUnixAttribs), 166 offsetof(struct GEA2LISTUNIXATTRIBS, offUID) - offsetof(struct GEA2LISTUNIXATTRIBS, offSymlink), sizeof(EA_SYMLINK) - 1, EA_SYMLINK, 167 offsetof(struct GEA2LISTUNIXATTRIBS, offGID) - offsetof(struct GEA2LISTUNIXATTRIBS, offUID), sizeof(EA_UID) - 1, EA_UID, 168 offsetof(struct GEA2LISTUNIXATTRIBS, offMode) - offsetof(struct GEA2LISTUNIXATTRIBS, offGID), sizeof(EA_GID) - 1, EA_GID, 169 offsetof(struct GEA2LISTUNIXATTRIBS, offINO) - offsetof(struct GEA2LISTUNIXATTRIBS, offMode), sizeof(EA_MODE) - 1, EA_MODE, 170 offsetof(struct GEA2LISTUNIXATTRIBS, offRDev) - offsetof(struct GEA2LISTUNIXATTRIBS, offINO), sizeof(EA_INO) - 1, EA_INO, 171 offsetof(struct GEA2LISTUNIXATTRIBS, offGen) - offsetof(struct GEA2LISTUNIXATTRIBS, offRDev), sizeof(EA_RDEV) - 1, EA_RDEV, 172 0, sizeof(EA_GEN) - 1, EA_GEN 121 #pragma pack() 122 123 /** 124 * The prefilled GEA2LIST construct for querying all unix attributes. 125 */ 126 const struct __LIBC_BACK_FSUNIXATTRIBSGEA2LIST __libc_gFsUnixAttribsGEA2List = 127 { 128 #define OFF(a,b) offsetof(struct __LIBC_BACK_FSUNIXATTRIBSGEA2LIST, a) - offsetof(struct __LIBC_BACK_FSUNIXATTRIBSGEA2LIST, b) 129 sizeof(__libc_gFsUnixAttribsGEA2List), 130 OFF(offUID, offSymlink), sizeof(EA_SYMLINK) - 1, EA_SYMLINK, 131 OFF(offGID, offUID), sizeof(EA_UID) - 1, EA_UID, 132 OFF(offMode, offGID), sizeof(EA_GID) - 1, EA_GID, 133 OFF(offINO, offMode), sizeof(EA_MODE) - 1, EA_MODE, 134 OFF(offRDev, offINO), sizeof(EA_INO) - 1, EA_INO, 135 OFF(offGen, offRDev), sizeof(EA_RDEV) - 1, EA_RDEV, 136 OFF(offFlags, offGen), sizeof(EA_GEN) - 1, EA_GEN, 137 0, sizeof(EA_FLAGS) - 1, EA_FLAGS 138 #undef OFF 173 139 }; 140 #pragma pack() 141 142 /** 143 * The prefilled FEA2LIST construct for setting all attributes during a creation operation. 144 */ 145 #pragma pack(1) 146 const struct __LIBC_FSUNIXATTRIBSCREATEFEA2LIST __libc_gFsUnixAttribsCreateFEA2List = 147 { 148 #define OFF(a,b) offsetof(struct __LIBC_FSUNIXATTRIBSCREATEFEA2LIST, a) - offsetof(struct __LIBC_FSUNIXATTRIBSCREATEFEA2LIST, b) 149 sizeof(__libc_gFsUnixAttribsCreateFEA2List), 150 OFF(offGID, offUID), FEA_NEEDEA, sizeof(EA_UID) - 1, sizeof(uint32_t) + 4, EA_UID, EAT_BINARY, sizeof(uint32_t), 0, "", 151 OFF(offMode, offGID), FEA_NEEDEA, sizeof(EA_GID) - 1, sizeof(uint32_t) + 4, EA_GID, EAT_BINARY, sizeof(uint32_t), 0, "", 152 OFF(offINO, offMode), FEA_NEEDEA, sizeof(EA_MODE) - 1, sizeof(uint32_t) + 4, EA_MODE, EAT_BINARY, sizeof(uint32_t), 0, "", 153 OFF(offRDev, offINO), FEA_NEEDEA, sizeof(EA_INO) - 1, sizeof(uint64_t) + 4, EA_INO, EAT_BINARY, sizeof(uint64_t), 0, "", 154 OFF(offGen, offRDev), FEA_NEEDEA, sizeof(EA_RDEV) - 1, sizeof(uint32_t) + 4, EA_RDEV, EAT_BINARY, sizeof(uint32_t), 0, "", 155 OFF(offFlags, offGen), FEA_NEEDEA, sizeof(EA_GEN) - 1, sizeof(uint32_t) + 4, EA_GEN, EAT_BINARY, sizeof(uint32_t), 0, "", 156 0, FEA_NEEDEA, sizeof(EA_FLAGS) - 1, sizeof(uint32_t) + 4, EA_FLAGS, EAT_BINARY, sizeof(uint32_t), 0, "" 157 #undef OFF 158 }; 159 #pragma pack() 174 160 175 161 /** … … 188 174 /** Mutex semaphore protecting the g_aFSInfoVolumes array. */ 189 175 static _fmutex g_mtxFSInfoVolumes = _FMUTEX_INITIALIZER_EX(_FMC_MUST_COMPLETE, "mtxFSInfoVolumes"); 176 190 177 191 178 /******************************************************************************* … … 195 182 static int fsResolveOS2(const char *pszUserPath, unsigned fFlags, char *pszNativePath, int *pfInUnixTree); 196 183 static uint32_t crc32str(const char *psz); 184 #if 0 197 185 static uint32_t djb2(const char *str); 186 #endif 198 187 static uint32_t sdbm(const char *str); 199 188 … … 496 485 } 497 486 #endif 498 499 500 /**501 * Creates a symlink.502 *503 * @returns 0 on success.504 * @returns Negative error code (errno.h) on failure.505 * @param pszTarget The symlink target.506 * @param pszSymlink The symlink, the one to be updated.507 */508 int __libc_back_fsNativeSymlinkCreate(const char *pszTarget, const char *pszNativePath)509 {510 LIBCLOG_ENTER("pszTarget=%s pszNativePath=%s\n", pszTarget, pszNativePath);511 512 /*513 * Validate input.514 */515 int cchTarget = strlen(pszTarget);516 if (cchTarget >= PATH_MAX)517 LIBCLOG_ERROR_RETURN(-ENAMETOOLONG, "ret -ENAMETOOLONG - Target is too long, %d bytes. (%s)\n", cchTarget, pszTarget);518 519 /*520 * Allocate FEA buffer.521 */522 EAOP2 EaOp = {0,0,0};523 int cb = cchTarget + sizeof(USHORT) * 2 + sizeof(EA_SYMLINK) + sizeof(FEALIST);524 EaOp.fpFEA2List = alloca(cb);525 if (!EaOp.fpFEA2List)526 LIBCLOG_ERROR_RETURN(-ENOMEM, "ret -ENOMEM -Out of stack! alloca(%d) failed\n", cb);527 528 /*529 * Setup the EAOP structure.530 */531 EaOp.fpFEA2List->cbList = cb;532 PFEA2 pFEA = &EaOp.fpFEA2List->list[0];533 pFEA->oNextEntryOffset = 0;534 pFEA->cbName = sizeof(EA_SYMLINK) - 1;535 pFEA->cbValue = cchTarget + sizeof(USHORT) * 2;536 pFEA->fEA = FEA_NEEDEA;537 memcpy(pFEA->szName, EA_SYMLINK, sizeof(EA_SYMLINK));538 PUSHORT pus = (PUSHORT)&pFEA->szName[sizeof(EA_SYMLINK)];539 pus[0] = EAT_ASCII;540 pus[1] = cchTarget;541 memcpy(&pus[2], pszTarget, cchTarget);542 HFILE hf = -1;543 ULONG ul = 0;544 int rc = DosOpen((PCSZ)pszNativePath, &hf, &ul, cchTarget + 1, FILE_NORMAL,545 OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_FAIL_IF_EXISTS,546 OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,547 &EaOp);548 if (!rc)549 {550 char *psz = (char *)&pus[2] - (sizeof(EA_SYMLINK "=") - 1);551 memcpy(psz, EA_SYMLINK "=", sizeof(EA_SYMLINK "=") - 1);552 DosWrite(hf, psz, cchTarget + sizeof(EA_SYMLINK "=") - 1, &ul);553 DosClose(hf);554 LIBCLOG_RETURN_INT(0);555 }556 557 rc = -__libc_native2errno(rc);558 LIBCLOG_ERROR_RETURN_INT(rc);559 }560 561 487 562 488 … … 1312 1238 1313 1239 1314 1315 1316 /** 1317 * Creates the unix EAs for a new file or directory. 1318 * 1319 * @returns 0 on success. 1320 * @returns Negative errno on failure. 1321 * @param hFile File handle to the newly created fs object. If no 1322 * handle handy, set to -1. 1323 * @param pszNativePath Native path to the newly created fs object. 1324 * @param mode The specified file permission mode mask. 1325 * @param pDev Where to store the dev number. 1326 * @param pInode Where to store the calculated inode number. 1327 */ 1328 int __libc_back_fsUnixAttribsSet(int hFile, const char *pszNativePath, mode_t mode, dev_t *pDev, ino_t *pInode) 1329 { 1330 /* 1331 * Calc device. 1332 */ 1333 dev_t Dev; 1334 char chDrv = *pszNativePath; 1335 if (chDrv == '/' || chDrv == '\\') 1336 Dev = makedev('U', 0); /* U as in UNC */ 1337 else 1338 { 1339 LIBC_ASSERT(chDrv >= 'A' && chDrv <= 'Z'); 1340 Dev = makedev('V', chDrv); /* V as in Volume */ 1341 } 1342 1240 /** 1241 * Initializes a unix attribute structure before creating a new inode. 1242 * The call must have assigned default values to the the structure before doing this call! 1243 * 1244 * @returns Device number. 1245 * @param pFEas The attribute structure to fill with actual values. 1246 * @param pszNativePath The native path, used to calculate the inode number. 1247 * @param Mode The correct mode (the caller have fixed this!). 1248 */ 1249 dev_t __libc_back_fsUnixAttribsInit(struct __LIBC_FSUNIXATTRIBSCREATEFEA2LIST *pFEas, char *pszNativePath, mode_t Mode) 1250 { 1343 1251 /* 1344 1252 * Calc Inode number. 1345 * 1346 * Whether to use another hash algorithm here is a bit in the blue now 1347 * because the stored value might be inaccessible at times. 1348 */ 1253 * We replace the lower 32-bit with a random value. 1254 */ 1255 /* low 32-bit - random */ 1256 static union 1257 { 1258 uint64_t u64TSC; 1259 unsigned short ausSeed[4]; 1260 } s_Seed = {0}; 1261 static _smutex s_smtxSeed = 0; 1262 _smutex_request(&s_smtxSeed); 1263 /* seed it ? */ 1264 if (!s_Seed.ausSeed[3]) 1265 { 1266 __asm__ __volatile__ ("rdtsc" : "=A" (s_Seed.u64TSC)); 1267 s_Seed.ausSeed[3] = 1; 1268 } 1269 pFEas->u64INO = nrand48(&s_Seed.ausSeed[0]) & 0xffffffff; 1270 _smutex_release(&s_smtxSeed); 1271 1272 /* high 32-bit - crc32 */ 1349 1273 const char *psz = pszNativePath; 1350 1274 if (psz[1] == ':') 1351 1275 psz += 2; 1352 ino_t Inode = ((uint64_t)crc32str(psz) << 32) | (uint64_t)djb2(psz); 1353 1354 /** @todo Save unix EAs! */ 1355 if (pDev) 1356 *pDev = Dev; 1357 if (pInode) 1358 *pInode = (Inode & 0xffffffff00000000ULL) | (uint64_t)sdbm(psz); 1359 return 0; 1276 pFEas->u64INO |= (uint64_t)crc32str(psz) << 32; 1277 1278 /* 1279 * The other stuff. 1280 */ 1281 pFEas->u32UID = __libc_spmGetId(__LIBC_SPMID_EUID); 1282 pFEas->u32GID = __libc_spmGetId(__LIBC_SPMID_EGID); /** @todo sticky bit! */ 1283 pFEas->u32Mode = Mode; 1284 LIBC_ASSERT(pFEas->u32RDev == 0); 1285 LIBC_ASSERT(pFEas->u32Gen == 0); 1286 LIBC_ASSERT(pFEas->u32Flags == 0); 1287 1288 /* 1289 * Calc device. 1290 */ 1291 char chDrv = *pszNativePath; 1292 if (chDrv == '/' || chDrv == '\\') 1293 return makedev('U', 0); /* U as in UNC */ 1294 LIBC_ASSERT(chDrv >= 'A' && chDrv <= 'Z'); 1295 return makedev('V', chDrv); /* V as in Volume */ 1360 1296 } 1361 1297 … … 1378 1314 1379 1315 /* Try come up with an accurate max estimate of a maximum result. */ 1380 char achBuffer[sizeof( gGEA2ListUnixAttribs) + 7 * (sizeof(USHORT) * 2 + sizeof(BYTE)) + CCHMAXPATH + 6 * sizeof(uint32_t) + 0x30];1316 char achBuffer[sizeof(EAOP2) + sizeof(FILEFINDBUF3) + sizeof(__libc_gFsUnixAttribsGEA2List) + 7 * (sizeof(USHORT) * 2 + sizeof(BYTE)) + CCHMAXPATH + 6 * sizeof(uint32_t) + 0x30]; 1381 1317 char *pachBuffer = (char *)((uintptr_t)&achBuffer[3] & ~3); 1382 EAOP2 EaOp2;1383 int rc ;1318 PEAOP2 pEaOp2 = (PEAOP2)pachBuffer; 1319 int rc = -1000; 1384 1320 1385 1321 /* 1386 1322 * Issue the query. 1387 1323 */ 1388 EaOp2.fpGEA2List = (PGEA2LIST)&gGEA2ListUnixAttribs;1389 EaOp2.fpFEA2List = (PFEA2LIST)pachBuffer;1390 EaOp2.oError = 0;1391 EaOp2.fpFEA2List->cbList = sizeof(achBuffer) - 4;1392 1324 if (hFile >= 0) 1393 rc = DosQueryFileInfo(hFile, FIL_QUERYEASFROMLIST, &EaOp2, sizeof(EaOp2)); 1394 else 1395 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_QUERYEASFROMLIST, &EaOp2, sizeof(EaOp2)); 1325 { 1326 pEaOp2->fpGEA2List = (PGEA2LIST)&__libc_gFsUnixAttribsGEA2List; 1327 pEaOp2->fpFEA2List = (PFEA2LIST)(pEaOp2 + 1); 1328 pEaOp2->oError = 0; 1329 pEaOp2->fpFEA2List->cbList = sizeof(achBuffer) - 4 - sizeof(EAOP2); 1330 rc = DosQueryFileInfo(hFile, FIL_QUERYEASFROMLIST, pEaOp2, sizeof(EAOP2)); 1331 } 1332 if (rc && pszNativePath) 1333 { 1334 pEaOp2->fpGEA2List = (PGEA2LIST)&__libc_gFsUnixAttribsGEA2List; 1335 pEaOp2->fpFEA2List = (PFEA2LIST)(pEaOp2 + 1); 1336 pEaOp2->oError = 0; 1337 pEaOp2->fpFEA2List->cbList = sizeof(achBuffer) - 4 - sizeof(EAOP2); 1338 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_QUERYEASFROMLIST, pEaOp2, sizeof(EAOP2)); 1339 if (rc == ERROR_SHARING_VIOLATION || rc == ERROR_ACCESS_DENIED || rc == ERROR_INVALID_ACCESS) 1340 { 1341 HDIR hDir = HDIR_CREATE; 1342 ULONG cFiles = 1; 1343 pEaOp2->fpGEA2List = (PGEA2LIST)&__libc_gFsUnixAttribsGEA2List; 1344 pEaOp2->fpFEA2List = (PFEA2LIST)(pEaOp2 + 1); 1345 pEaOp2->oError = 0; 1346 pEaOp2->fpFEA2List->cbList = sizeof(achBuffer) - 4 - sizeof(EAOP2); 1347 rc = DosFindFirst((PCSZ)pszNativePath, &hDir, 0, pEaOp2, pEaOp2->fpFEA2List->cbList + sizeof(*pEaOp2), &cFiles, FIL_QUERYEASFROMLIST); 1348 if (!rc) 1349 { 1350 DosFindClose(hDir); 1351 pEaOp2->fpFEA2List = (PFEA2LIST)((char *)pEaOp2 + sizeof(EAOP2) + offsetof(FILEFINDBUF3, cchName)); 1352 } 1353 } 1354 } 1396 1355 if (rc) 1397 1356 { 1398 LIBC_ASSERTM(rc == ERROR_ACCESS_DENIED, "Bogus EAs? rc=%d oError=%ld\n", rc, EaOp2.oError); 1357 LIBC_ASSERTM(rc == ERROR_ACCESS_DENIED || rc == ERROR_SHARING_VIOLATION || rc == ERROR_EAS_NOT_SUPPORTED, 1358 "Bogus EAs? rc=%d oError=%ld\n", rc, pEaOp2->oError); 1399 1359 rc = -__libc_native2errno(rc); 1400 1360 LIBCLOG_ERROR_RETURN_INT(rc); 1401 1361 } 1402 if ( EaOp2.fpFEA2List->cbList < LIBC_UNIX_EA_MIN)1362 if (pEaOp2->fpFEA2List->cbList < LIBC_UNIX_EA_MIN) 1403 1363 LIBCLOG_RETURN_INT(0); 1404 1364 … … 1406 1366 * Parse the result. 1407 1367 */ 1408 PFEA2 pFea2 = & EaOp2.fpFEA2List->list[0];1368 PFEA2 pFea2 = &pEaOp2->fpFEA2List->list[0]; 1409 1369 for (;;) 1410 1370 { … … 1416 1376 else 1417 1377 { 1418 PUSHORT pusType = (PUSHORT) ((char *)pFea2 + pFea2->cbName);1419 if ( pusType[0] == EAT_BINARY && pusType[1] == sizeof(uint32_t))1378 PUSHORT pusType = (PUSHORT)&pFea2->szName[pFea2->cbName + 1]; 1379 if (*pusType == EAT_BINARY) 1420 1380 { 1421 uint32_t u32 = *(uint32_t *)&pusType[2]; 1422 if (COMPARE_EANAME(__libc_gszUidEA)) 1423 pStat->st_uid = u32; 1424 else if (COMPARE_EANAME(__libc_gszGidEA)) 1425 pStat->st_gid = u32; 1426 else if (COMPARE_EANAME(__libc_gszModeEA)) 1427 pStat->st_mode = u32; 1428 else if (COMPARE_EANAME(__libc_gszInoEA)) 1429 pStat->st_ino = u32; 1430 else if (COMPARE_EANAME(__libc_gszRDevEA)) 1431 pStat->st_rdev = u32; 1432 else if (COMPARE_EANAME(__libc_gszGenEA)) 1433 /* pStat->st_gen = u32 - not implemented */; 1381 pusType++; 1382 if (*pusType == sizeof(uint32_t)) 1383 { 1384 uint32_t u32 = *(uint32_t *)++pusType; 1385 if (COMPARE_EANAME(__libc_gszUidEA)) 1386 pStat->st_uid = u32; 1387 else if (COMPARE_EANAME(__libc_gszGidEA)) 1388 pStat->st_gid = u32; 1389 else if (COMPARE_EANAME(__libc_gszModeEA)) 1390 pStat->st_mode = u32; 1391 else if (COMPARE_EANAME(__libc_gszRDevEA)) 1392 pStat->st_rdev = u32; 1393 else if (COMPARE_EANAME(__libc_gszGenEA)) 1394 /* pStat->st_gen = u32 - not implemented */; 1395 else if (COMPARE_EANAME(__libc_gszFlagsEA)) 1396 /* pStat->st_flags = u32 - not implemented */; 1397 else 1398 LIBC_ASSERTM_FAILED("Huh?!? got an ea named '%s', namelen=%d! u32=%#x (%d)\n", pFea2->szName, pFea2->cbName, u32, u32); 1399 } 1400 else if (*pusType == sizeof(uint64_t)) 1401 { 1402 uint64_t u64 = *(uint64_t *)++pusType; 1403 if (COMPARE_EANAME(__libc_gszInoEA)) 1404 pStat->st_ino = u64; 1405 else 1406 LIBC_ASSERTM_FAILED("Huh?!? got an ea named '%s', namelen=%d! u64=%#llx (%lld)\n", pFea2->szName, pFea2->cbName, u64, u64); 1407 } 1434 1408 else 1435 LIBC_ASSERTM_FAILED(" Huh?!? got an ea named '%s', namelen=%d!\n", pFea2->szName, pFea2->cbName);1409 LIBC_ASSERTM_FAILED("Invalid LIBC EA! '%s' len=%#x and len=4 or 8.\n", pFea2->szName, *pusType); 1436 1410 } 1437 1411 else 1438 LIBC_ASSERTM_FAILED("Invalid LIBC EA! %s type=%#x len=%#x, expected type=%#x and len=%#x.\n",1439 pFea2->szName, pusType[0], pusType[1], EAT_BINARY , sizeof(uint32_t));1412 LIBC_ASSERTM_FAILED("Invalid LIBC EA! '%s' type=%#x len=%#x, expected type=%#x and len=4 or 8.\n", 1413 pFea2->szName, pusType[0], pusType[1], EAT_BINARY); 1440 1414 } 1441 1415 #undef COMPARE_EANAME … … 1618 1592 1619 1593 1594 #if 0 1620 1595 /* djb2: 1621 1596 This algorithm (k=33) was first reported by dan bernstein many years ago in … … 1635 1610 return hash; 1636 1611 } 1612 #endif 1637 1613 1638 1614 /* sdbm: -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/seterrno.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r2312 r2313 64 64 EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 270..274 */ 65 65 EINVAL, EINVAL, EINVAL, EINVAL, EINVAL, /* 275..279 */ 66 EINVAL, EINVAL, E INVAL, EINVAL, EEXIST, /* 280..284 */66 EINVAL, EINVAL, ENOTSUP, EINVAL, EEXIST, /* 280..284 */ 67 67 EEXIST, EINVAL, EINVAL, EINVAL, EINVAL, /* 285..289 */ 68 68 ENOMEM, EMFILE, EINVAL, EINVAL, EINVAL, /* 290..294 */ -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.