- Timestamp:
- Aug 29, 2005, 5:35:39 AM (20 years ago)
- Location:
- trunk/src/emx
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/ChangeLog.LIBC
-
Property cvs2svn:cvs-rev
changed from
1.134
to1.135
r2315 r2316 3 3 TODO: open replace on RAMFS fails with error 32! 4 4 5 2005-08-29: knut st. osmundsen <bird-gccos2-spam@anduin.net> 6 - libc: 7 o Removed forwarder dlls since struct stat and __LIBC_FH is incompatible in rc2. 5 2005-08-28: knut st. osmundsen <bird-gccos2-spam@anduin.net> 6 - libc: 7 o Reworked the open backend, adding directory support. Some O_* 8 flags was changed in the process, breaking the old ABI. 9 This is not fully tested. 10 o Added more BSD fields to struct stat, breaking the old ABI. 11 The mtime field and ctime fields will now keep the same values 12 and the creation time is to be found in birthtime. This means that 13 ctime will be updated in a few places where it doesn't on unix - but 14 this is probably better than previously where it wasn't ever updated 15 when it should. 16 o Removed forwarder dlls since struct stat, O_* and __LIBC_FH is 17 soon going to be incompatible with rc1 and older versions. 8 18 - version.smak: 9 19 o Changed version number back to 3.3.5 / 0.6 rc2. 10 20 11 2005-08-2 8: knut st. osmundsen <bird-gccos2-spam@anduin.net>21 2005-08-27: knut st. osmundsen <bird-gccos2-spam@anduin.net> 12 22 - libc: 13 23 o Fixed lot's of unix attribute (in EA) handling. … … 16 26 This will break libsocket backwards compatability. 17 27 o Added _hstrdup. 18 19 2005-08-27: knut st. osmundsen <bird-gccos2-spam@anduin.net>20 - libc:21 28 o Fixed two cases where the signal semaphore was incorrectly unlocked 22 29 after signalDeliver(). -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/InnoTekLIBC/backend.h
-
Property cvs2svn:cvs-rev
changed from
1.33
to1.34
r2315 r2316 398 398 399 399 /** 400 * Opens a file.400 * Opens or creates a file. 401 401 * 402 402 * @returns Filehandle to the opened file on success. 403 403 * @returns Negative error code (errno.h) on failure. 404 404 * @param pszFile Path to the file. 405 * @param fFlags Open flags. 405 * @param fLibc The LIBC open flags (O_*). 406 * @param fShare The share flags (SH_*). 406 407 * @param cbInitial Initial filesize. 407 408 * @param Mode The specified permission mask. 408 * @param fLibc LIBC filehandle flags.409 409 * @param ppFH Where to store the LIBC filehandle structure which was created 410 410 * for the opened file. 411 411 */ 412 int __libc_Back_ioFileOpen(const char *pszFile, int fFlags, off_t cbInitial, mode_t Mode, unsigned fLibc, PLIBCFH *ppFH);412 int __libc_Back_ioFileOpen(const char *pszFile, unsigned fLibc, int fShare, off_t cbInitial, mode_t Mode, PLIBCFH *ppFH); 413 413 414 414 /** -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/emx/io.h
-
Property cvs2svn:cvs-rev
changed from
1.19
to1.20
r2315 r2316 36 36 /* O_NONBLOCK 0x00000004 */ 37 37 /* O_APPEND 0x00000008 */ 38 /* emx O_TEXT 0x00000010*/39 /* emx O_SIZE 0x00000020*/40 /* free 0x00000040*/38 /* reserved 0x00000010 O_SHLOCK */ 39 /* reserved 0x00000020 O_EXLOCK */ 40 /* reserved 0x00000040 O_ASYNC */ 41 41 /* O_(F)SYNC 0x00000080 */ 42 /* O_SYNC 0x00000080 */ 43 /* emx O_BINARY 0x00000100 */ 42 /* O_NOFOLLOW 0x00000100 */ 44 43 /* O_CREAT 0x00000200 */ 45 44 /* O_TRUNC 0x00000400 */ 46 45 /* O_EXCL 0x00000800 */ 47 46 /* emx O_NOINHERIT 0x00001000 */ 48 /* free 49 /* free 47 /* free? 0x00002000 */ 48 /* free? 0x00004000 */ 50 49 /* O_NOCTTY 0x00008000 */ 50 /* O_DIRECT 0x00010000 */ 51 /* emx O_BINARY 0x00020000 */ 52 /* emx O_TEXT 0x00040000 */ 53 /* emx O_SIZE 0x00080000 */ 51 54 #define F_EOF 0x00100000 52 55 #define F_TERMIO 0x00200000 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/sys/fcntl.h
-
Property cvs2svn:cvs-rev
changed from
1.8
to1.9
r2315 r2316 126 126 /* bird: EMX used 0x2000 for O_SYNC. */ 127 127 #define O_SYNC 0x0080 /* POSIX synonym for O_FSYNC */ 128 #if 0 /* bird: not implemented - start */129 128 #if __BSD_VISIBLE 130 129 #define O_NOFOLLOW 0x0100 /* don't follow symlinks */ 131 130 #endif 132 #endif /* bird: not implemented - end */133 131 #define O_CREAT 0x0200 /* create if nonexistent */ 134 132 #define O_TRUNC 0x0400 /* truncate to zero length */ … … 145 143 #define O_NOCTTY 0x8000 /* don't assign controlling terminal */ 146 144 147 #if 0 /* bird: not implemented - start */148 145 #if __BSD_VISIBLE 149 146 /* Attempt to bypass buffer cache */ 150 147 #define O_DIRECT 0x00010000 151 148 #endif 152 #endif /* bird: not implemented - end */153 149 154 150 /* … … 279 275 #if !defined (O_TEXT) 280 276 /* Open flags. 281 As stated in the FreeBSD part, there is supposidly a limited number of bits 282 available. We'll try keep it suitable for 16bit just in case (don't care to 283 check what we use right now) because that'll enable us to share a 32-bit flag 284 variable per handle to both status (O_*) flags and descriptor (FD_*) flags. 285 286 When we've disabled a few BSD flags and leave out KERNEL stuff the following 287 bits are available: 288 0x0010, 0x0020, 0x0040, 0x0100, 0x1000, 0x4000*, 0x2000 289 */ 290 #define O_TEXT 0x0010 291 #define O_BINARY 0x0100 292 #define O_SIZE 0x0020 /* EMX used 0x8000 for O_SIZE. */ 277 * There is some limits to the available bits, generally FreeBSD limits 278 * it's range to the first 16-bits. See emx\io.h for the complete 279 * assignments. 280 */ 281 #define O_BINARY 0x00020000 282 #define O_TEXT 0x00040000 283 #define O_SIZE 0x00080000 293 284 #if !defined (_POSIX_SOURCE) || defined(__USE_EMX) 294 #define O_NOINHERIT 0x1000 /* EMX used 0x1000 for O_NOINHERIT. */285 #define O_NOINHERIT 0x00001000 295 286 #endif 296 287 #endif -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/sys/stat.h
-
Property cvs2svn:cvs-rev
changed from
1.11
to1.12
r2315 r2316 137 137 struct stat { 138 138 __dev_t st_dev; /* inode's device */ 139 #if 1 /* bird: emx: */ 140 __uint32_t st_attr; /* emx: OS/2 & DOS attributes */ 141 #endif 139 142 ino_t st_ino; /* inode's number */ 140 143 mode_t st_mode; /* inode protection mode */ … … 143 146 gid_t st_gid; /* group ID of the file's group */ 144 147 __dev_t st_rdev; /* device type */ 145 #if 1 /* bird: emx */ 146 time_t st_atime; 147 time_t st_mtime; 148 time_t st_ctime; 149 #else /* bird: emx */ 148 #if 1 /* bird: emx - better alignment of 64-bit types */ 149 __int32_t st_lspare; 150 #endif /* bird */ 150 151 #if __BSD_VISIBLE 151 152 struct timespec st_atimespec; /* time of last access */ … … 160 161 long st_ctimensec; /* nsec of last file status change */ 161 162 #endif 162 #endif /* bird: emx */163 163 off_t st_size; /* file size, in bytes */ 164 164 __int64_t st_blocks; /* blocks allocated for file */ 165 165 __uint32_t st_blksize; /* optimal blocksize for I/O */ 166 #if 1 /* bird: emx: */167 long st_attr; /* emx: OS/2 & DOS attributes */168 #else /* bird: emx */169 170 166 fflags_t st_flags; /* user defined flags for file */ 171 167 __uint32_t st_gen; /* file generation number */ 168 #if 0 /* bird: !emx - it's higher up for packing reasons */ 172 169 __int32_t st_lspare; 170 #endif /* bird */ 173 171 #if __BSD_VISIBLE 174 172 struct timespec st_birthtimespec; /* time of file creation */ … … 189 187 unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec)); 190 188 #endif 191 #endif /* bird: emx - end */192 189 }; 193 190 … … 220 217 #endif /* bird: emx */ 221 218 222 #if 0 /* bird: emx */223 219 #if __BSD_VISIBLE 224 220 #define st_atime st_atimespec.tv_sec … … 227 223 #define st_birthtime st_birthtimespec.tv_sec 228 224 #endif 229 #endif /* bird: emx */230 225 231 226 #define S_ISUID 0004000 /* set user id on execution */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/_vsopen.c
-
Property cvs2svn:cvs-rev
changed from
1.7
to1.8
r2315 r2316 11 11 #include <emx/syscalls.h> 12 12 #include <InnoTekLIBC/backend.h> 13 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_IO 14 #include <InnoTekLIBC/logstrict.h> 13 15 14 /* Bugs: O_TRUNC|O_RDONLY not implemented */16 /* Bugs: O_TRUNC|O_RDONLY not implemented - bird: rejecting it makes more sense, just ask the OpenBSD guys. */ 15 17 /* O_TEXT|O_WRONLY does/can not overwrite Ctrl-Z */ 16 18 … … 32 34 int _vsopen(const char *pszName, int fOpen, int fShare, va_list va) 33 35 { 34 int hFile; 35 /** Flags is for __open. 36 * 0 - 1 Access mode (O_RDONLY, O_WRONLY, O_RDWR). 37 * 4 - 6 Shared (SH_*) 38 * 8 - 15 File attributes (DOS style). 39 * 16 - 23 __open flags, _SO_* 40 */ 41 int fFlags; 42 unsigned fLibc; /* LIBC handle flags. */ 43 int saved_errno; 44 char chDummy; 45 int fCtrlZKludge = 0; 46 off_t cbInitial; 47 mode_t cmode = 0; 48 PLIBCFH pFH; 36 LIBCLOG_ENTER("pszName=%p:{%s} fOpen=%#x fShare=%#x ...\n", (void *)pszName, pszName, fOpen, fShare); 49 37 50 38 /* 51 39 * Validate input 52 40 */ 53 if ((fOpen & O_ACCMODE) == O_RDONLY && (fOpen & (O_TRUNC|O_CREAT))) 41 if ( (fOpen & O_ACCMODE) == O_RDONLY 42 && (fOpen & (O_TRUNC | O_CREAT))) 54 43 { 55 44 errno = EINVAL; 56 return -1;45 LIBCLOG_ERROR_RETURN_INT(-1); 57 46 } 58 47 59 48 /* 60 * Build fFlags. 49 * Build fLibc 50 * - It's pretty much fOpen but we need to remove irrelevant flags and add O_TEXT/O_BINARY and such. 61 51 */ 62 fLibc = fOpen & (O_ACCMODE|O_NDELAY|O_APPEND|O_SYNC/*|O_DIRECT*/|O_NOINHERIT);52 unsigned fLibc = fOpen & (O_ACCMODE | O_NDELAY | O_APPEND | O_SYNC | O_DIRECT | O_NOINHERIT | O_CREAT | O_EXCL | O_TRUNC | O_NOINHERIT | O_SIZE); 63 53 if ( !(fOpen & O_BINARY) 64 54 && ((fOpen & O_TEXT) || !_fmode_bin)) 65 55 fLibc |= O_TEXT; 66 67 if ((fLibc & O_TEXT) && (fOpen & O_APPEND) && (fOpen & O_ACCMODE) == O_WRONLY) 56 else 57 fLibc |= O_BINARY; 58 if ((fLibc & (O_EXCL | O_CREAT)) == O_EXCL) 68 59 { 69 /* The caller requests to open a text file for appending in 70 write-only. To remove the Ctrl-Z (if there is any), we have 71 to temporarily open the file in read/write mode. */ 72 73 fFlags = O_RDWR | (fShare & SH_MASK); 74 fCtrlZKludge = 1; 75 } 76 else 77 fFlags = (fOpen & O_ACCMODE) | (fShare & SH_MASK); 78 79 /* cmode(=attr) - attr is 2nd byte of flags. */ 80 if (fOpen & O_CREAT) 81 { 82 int attr; 83 84 attr = 0; 85 cmode = va_arg(va, mode_t); 86 if (!(cmode & S_IWRITE)) 87 attr |= _A_RDONLY; 88 fFlags |= (attr << 8) | _SO_CREAT; 89 if (fOpen & O_EXCL) 90 fFlags |= _SO_EXCL; 60 fLibc &= ~O_EXCL; /* O_EXCL doesn't make sense without O_CREATE. */ 61 LIBCLOG_MSG("No O_CREAT, stripping O_EXCL.\n"); 91 62 } 92 63 93 if (fOpen & O_TRUNC) 94 fFlags |= _SO_TRUNC; 64 /* 65 * If the caller requests to open a text file for appending in write-only 66 * we have some trouble reading and stripping away any Ctrl-Z that may 67 * reside at the end of the file. Thus, first open the file in O_RDWR mode 68 * to do the stripping, close it, and reopen it in O_WRONLY mode. 69 */ 70 int fCtrlZKludge = 0; 71 if ((fLibc & (O_TEXT | O_APPEND | O_ACCMODE | O_EXCL)) == (O_TEXT | O_APPEND | O_WRONLY)) 72 { 73 fCtrlZKludge = 1; 74 fLibc = (fLibc & ~O_ACCMODE) | O_RDWR; 75 LIBCLOG_MSG("Ctrl-Z: Applying the kludge.\n"); 76 } 95 77 96 if (fOpen & O_NOINHERIT) 97 fFlags |= _SO_NOINHERIT; 78 /* 79 * The file mode is only available if O_CREAT is specified. 80 */ 81 mode_t Mode = 0; 82 if (fLibc & O_CREAT) 83 { 84 Mode = va_arg(va, mode_t); 85 LIBCLOG_MSG("O_CREATE: Mode=0%o\n", Mode); 86 } 98 87 99 if (fOpen & O_SYNC) 100 fFlags |= _SO_SYNC; 101 102 /* Initial file size */ 103 cbInitial = 0; 104 if (fOpen & O_SIZE) 88 /* 89 * The initial file size is only available if O_SIZE is specified. 90 */ 91 off_t cbInitial = 0; 92 if (fLibc & O_SIZE) 105 93 { 106 94 cbInitial = va_arg(va, off_t); 107 fFlags |= _SO_SIZE;95 LIBCLOG_MSG("O_SIZE: cbInitial=%#llx\n", cbInitial); 108 96 } 109 97 … … 111 99 * Open - note Ctrl-Z hack. 112 100 */ 113 saved_errno = errno; 114 hFile = __libc_Back_ioFileOpen(pszName, fFlags, cbInitial, cmode, fLibc, &pFH); 115 if (hFile < 0 && fCtrlZKludge && errno == EACCES) 101 int saved_errno = errno; 102 PLIBCFH pFH; 103 int fd = __libc_Back_ioFileOpen(pszName, fLibc, fShare, cbInitial, Mode, &pFH); 104 if (fd == -EACCES && fCtrlZKludge) 116 105 { 117 /* Perhaps read access is denied. Try again. */106 LIBCLOG_MSG("Ctrl-Z: Open failed, retries without the kludge.\n"); 118 107 fCtrlZKludge = 0; 119 f Flags = (fFlags & ~O_ACCMODE) | (fOpen & O_ACCMODE);120 hFile = __libc_Back_ioFileOpen(pszName, fFlags, cbInitial, cmode, fLibc, &pFH);108 fLibc = (fLibc & ~O_ACCMODE) | O_WRONLY; 109 fd = __libc_Back_ioFileOpen(pszName, fLibc, fShare, cbInitial, Mode, &pFH); 121 110 } 122 if ( hFile< 0)111 if (fd < 0) 123 112 { 124 errno = - hFile;125 return -1;113 errno = -fd; 114 LIBCLOG_ERROR_RETURN_INT(-1); 126 115 } 127 116 fLibc = pFH->fFlags; /* get the updated flags. */ … … 130 119 * Check what we got a handle to. 131 120 */ 132 if ((fLibc & __LIBC_FH_TYPEMASK) == F_DEV) 133 fOpen &= ~O_APPEND; 121 if ( (fLibc & O_APPEND) 122 && (fLibc & __LIBC_FH_TYPEMASK) != F_FILE) 123 { 124 fLibc &= ~O_APPEND; 125 LIBCLOG_MSG("Not a F_FILE, stripping O_APPEND!\n"); /** @todo __libc_Back_ioFileOpen should strip this! */ 126 } 134 127 135 128 /* 136 * For text files we shall remove eventual ending Ctrl-Z.129 * For text files we shall remove the eventual Ctrl-Z at the end of the file. 137 130 */ 138 if ( (fLibc & __LIBC_FH_TYPEMASK) != F_DEV139 && (fLibc & O_ TEXT))131 if ( (fLibc & (__LIBC_FH_TYPEMASK | O_TEXT | O_BINARY)) == (F_FILE | O_TEXT) 132 && (fLibc & O_ACCMODE) != O_RDONLY) 140 133 { 141 off_t cbSize;142 143 134 /* Remove the last character of the file if it is a Ctrl-Z. Do 144 135 this even if O_SIZE is given as we don't know whether the 145 136 file existed before; removing a spurious Ctrl-Z due to O_SIZE 146 137 should be harmless. */ 147 148 cbSize = __libc_Back_ioSeek(hFile, -1, SEEK_END); 138 off_t cbSize = __libc_Back_ioSeek(fd, -1, SEEK_END); 149 139 if (cbSize >= 0) 150 140 { 151 if (__read(hFile, &chDummy, 1) == 1 && chDummy == 0x1a) 152 __libc_Back_ioFileSizeSet(hFile, cbSize, 0); /* Remove Ctrl-Z */ 153 __libc_Back_ioSeek(hFile, 0, SEEK_SET); 141 char chDummy = 127; 142 if ( __read(fd, &chDummy, 1) == 1 143 && chDummy == 0x1a) 144 { 145 int rc2 = __libc_Back_ioFileSizeSet(fd, cbSize, 0); /* Remove Ctrl-Z */ 146 LIBCLOG_MSG("Ctrl-Z: Strip attempt rc=%d, cbSize=%#llx\n", rc2, cbSize); (void)rc2; 147 } 148 else 149 LIBCLOG_MSG("Ctrl-Z: Strip attempt chDummy=0x%02x, cbSize=%#llx.\n", chDummy, cbSize); 150 __libc_Back_ioSeek(fd, 0, SEEK_SET); 154 151 } 152 else 153 LIBCLOG_MSG("Ctrl-Z: Failed to search to end of file, cbSize=%lld\n", cbSize); 155 154 } 156 155 157 156 /* 158 * Reopen the file in write-only mode if Ctrl-Z hack applied.157 * Reopen the file in write-only Mode if Ctrl-Z hack applied. 159 158 */ 160 159 if (fCtrlZKludge) 161 160 { 162 __close(hFile); 163 fFlags = (fFlags & ~O_ACCMODE) | (fOpen & O_ACCMODE); 164 fFlags &= ~_SO_EXCL; /* Ignore O_EXCL */ 165 hFile = __libc_Back_ioFileOpen(pszName, fFlags, cbInitial, cmode, fLibc & ~__LIBC_FH_TYPEMASK, &pFH); 166 if (hFile < 0) 161 LIBCLOG_MSG("Ctrl-Z: Reopening the file in O_WRONLY mode.\n"); 162 __close(fd); 163 int fLibcSaved = fLibc; 164 fLibc = (fLibc & ~(O_ACCMODE | O_EXCL | __LIBC_FH_TYPEMASK)) | O_WRONLY; /* Ignore exclusive open. */ 165 fd = __libc_Back_ioFileOpen(pszName, fLibc, fShare, cbInitial, Mode, &pFH); 166 if (fd < 0) 167 167 { 168 errno = - hFile;169 return -1;168 errno = -fd; 169 LIBCLOG_ERROR_RETURN_INT(-1); 170 170 } 171 if (fLibcSaved & O_EXCL) 172 pFH->fFlags |= O_EXCL; 173 fLibc = pFH->fFlags; 171 174 } 172 175 … … 177 180 if ( (fLibc & __LIBC_FH_TYPEMASK) == F_FILE 178 181 && (fLibc & O_APPEND)) 179 __libc_Back_ioSeek(hFile, 0, SEEK_END); 182 { 183 off_t cbSize = __libc_Back_ioSeek(fd, 0, SEEK_END); 184 LIBCLOG_MSG("O_APPEND: seek cbSize=%#llx\n", cbSize); (void)cbSize; 185 } 186 180 187 errno = saved_errno; 188 LIBCLOG_RETURN_INT(fd); 189 } 181 190 182 return hFile;183 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_dir.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r2315 r2316 38 38 #include <errno.h> 39 39 #include <limits.h> 40 #include <sys/fcntl.h> 40 41 #include <emx/umalloc.h> 42 #include <emx/io.h> 41 43 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO 42 44 #include <InnoTekLIBC/logstrict.h> … … 252 254 * @param pszNativePath Pointer to the native path. The buffer must be on stack 253 255 * and must have space for 4 extra bytes! 256 * @param fInUnixTree Set if the native path is in the unix tree. 254 257 * @param fLibc The LIBC open() flags. 255 */ 256 int __libc_Back_dirOpenNative(char *pszNativePath, unsigned fLibc) 257 { 258 LIBCLOG_ENTER("pszNativePath=%p:{%s} fLibc=%#x\n", (void *)pszNativePath, pszNativePath, fLibc); 259 260 /* setting up a temporary handle; allocate buffer and suchlike. */ 258 * @param pStat Pointer to the stat structure for the directory. 259 */ 260 int __libc_Back_dirOpenNative(char *pszNativePath, unsigned fInUnixTree, unsigned fLibc, struct stat *pStat) 261 { 262 LIBCLOG_ENTER("pszNativePath=%p:{%s} fInUnixTree=%d fLibc=%#x pStat=%p\n", (void *)pszNativePath, pszNativePath, fInUnixTree, fLibc, (void *)pStat); 263 264 /* 265 * Validate input. 266 */ 267 if (!S_ISDIR(pStat->st_mode)) 268 LIBCLOG_ERROR_RETURN_INT(-ENOTDIR); 269 if ((fLibc & O_ACCMODE) != O_RDONLY) 270 LIBCLOG_ERROR_RETURN_INT(-EISDIR); 271 if ((fLibc & (O_EXCL | O_CREAT)) == (O_EXCL | O_CREAT)) 272 LIBCLOG_ERROR_RETURN_INT(-EEXIST); 273 if (fLibc & (O_TRUNC | O_APPEND)) 274 LIBCLOG_ERROR_RETURN_INT(-EPERM); 275 if (fLibc & (O_TRUNC | O_APPEND | O_SIZE)) 276 LIBCLOG_ERROR_RETURN_INT(-EINVAL); 277 278 /* 279 * Directory handles are binary, period. 280 */ 281 fLibc &= ~O_TEXT; 282 fLibc |= O_BINARY; 283 284 /* 285 * Setting up a temporary handle; allocate buffer and suchlike. 286 */ 261 287 int rc = -ENOMEM; 262 288 __LIBC_FHDIR Tmp; … … 314 340 pFHDir->fType = Tmp.fType; 315 341 pFHDir->uBuf.pv = Tmp.uBuf.pv; 316 pFHDir->uCur.pv = Tmp.u Buf.pv; /* (this is correct) */342 pFHDir->uCur.pv = Tmp.uCur.pv; 317 343 pFHDir->cFiles = Tmp.cFiles; 318 344 pFHDir->cbBuf = Tmp.cbBuf; 319 345 320 346 FS_RESTORE(); 347 LIBCLOG_MSG("pFHDir=%p:{.hDir=%#lx, .fType=%d, .cFiles=%ld, .cbBuf=%#x} fh=%d\n", 348 (void *)pFHDir, pFHDir->hDir, pFHDir->fType, pFHDir->cFiles, pFHDir->cbBuf, fh); 321 349 LIBCLOG_RETURN_INT(fh); 322 350 } 351 352 /* bailout */ 323 353 DosFindClose(Tmp.hDir); 324 354 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_dir.h
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r2315 r2316 39 39 /** The directory handle. */ 40 40 HDIR hDir; 41 /** Set if the path is in the unix tree, else clear. 42 * This is for fchdir() handling. */ 43 unsigned fInUnixTree; 41 44 /** The find operation type. */ 42 45 unsigned fType; … … 67 70 68 71 69 int __libc_Back_dirOpenNative(char *pszNativePath, unsigned f Libc);72 int __libc_Back_dirOpenNative(char *pszNativePath, unsigned fInUnixTree, unsigned fLibc, struct stat *pStat); 70 73 71 74 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_fsFileStatFH.c
-
Property cvs2svn:cvs-rev
changed from
1.9
to1.10
r2315 r2316 4 4 * LIBC SYS Backend - fstat. 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 * 8 8 * … … 142 142 */ 143 143 /* Times: FAT might not return create and access time. */ 144 pStat->st_ mtime = _sys_p2t(info.fsts4.ftimeLastWrite, info.fsts4.fdateLastWrite);144 pStat->st_ctime = pStat->st_mtime = _sys_p2t(info.fsts4.ftimeLastWrite, info.fsts4.fdateLastWrite); 145 145 if ( FTIMEZEROP(info.fsts4.ftimeCreation) 146 146 && FDATEZEROP(info.fsts4.fdateCreation)) 147 pStat->st_ ctime = pStat->st_mtime;148 else 149 pStat->st_ ctime = _sys_p2t(info.fsts4.ftimeCreation, info.fsts4.fdateCreation);147 pStat->st_birthtime = pStat->st_mtime; 148 else 149 pStat->st_birthtime = _sys_p2t(info.fsts4.ftimeCreation, info.fsts4.fdateCreation); 150 150 if ( FTIMEZEROP(info.fsts4.ftimeLastAccess) 151 151 && FDATEZEROP(info.fsts4.fdateLastAccess)) … … 237 237 //} 238 238 239 LIBCLOG_MSG("st_dev: %#x\n", pStat->st_dev); 240 LIBCLOG_MSG("st_ino: %#018llx\n",pStat->st_ino); 241 LIBCLOG_MSG("st_mode: 0%o\n", pStat->st_mode); 242 LIBCLOG_MSG("st_nlink: %u\n", pStat->st_nlink); 243 LIBCLOG_MSG("st_uid: %u\n", pStat->st_uid); 244 LIBCLOG_MSG("st_gid: %u\n", pStat->st_gid); 245 LIBCLOG_MSG("st_rdev: %#x\n", pStat->st_rdev); 246 LIBCLOG_MSG("st_atime: %d\n", pStat->st_atime); 247 LIBCLOG_MSG("st_mtime: %d\n", pStat->st_mtime); 248 LIBCLOG_MSG("st_ctime: %d\n", pStat->st_ctime); 249 LIBCLOG_MSG("st_size: %lld\n", pStat->st_size); 250 LIBCLOG_MSG("st_blocks: %lld\n", pStat->st_blocks); 251 LIBCLOG_MSG("st_blksize: %u\n", pStat->st_blksize); 252 LIBCLOG_MSG("st_attr: %ld\n", pStat->st_attr); 239 LIBCLOG_MSG("%02x - st_dev: %#x\n", offsetof(struct stat, st_dev), pStat->st_dev); 240 LIBCLOG_MSG("%02x - st_attr: %#x\n", offsetof(struct stat, st_attr), pStat->st_attr); 241 LIBCLOG_MSG("%02x - st_ino: %#llx\n",offsetof(struct stat, st_ino), (long long)pStat->st_ino); 242 LIBCLOG_MSG("%02x - st_mode: %#x\n", offsetof(struct stat, st_mode), pStat->st_mode); 243 LIBCLOG_MSG("%02x - st_nlink: %u\n", offsetof(struct stat, st_nlink), pStat->st_nlink); 244 LIBCLOG_MSG("%02x - st_uid: %u\n", offsetof(struct stat, st_uid), pStat->st_uid); 245 LIBCLOG_MSG("%02x - st_gid: %u\n", offsetof(struct stat, st_gid), pStat->st_gid); 246 LIBCLOG_MSG("%02x - st_rdev: %#x\n", offsetof(struct stat, st_rdev), pStat->st_rdev); 247 LIBCLOG_MSG("%02x - st_lspare: %#x\n", offsetof(struct stat, st_lspare), pStat->st_lspare); 248 LIBCLOG_MSG("%02x - st_atime: %d\n", offsetof(struct stat, st_atime), pStat->st_atime); 249 LIBCLOG_MSG("%02x - st_mtime: %d\n", offsetof(struct stat, st_mtime), pStat->st_mtime); 250 LIBCLOG_MSG("%02x - st_ctime: %d\n", offsetof(struct stat, st_ctime), pStat->st_ctime); 251 LIBCLOG_MSG("%02x - st_size: %lld\n", offsetof(struct stat, st_size), (long long)pStat->st_size); 252 LIBCLOG_MSG("%02x - st_blocks: %lld\n", offsetof(struct stat, st_blocks), (long long)pStat->st_blocks); 253 LIBCLOG_MSG("%02x - st_blksize: %u\n", offsetof(struct stat, st_blksize), pStat->st_blksize); 254 LIBCLOG_MSG("%02x - st_flags: %#x\n", offsetof(struct stat, st_flags), pStat->st_flags); 255 LIBCLOG_MSG("%02x - st_gen: %#x\n", offsetof(struct stat, st_gen), pStat->st_gen); 256 LIBCLOG_MSG("%02x - st_birthtime: %d\n", offsetof(struct stat, st_birthtime), pStat->st_birthtime); 253 257 LIBCLOG_RETURN_INT(0); 254 258 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_fsNativeFileStat.c
-
Property cvs2svn:cvs-rev
changed from
1.10
to1.11
r2315 r2316 4 4 * LIBC SYS Backend - internal stat. 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 * … … 128 128 */ 129 129 /* Times: FAT might not return create and access time. */ 130 pStat->st_mtime = _sys_p2t(info.fsts4.ftimeLastWrite, info.fsts4.fdateLastWrite);130 pStat->st_mtime = pStat->st_mtime = _sys_p2t(info.fsts4.ftimeLastWrite, info.fsts4.fdateLastWrite); 131 131 if ( FTIMEZEROP(info.fsts4.ftimeCreation) 132 132 && FDATEZEROP(info.fsts4.fdateCreation)) 133 pStat->st_ ctime = pStat->st_mtime;134 else 135 pStat->st_ ctime = _sys_p2t(info.fsts4.ftimeCreation, info.fsts4.fdateCreation);133 pStat->st_birthtime = pStat->st_mtime; 134 else 135 pStat->st_birthtime = _sys_p2t(info.fsts4.ftimeCreation, info.fsts4.fdateCreation); 136 136 if ( FTIMEZEROP(info.fsts4.ftimeLastAccess) 137 137 && FDATEZEROP(info.fsts4.fdateLastAccess)) … … 204 204 pStat->st_dev = __libc_back_fsPathCalcInodeAndDev(pszNativePath, &pStat->st_ino); 205 205 206 LIBCLOG_MSG("st_dev: %#x\n", pStat->st_dev); 207 LIBCLOG_MSG("st_ino: %#llx\n", pStat->st_ino); 208 LIBCLOG_MSG("st_mode: %#x\n", pStat->st_mode); 209 LIBCLOG_MSG("st_nlink: %u\n", pStat->st_nlink); 210 LIBCLOG_MSG("st_uid: %u\n", pStat->st_uid); 211 LIBCLOG_MSG("st_gid: %u\n", pStat->st_gid); 212 LIBCLOG_MSG("st_rdev: %#x\n", pStat->st_rdev); 213 LIBCLOG_MSG("st_atime: %d\n", pStat->st_atime); 214 LIBCLOG_MSG("st_mtime: %d\n", pStat->st_mtime); 215 LIBCLOG_MSG("st_ctime: %d\n", pStat->st_ctime); 216 LIBCLOG_MSG("st_size: %lld\n", pStat->st_size); 217 LIBCLOG_MSG("st_blocks: %lld\n", pStat->st_blocks); 218 LIBCLOG_MSG("st_blksize: %u\n", pStat->st_blksize); 219 LIBCLOG_MSG("st_attr: %ld\n", pStat->st_attr); 206 LIBCLOG_MSG("%02x - st_dev: %#x\n", offsetof(struct stat, st_dev), pStat->st_dev); 207 LIBCLOG_MSG("%02x - st_attr: %#x\n", offsetof(struct stat, st_attr), pStat->st_attr); 208 LIBCLOG_MSG("%02x - st_ino: %#llx\n",offsetof(struct stat, st_ino), (long long)pStat->st_ino); 209 LIBCLOG_MSG("%02x - st_mode: %#x\n", offsetof(struct stat, st_mode), pStat->st_mode); 210 LIBCLOG_MSG("%02x - st_nlink: %u\n", offsetof(struct stat, st_nlink), pStat->st_nlink); 211 LIBCLOG_MSG("%02x - st_uid: %u\n", offsetof(struct stat, st_uid), pStat->st_uid); 212 LIBCLOG_MSG("%02x - st_gid: %u\n", offsetof(struct stat, st_gid), pStat->st_gid); 213 LIBCLOG_MSG("%02x - st_rdev: %#x\n", offsetof(struct stat, st_rdev), pStat->st_rdev); 214 LIBCLOG_MSG("%02x - st_lspare: %#x\n", offsetof(struct stat, st_lspare), pStat->st_lspare); 215 LIBCLOG_MSG("%02x - st_atime: %d\n", offsetof(struct stat, st_atime), pStat->st_atime); 216 LIBCLOG_MSG("%02x - st_mtime: %d\n", offsetof(struct stat, st_mtime), pStat->st_mtime); 217 LIBCLOG_MSG("%02x - st_ctime: %d\n", offsetof(struct stat, st_ctime), pStat->st_ctime); 218 LIBCLOG_MSG("%02x - st_size: %lld\n", offsetof(struct stat, st_size), (long long)pStat->st_size); 219 LIBCLOG_MSG("%02x - st_blocks: %lld\n", offsetof(struct stat, st_blocks), (long long)pStat->st_blocks); 220 LIBCLOG_MSG("%02x - st_blksize: %u\n", offsetof(struct stat, st_blksize), pStat->st_blksize); 221 LIBCLOG_MSG("%02x - st_flags: %#x\n", offsetof(struct stat, st_flags), pStat->st_flags); 222 LIBCLOG_MSG("%02x - st_gen: %#x\n", offsetof(struct stat, st_gen), pStat->st_gen); 223 LIBCLOG_MSG("%02x - st_birthtime: %d\n", offsetof(struct stat, st_birthtime), pStat->st_birthtime); 220 224 LIBCLOG_RETURN_INT(0); 221 225 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_ioFileOpen.c
-
Property cvs2svn:cvs-rev
changed from
1.10
to1.11
r2315 r2316 41 41 #include <share.h> 42 42 #include <sys/stat.h> 43 #include <sys/fcntl.h> 43 44 #include <emx/umalloc.h> 44 45 #include <emx/syscalls.h> … … 53 54 54 55 /** 55 * Opens a file.56 * Opens or creates a file. 56 57 * 57 58 * @returns Filehandle to the opened file on success. 58 59 * @returns Negative error code (errno.h) on failure. 59 60 * @param pszFile Path to the file. 60 * @param fFlags Open flags. 61 * @param fLibc The LIBC open flags (O_*). 62 * @param fShare The share flags (SH_*). 61 63 * @param cbInitial Initial filesize. 62 64 * @param Mode The specified permission mask. 63 * @param fLibc LIBC filehandle flags.64 65 * @param ppFH Where to store the LIBC filehandle structure which was created 65 66 * for the opened file. 66 67 */ 67 int __libc_Back_ioFileOpen(const char *pszFile, int fFlags, off_t cbInitial, mode_t Mode, unsigned fLibc, PLIBCFH *ppFH)68 int __libc_Back_ioFileOpen(const char *pszFile, unsigned fLibc, int fShare, off_t cbInitial, mode_t Mode, PLIBCFH *ppFH) 68 69 { 69 LIBCLOG_ENTER("pszFile=%s fFlags=%#x cbInitial=%lld Mode=0%o fLibc=%#x ppFH=%p\n", 70 pszFile, fFlags, cbInitial, Mode, fLibc, (void*)ppFH); 71 FS_VAR(); 70 LIBCLOG_ENTER("pszFile=%p:{%s} fLibc=%#x fShare=%#x cbInitial=%lld Mode=0%o ppFH=%p\n", 71 pszFile, pszFile, fLibc, fShare, cbInitial, Mode, (void*)ppFH); 72 73 /* 74 * Validate input. 75 */ 76 if ( (fLibc & O_ACCMODE) == O_RDONLY 77 && (fLibc & (O_TRUNC | O_CREAT))) 78 LIBCLOG_ERROR_RETURN_INT(-EINVAL); 72 79 73 80 /* 74 81 * The SH_COMPAT mode is weird and unless supported by the host we map it to SH_DENYNO. 75 82 */ 76 if ((fFlags & SH_MASK) == SH_COMPAT) 77 fFlags = (fFlags & ~SH_MASK) | SH_DENYNO; 78 79 /* 80 * Extract the access mode and sharing mode bits. 81 */ 82 ULONG flOpenMode = fFlags & 0x77; 83 84 /* 85 * File O_NOINHERIT and O_SYNC. 86 */ 87 if (fFlags & _SO_NOINHERIT) 83 fShare &= SH_MASK; 84 if (fShare == SH_COMPAT) 85 fShare = SH_DENYNO; 86 87 /* 88 * Correct the initial size. 89 */ 90 if (!(fLibc & O_SIZE)) 91 cbInitial = 0; 92 93 /* 94 * Calc the open mode mask from the libc flags and the shared flags in flFlags. 95 * Assumes: OPEN_ACCESS_READONLY == O_RDONLY 96 * OPEN_ACCESS_WRITEONLY == O_WRONLY 97 * OPEN_ACCESS_READWRITE == O_RDWR 98 */ 99 ULONG flOpenMode = fShare & SH_MASK; 100 flOpenMode |= fLibc & O_ACCMODE; 101 if (fLibc & O_NOINHERIT) 88 102 flOpenMode |= OPEN_FLAGS_NOINHERIT; 89 if (fFlags & _SO_SYNC) 103 104 if (fLibc & (O_FSYNC | O_SYNC)) 90 105 flOpenMode |= OPEN_FLAGS_WRITE_THROUGH; 91 92 /* 93 * Extract the file flAttribute bits. 94 */ 95 ULONG flAttr = (fFlags >> 8) & 0xff; 96 if (__libc_gfsUMask & S_IWUSR) 97 flAttr |= FILE_READONLY; 106 if (fLibc & O_DIRECT) 107 flOpenMode |= OPEN_FLAGS_NO_CACHE; 98 108 99 109 /* … … 103 113 104 114 /* 105 * Compute `flOpenFlags' depending on `fFlags'. Note that _SO_CREAT is 106 * set for O_CREAT. 115 * Compute the flOpenFlags using fLibc. 107 116 */ 108 117 ULONG flOpenFlags; 109 if (f Flags & _SO_CREAT)110 { 111 if (f Flags & _SO_EXCL)118 if (fLibc & O_CREAT) 119 { 120 if (fLibc & O_EXCL) 112 121 { 113 122 flOpenFlags = OPEN_ACTION_FAIL_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; 114 123 rcOpenFailed = -EEXIST; 115 124 } 116 else if (f Flags & _SO_TRUNC)125 else if (fLibc & O_TRUNC) 117 126 flOpenFlags = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; 118 127 else 119 128 flOpenFlags = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW; 120 129 } 121 else if (fFlags & _SO_TRUNC)122 flOpenFlags = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW;123 130 else 124 flOpenFlags = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW; 125 126 if (!(fFlags & _SO_SIZE)) 127 cbInitial = 0; 131 { 132 fLibc &= ~O_EXCL; /* O_EXCL doesn't make sense without O_CREAT */ 133 if (fLibc & O_TRUNC) 134 flOpenFlags = OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW; 135 else 136 flOpenFlags = OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW; 137 } 128 138 129 139 /* 130 140 * Resolve the specified file path. 131 141 */ 132 char szNativePath[PATH_MAX + 5]; 142 char szNativePath[PATH_MAX + 4]; 143 int fInUnixTree = 0; 133 144 int rc = __libc_back_fsResolve(pszFile, 134 145 (flOpenFlags & OPEN_ACTION_FAIL_IF_NEW 135 ? BACKFS_FLAGS_RESOLVE_FULL | BACKFS_FLAGS_RESOLVE_DIR_MAYBE 136 : BACKFS_FLAGS_RESOLVE_FULL_MAYBE | BACKFS_FLAGS_RESOLVE_DIR_MAYBE), 146 ? fLibc & O_NOFOLLOW 147 ? BACKFS_FLAGS_RESOLVE_FULL_SYMLINK | BACKFS_FLAGS_RESOLVE_DIR_MAYBE 148 : BACKFS_FLAGS_RESOLVE_FULL | BACKFS_FLAGS_RESOLVE_DIR_MAYBE 149 : fLibc & O_NOFOLLOW 150 ? BACKFS_FLAGS_RESOLVE_FULL_SYMLINK_MAYBE | BACKFS_FLAGS_RESOLVE_DIR_MAYBE 151 : BACKFS_FLAGS_RESOLVE_FULL_MAYBE | BACKFS_FLAGS_RESOLVE_DIR_MAYBE), 137 152 &szNativePath[0], 138 NULL);153 &fInUnixTree); 139 154 if (rc) 140 155 LIBCLOG_ERROR_RETURN_INT(rc); 141 156 142 /*143 * Create Unix attributes for a new file.144 */145 157 dev_t Dev = 0; 146 158 ino_t Inode = 0; 147 159 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 } 160 if (!__libc_gfNoUnix) 161 { 162 /* 163 * Stat the file to see if it's there, and if it is what kind of file it is. 164 * For some of the file types there are race conditions involved, but we don't care. 165 */ 166 struct stat st; 167 rc = __libc_back_fsNativeFileStat(szNativePath, &st); 168 if (!rc) 169 { 170 /* 171 * If we're truncating a file and no Mode bits are specified, we'll 172 * use the ones from the original file. 173 */ 174 /** @todo Check if O_TRUNC and the OS/2 semantics really match.. I don't think O_TRUNC mean replace really. */ 175 Mode &= ALLPERMS; 176 if (!Mode && (fLibc & (O_CREAT | O_TRUNC)) == O_TRUNC) 177 Mode = st.st_mode; 178 179 /* 180 * Take action based on the type of file we're facing. 181 */ 182 switch (st.st_mode & S_IFMT) 183 { 184 /* 185 * Regular file: Presently we don't have to do anything special. 186 */ 187 case S_IFREG: 188 /** @todo handle st_flags. */ 189 break; 190 191 /* 192 * Directory: Open it as a directory. 193 */ 194 case S_IFDIR: 195 { 196 rc = __libc_Back_dirOpenNative(szNativePath, fInUnixTree, fLibc, &st); 197 if (rc >= 0) 198 LIBCLOG_RETURN_INT(rc); 199 LIBCLOG_ERROR_RETURN_INT(rc); 200 break; 201 } 202 203 /* 204 * Named Pipe: Open / create the named pipe. 205 */ 206 case S_IFIFO: 207 { 208 /** @todo implement named pipes. */ 209 LIBCLOG_ERROR_RETURN_INT(-ENOTSUP); 210 } 211 212 /* 213 * Character device or Block device: 214 * Translate the major/minor to an OS/2 device name and open that. 215 */ 216 case S_IFCHR: 217 case S_IFBLK: 218 { 219 /** @todo assign major & minor numbers and do translations. */ 220 LIBCLOG_ERROR_RETURN_INT(-ENOTSUP); 221 } 222 223 /* 224 * Symbolic link: These cannot be opened by open(). 225 */ 226 case S_IFLNK: 227 LIBCLOG_ERROR_RETURN_INT(-EMLINK); 228 229 230 /* 231 * Local socket: Open the local socket. 232 */ 233 case S_IFSOCK: 234 { 235 /** @todo integrate sockets with libc. */ 236 LIBCLOG_ERROR_RETURN_INT(-ENOTSUP); 237 } 238 239 /* 240 * Stat cannot return anything else. 241 */ 242 default: 243 __libc_Back_panic(0, NULL, "Invalid file type returned in st_mode=0x%x for '%s'\n", st.st_mode, szNativePath); 244 break; 245 } 246 } 247 /* else: didn't find it, just go ahead. */ 248 249 /* 250 * Create Unix attributes for a file which is potentially created / replaced. 251 */ 252 if (flOpenFlags & (OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS)) 253 { 254 pEaOp2 = alloca(sizeof(EAOP2) + sizeof(__libc_gFsUnixAttribsCreateFEA2List)); 255 struct __LIBC_FSUNIXATTRIBSCREATEFEA2LIST *pFEas = (struct __LIBC_FSUNIXATTRIBSCREATEFEA2LIST *)(pEaOp2 + 1); 256 *pFEas = __libc_gFsUnixAttribsCreateFEA2List; 257 Dev = __libc_back_fsUnixAttribsInit(pFEas, szNativePath, Mode); 258 Inode = pFEas->u64INO; 259 pEaOp2->fpGEA2List = NULL; 260 pEaOp2->fpFEA2List = (PFEA2LIST)pFEas; 261 pEaOp2->oError = 0; 262 } 263 } 264 265 /* 266 * Normalize the mode mask and calc the file attributes. 267 */ 268 Mode &= ~__libc_gfsUMask; 269 Mode &= ACCESSPERMS; 270 Mode |= S_IFREG; 271 272 ULONG flAttr = Mode & S_IWUSR ? FILE_NORMAL : FILE_READONLY; 164 273 165 274 /* 166 275 * Try to open the file. 167 276 */ 168 FS_ SAVE_LOAD();277 FS_VAR_SAVE_LOAD(); 169 278 ULONG cExpandRetries; 170 279 ULONG ulAction; … … 211 320 if (!rc) 212 321 { 213 ULONG fulType;214 ULONG fulDevFlags;215 216 322 /* 217 323 * Figure the handle type. 218 324 */ 325 ULONG fulType; 326 ULONG fulDevFlags; 219 327 rc = DosQueryHType(hFile, &fulType, &fulDevFlags); 220 if ( !rc)328 if (__predict_true(!rc)) 221 329 { 222 330 switch (fulType & 0xff) … … 245 353 break; 246 354 case HANDTYPE_PIPE: 247 fLibc |= F_PIPE; 355 fLibc |= F_PIPE; /** @todo this is a named pipe! */ 248 356 Dev = makedev('p', 0); 249 357 __libc_back_fsPathCalcInodeAndDev(szNativePath, &Inode); … … 256 364 __LIBC_PFH pFH; 257 365 rc = __libc_FHAllocate(hFile, fLibc, sizeof(LIBCFH), NULL, &pFH, NULL); 258 if ( !rc)366 if (__predict_true(!rc)) 259 367 { 260 pFH->Inode = Inode;261 pFH->Dev = Dev;262 pFH->pFsInfo = __libc_back_fsInfoObjByDev(Dev);263 pFH->pszNativePath = _hstrdup(szNativePath);368 pFH->Inode = Inode; 369 pFH->Dev = Dev; 370 pFH->pFsInfo = __libc_back_fsInfoObjByDev(Dev); 371 pFH->pszNativePath = _hstrdup(szNativePath); 264 372 265 373 if (ppFH) 266 374 *ppFH = pFH; 375 FS_RESTORE(); 267 376 LIBCLOG_MSG("pFH=%p hFile=%#lx fLibc=%#x fulType=%#lx ulAction=%lu Dev=%#x Inode=%#llx\n", 268 377 (void *)pFH, hFile, fLibc, fulType, ulAction, Dev, Inode); … … 273 382 DosClose(hFile); 274 383 } 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 #endif288 384 FS_RESTORE(); 289 385 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/filehandles.c
-
Property cvs2svn:cvs-rev
changed from
1.24
to1.25
r2315 r2316 541 541 { 542 542 /* 543 * Preallocated or heap? 543 * Free and zero resources referenced by the handle. 544 */ 545 pFH->fFlags = 0; 546 pFH->iLookAhead = 0; 547 pFH->pOps = NULL; 548 pFH->Dev = 0; 549 pFH->Inode = 0; 550 if (pFH->pFsInfo) 551 { 552 __libc_back_fsInfoObjRelease(pFH->pFsInfo); 553 pFH->pFsInfo = NULL; 554 } 555 if (pFH->pszNativePath) 556 { 557 free(pFH->pszNativePath); 558 pFH->pszNativePath = NULL; 559 } 560 561 /* 562 * Free the handle it self. 544 563 */ 545 564 if ( pFH >= &gaPreAllocated[0] 546 565 && pFH < &gaPreAllocated[sizeof(gaPreAllocated) / sizeof(gaPreAllocated[0])]) 547 {548 pFH->fFlags = 0;549 pFH->iLookAhead = 0;550 pFH->pOps = NULL;551 566 gcPreAllocatedAvail++; 552 }553 567 else 554 568 free(pFH); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/fs.c
-
Property cvs2svn:cvs-rev
changed from
1.23
to1.24
r2315 r2316 1392 1392 pStat->st_rdev = u32; 1393 1393 else if (COMPARE_EANAME(__libc_gszGenEA)) 1394 /* pStat->st_gen = u32 - not implemented */;1394 pStat->st_gen = u32; 1395 1395 else if (COMPARE_EANAME(__libc_gszFlagsEA)) 1396 /* pStat->st_flags = u32 - not implemented */;1396 pStat->st_flags = u32; 1397 1397 else 1398 1398 LIBC_ASSERTM_FAILED("Huh?!? got an ea named '%s', namelen=%d! u32=%#x (%d)\n", pFea2->szName, pFea2->cbName, u32, u32); -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.