Changeset 2090
- Timestamp:
- Jun 27, 2005, 5:30:23 AM (20 years ago)
- Location:
- trunk/src/emx
- Files:
-
- 3 added
- 40 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/ChangeLog.LIBC
-
Property cvs2svn:cvs-rev
changed from
1.65
to1.66
r2089 r2090 1 1 /* $Id$ */ 2 3 2005-06-26: knut st. osmundsen <bird-gccos2-spam@anduin.net> 4 - libc: 5 o Added [__]isinf[fl] which seems to have been mislaid during the 6 math source import. 7 o Rewrote the libcXXXX.dll install rule to not play with emxload since 8 emxload sticks around when first loaded. 9 o Made unsetenv() cause tzset reload just like putenv() and setenv(). 10 o Changed putenv() behaviour for removal (no '=' in input) to be identical 11 to unsetenv(). This solves duplicate variable testcase. 12 o Changed filestreams opened for both reading and writing to switch 13 more willingly between read and write mode. 14 o Made sscan() return EOF on EOF. 15 o Made sscan() skip blanks in input for '%%'. 16 o Implemented the stdio_unlocked stuff with BSD and GLIBC extension. 17 TODO: Require a new locktype which support recursive usage! Currently 18 a hack using 8 free flag bits is used. 19 o Corrected realpath() behaviour to return the path up to the failure 20 point on error. _realrealpath() also does this now. 21 (This also saves us a temp buffer and a copy of the result.) 22 o Fixed a bug in the handling of ".." in the path resolver. 23 o Extended that path resolver to check the directoryness of the input 24 according to flags and any trailing slashes. 25 o Change the path resolver to be very strict about UNC - UNC have exactly 26 two slashes at the start of the path. 2 27 3 28 2005-06-25: knut st. osmundsen <bird-gccos2-spam@anduin.net> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/emx/io.h
-
Property cvs2svn:cvs-rev
changed from
1.15
to1.16
r2089 r2090 8 8 #include <InnoTekLIBC/fork.h> 9 9 #include <alloca.h> 10 #include <stdio.h> 10 11 11 12 __BEGIN_DECLS … … 148 149 #define _IONOCLOSEALL 0x00020000 149 150 151 /** This bit is set when the stream is locked by flockfile() or ftrylockfile(). 152 * !!TEMPORARY HACK!! 153 * @todo replace the fmutex on the stream with a recursive lock! */ 154 #define _IOLOCKED 0xff000000 150 155 151 156 #define _FLUSH_FLUSH (-1) … … 192 197 193 198 #if defined (_SYS_FMUTEX_H) 194 195 199 /* This semaphore (defined in app/stdio.c) protects _streamv[]. Only 196 200 concurrent access by _newstream(), _setmore(), and freopen() in … … 204 208 #define STREAMV_LOCK _fmutex_checked_request(&_streamv_fmutex, _FMR_IGNINT) 205 209 #define STREAMV_UNLOCK _fmutex_checked_release(&_streamv_fmutex) 206 207 #define STREAM_LOCK(f) \ 208 ((f)->__uVersion != _FILE_STDIO_VERSION ? __stream_abort (f, "version error") \ 209 : _fmutex_request(&(f)->__u.__fsem, _FMR_IGNINT) != 0 \ 210 ? __stream_abort (f, "fmutex request") : 0) 211 212 #define STREAM_UNLOCK(f) \ 213 (_fmutex_release(&(f)->__u.__fsem) != 0 ? __stream_abort (f, "fmutex release") : (void)0) 214 215 #define STREAM_LOCK_NOWAIT(f) \ 216 (((f)->__uVersion == _FILE_STDIO_VERSION || __stream_abort (f, "version error")) && _fmutex_request(&(f)->__u.__fsem, _FMR_NOWAIT) == 0) 217 218 #define STREAM_UNLOCKED(f) ((f)->__uVersion == _FILE_STDIO_VERSION && _fmutex_available(&(f)->__u.__fsem)) 210 #endif /* _SYS_FMUTEX_H */ 211 212 #if defined (__FILE_FSEM_DECLARED) 219 213 220 214 int __stream_abort(struct _FILE *f, const char *pszMsg); 221 215 222 #endif /* defined (_SYS_FMUTEX_H) */ 216 static int __inline__ stream_validate(struct _FILE *stream) 217 { 218 if (stream->__uVersion != _FILE_STDIO_VERSION) 219 { 220 __stream_abort(stream, "version error"); 221 return 0; 222 } 223 return 1; 224 } 225 226 static int __inline__ stream_lock(struct _FILE *stream) 227 { 228 if (!stream_validate(stream)) 229 return 0; 230 if ( !(stream->_flags & _IOLOCKED) 231 || !_fmutex_is_owner(&stream->__u.__fsem)) 232 { 233 if (_fmutex_request(&stream->__u.__fsem, _FMR_IGNINT) != 0) 234 { 235 __stream_abort(stream, "fmutex_request failed"); 236 return 0; 237 } 238 stream->_flags = 0x01000000 | (stream->_flags & ~_IOLOCKED); 239 } 240 else 241 stream->_flags = ((stream->_flags & _IOLOCKED) + 0x01000000) | (stream->_flags & ~_IOLOCKED); 242 return 1; 243 } 244 245 static int __inline__ stream_trylock(struct _FILE *stream) 246 { 247 if (!stream_validate(stream)) 248 return 0; 249 if ( !(stream->_flags & _IOLOCKED) 250 || !_fmutex_is_owner(&stream->__u.__fsem)) 251 { 252 if (_fmutex_request(&stream->__u.__fsem, _FMR_NOWAIT) != 0) 253 { 254 __stream_abort(stream, "fmutex_request failed"); 255 return 0; 256 } 257 stream->_flags = 0x01000000 | (stream->_flags & ~_IOLOCKED); 258 } 259 else 260 stream->_flags = ((stream->_flags & _IOLOCKED) + 0x01000000) | (stream->_flags & ~_IOLOCKED); 261 return 1; 262 } 263 264 static int __inline__ stream_unlock(struct _FILE *stream) 265 { 266 if (!stream_validate(stream)) 267 return 0; 268 if (!(stream->_flags & _IOLOCKED)) 269 { 270 __stream_abort(stream, "unlock, 0 count"); 271 return 0; 272 } 273 #ifdef __LIBC_STRICT 274 if (!_fmutex_is_owner(&stream->__u.__fsem)) 275 { 276 __stream_abort(stream, "unlock, not owner"); 277 return 0; 278 } 279 #endif 280 stream->_flags = ((stream->_flags & _IOLOCKED) - 0x01000000) | (stream->_flags & ~_IOLOCKED); 281 if ( !(stream->_flags & _IOLOCKED) 282 && _fmutex_release(&stream->__u.__fsem) != 0) 283 { 284 __stream_abort(stream, "fmutex_release failed"); 285 return 0; 286 } 287 return 1; 288 } 289 290 #define STREAM_LOCK(f) stream_lock(f) 291 #define STREAM_UNLOCK(f) stream_unlock(f) 292 #define STREAM_LOCK_NOWAIT(f) stream_trylock(f) 293 #define STREAM_UNLOCKED(f) ((f)->__uVersion == _FILE_STDIO_VERSION && _fmutex_available(&(f)->__u.__fsem)) 294 295 #endif /* __FILE_FSEM_DECLARED */ 223 296 224 297 struct __libc_FileHandle; … … 434 507 int _flushstream (struct _FILE *, int); 435 508 void _closestream (struct _FILE *); 436 int _fflush_nolock (struct _FILE *); 437 int _fseek_nolock (struct _FILE *, off_t, int); 438 off_t _ftell_nolock (struct _FILE *); 439 size_t _fwrite_nolock (const void *, size_t, size_t, struct _FILE *); 509 int _fseek_unlocked (struct _FILE *, off_t, int); 510 off_t _ftello_unlocked (struct _FILE *); 440 511 int _input (struct _FILE *, __const__ char *, char *); 441 512 struct _FILE *_newstream (void); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/stdio.h
-
Property cvs2svn:cvs-rev
changed from
1.14
to1.15
r2089 r2090 200 200 { 201 201 #if defined (_SYS_FMUTEX_H) 202 #define __FILE_FSEM_DECLARED 203 /** @todo replace this by a nested lock construct, see flockfile(). */ 202 204 _fmutex __fsem; 203 205 #endif … … 287 289 long ftell(FILE *); 288 290 size_t fwrite(const void * __restrict, size_t, size_t, FILE * __restrict); 289 #if 0 /* bird: emx */290 291 int getc(FILE *); 291 #else /* bird: emx */292 /** @todo: Check the standard, if this is correct or not. declaration might be required. */293 #define getc(s) fgetc(s) /* bird: emx */294 #endif /* bird: emx */295 292 int getchar(void); 296 293 char *gets(char *); 297 294 void perror(const char *); 298 295 int printf(const char * __restrict, ...); 299 #if 0 /* bird: emx */300 296 int putc(int, FILE *); 301 #else /* bird: emx */302 /** @todo: Check the standard, if this is correct or not. declaration might be required. */303 #define putc(c,s) fputc(c,s) /* bird: emx */304 #endif /* bird: emx */305 297 int putchar(int); 306 298 int puts(const char *); … … 356 348 357 349 #if __POSIX_VISIBLE >= 199506 358 /** @todo int ftrylockfile(FILE *); */ 359 /** @todo void flockfile(FILE *); */ 360 /** @todo void funlockfile(FILE *); */ 350 int ftrylockfile(FILE *); 351 void flockfile(FILE *); 352 void funlockfile(FILE *); 361 353 362 354 /* … … 364 356 * requires functions as well. 365 357 */ 366 /** @todo int getc_unlocked(FILE *); */ 367 /** @todo int getchar_unlocked(void); */ 368 /** @todo int putc_unlocked(int, FILE *); */ 369 /** @todo int putchar_unlocked(int); */ 358 int getc_unlocked(FILE *); 359 int getchar_unlocked(void); 360 int putc_unlocked(int, FILE *); 361 int putchar_unlocked(int); 370 362 #endif 371 363 #if __BSD_VISIBLE 372 /** @todo void clearerr_unlocked(FILE *); */ 373 /** @todo int feof_unlocked(FILE *); */ 374 /** @todo int ferror_unlocked(FILE *); */ 375 /** @todo int fileno_unlocked(FILE *); */ 364 void clearerr_unlocked(FILE *); 365 int feof_unlocked(FILE *); 366 int ferror_unlocked(FILE *); 367 int fileno_unlocked(FILE *); 368 #endif 369 #ifdef __USE_MISC 370 int fflush_unlocked(FILE *); 371 size_t fwrite_unlocked(const void * __restrict, size_t, size_t, FILE * __restrict); 372 size_t fread_unlocked(void * __restrict, size_t, size_t, FILE * __restrict); 373 int fgetc_unlocked(FILE *); 374 int fputc_unlocked(int, FILE *); 375 int fputs_unlocked(const char * __restrict, FILE * __restrict); 376 int puts_unlocked(const char *); 376 377 #endif 377 378 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/sys/fmutex.h
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r2089 r2090 104 104 } 105 105 106 107 static __inline__ int _fmutex_is_owner (_fmutex *sem) 108 { 109 return sem->fs > _FMS_AVAILABLE && sem->Owner == fibGetTidPid(); 110 } 111 106 112 /** 107 113 * Release a semaphore in the child process after the -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/app/putenv.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r2089 r2090 22 22 LIBCLOG_RETURN_INT(-1); 23 23 } 24 _tzset_flag = 0; /* Call tzset() */ 24 25 25 s = strchr(string, '='); 26 26 if (s == NULL) 27 len = strlen(string); /* Use complete string */ 28 else 29 len = s - string; 27 { 28 /* remove string, let unset do the work */ 29 int rc = unsetenv(string); 30 LIBCLOG_RETURN_INT(rc); 31 } 32 33 /* insert/replace */ 34 len = s - string; 30 35 p = environ; 31 36 env_size = 0; … … 73 78 LIBCLOG_MSG("replacing '%s' with '%s'\n", *p, string); 74 79 *p = (char *)string; 75 /** @todo this doesn't match the unset policy, we should remove the76 variable entirely from the environment when no value is77 specified! */78 80 } 81 82 _tzset_flag = 0; /* Call tzset() */ 79 83 LIBCLOG_RETURN_INT(0); 80 84 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/app/unsetenv.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r2089 r2090 17 17 #include <errno.h> 18 18 #include <emx/startup.h> 19 #include <emx/time.h> 19 20 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_ENV 20 21 #include <InnoTekLIBC/logstrict.h> … … 37 38 int lenname; 38 39 char ** p; 39 40 40 41 41 /* validate input */ … … 62 62 break; 63 63 LIBCLOG_MSG("deleted '%s'\n", s); 64 _tzset_flag = 0; /* Call tzset() */ 64 65 } 65 66 else -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/_fill.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r2089 r2090 34 34 } 35 35 36 /* Fail if the stream is in write mode. */36 /* switch to read mode if necessary. */ 37 37 38 38 if (stream->_flags & _IOWRT) 39 39 { 40 stream->_flags |= _IOERR; 41 errno = EACCES; 42 return EOF; 40 if (stream->_flags & _IORW) 41 { 42 int rc = _fseek_unlocked (stream, 0, SEEK_CUR); 43 if (rc) 44 return EOF; 45 } 46 if (stream->_flags & _IOWRT) 47 { 48 stream->_flags |= _IOERR; 49 errno = EACCES; 50 return EOF; 51 } 43 52 } 44 53 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/_flush.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r2089 r2090 28 28 } 29 29 30 /* Fail if the stream is in read mode. */30 /* switch to write mode if necessary. */ 31 31 32 32 if (stream->_flags & _IOREAD) 33 33 { 34 stream->_flags |= _IOERR; 35 errno = EACCES; 36 return EOF; 34 if (stream->_flags & _IORW) 35 { 36 int rc = _fseek_unlocked (stream, 0, SEEK_CUR); 37 if (rc) 38 return EOF; 39 } 40 if (stream->_flags & _IOREAD) 41 { 42 stream->_flags |= _IOERR; 43 errno = EACCES; 44 return EOF; 45 } 37 46 } 38 47 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/_input.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r2089 r2090 275 275 if (!ok) 276 276 { 277 make_unread (v, c); 278 v->status = MATCHING_FAILURE; 277 if (c != EOF) 278 { 279 make_unread (v, c); 280 v->status = MATCHING_FAILURE; 281 } 282 else 283 v->status = INPUT_FAILURE; 279 284 return; 280 285 } … … 352 357 if (!ok) 353 358 { 354 make_unread (v, c); 355 v->status = MATCHING_FAILURE; 359 if (c != EOF) 360 { 361 make_unread (v, c); 362 v->status = MATCHING_FAILURE; 363 } 364 else 365 v->status = INPUT_FAILURE; 356 366 return; 357 367 } … … 489 499 if (!ok) 490 500 { 491 make_unread (v, c); 492 v->status = MATCHING_FAILURE; 501 if (c != EOF) 502 { 503 make_unread (v, c); 504 v->status = MATCHING_FAILURE; 505 } 506 else 507 v->status = INPUT_FAILURE; 493 508 return; 494 509 } … … 505 520 if (!isdigit (c)) 506 521 { 507 make_unread (v, c); 508 v->status = MATCHING_FAILURE; 522 if (c != EOF) 523 { 524 make_unread (v, c); 525 v->status = MATCHING_FAILURE; 526 } 527 else 528 v->status = INPUT_FAILURE; 509 529 return; 510 530 } … … 725 745 if (f == 0) /* % at end of string */ 726 746 return v->count; 727 c = get0(v);747 c = skip (v); 728 748 if (c != f) 729 749 return v->count; … … 733 753 { 734 754 case INPUT_FAILURE: 735 return ((v->count == 0) ? EOF : v->count);755 return v->count == 0 ? EOF : v->count; 736 756 case MATCHING_FAILURE: 737 757 case OUT_OF_MEMORY: -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/_output.c
-
Property cvs2svn:cvs-rev
changed from
1.8
to1.9
r2089 r2090 74 74 if (n >= 16) 75 75 { 76 if ( _fwrite_nolock(s, 1, n, v->stream) != n)76 if (fwrite_unlocked (s, 1, n, v->stream) != n) 77 77 return -1; 78 78 v->count += n; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/_tmpbuf.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r2089 r2090 22 22 int result; 23 23 24 result = _fflush_nolock(stream);24 result = fflush_unlocked (stream); 25 25 stream->_buf_size = 1; 26 26 stream->_ptr = stream->_buffer = &stream->_char_buf; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/clearerr.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r2089 r2090 4 4 #include <stdio.h> 5 5 6 void _STD(clearerr) 6 void _STD(clearerr)(FILE *stream) 7 7 { 8 stream->_flags &= ~(_IOERR|_IOEOF);8 stream->_flags &= ~(_IOERR|_IOEOF); 9 9 } 10 11 void _STD(clearerr_unlocked)(FILE *stream) 12 { 13 stream->_flags &= ~(_IOERR|_IOEOF); 14 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/fclose.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r2089 r2090 2 2 3 3 #include "libc-alias.h" 4 #include <stdio.h>5 4 #include <stdlib.h> 6 5 #include <string.h> … … 9 8 #include <sys/fmutex.h> 10 9 #include <emx/io.h> 10 #include <stdio.h> 11 11 12 12 int _STD(fclose) (FILE *stream) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/feof.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r2089 r2090 4 4 #include <stdio.h> 5 5 6 int _STD(feof) 6 int _STD(feof)(FILE *s) 7 7 { 8 return (s->_flags & _IOEOF ? 1 : 0);8 return s->_flags & _IOEOF ? 1 : 0; 9 9 } 10 11 int _STD(feof_unlocked)(FILE *s) 12 { 13 return s->_flags & _IOEOF ? 1 : 0; 14 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/ferror.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r2089 r2090 4 4 #include <stdio.h> 5 5 6 int _STD(ferror) 6 int _STD(ferror)(FILE *s) 7 7 { 8 return (s->_flags & _IOERR ? 1 : 0);8 return s->_flags & _IOERR ? 1 : 0; 9 9 } 10 11 int _STD(ferror_unlocked)(FILE *s) 12 { 13 return s->_flags & _IOERR ? 1 : 0; 14 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/fflush.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r2089 r2090 11 11 #include <emx/io.h> 12 12 13 int _ fflush_nolock(FILE *stream)13 int _STD(fflush_unlocked) (FILE *stream) 14 14 { 15 15 int result, n, ft, saved_errno; … … 50 50 /* ISO 9899-1990, 7.9.5.2: "The fflush function returns EOF if a 51 51 write error occurs, otherwise zero." */ 52 pos = _ftell _nolock(stream);52 pos = _ftello_unlocked (stream); 53 53 if (pos != -1) 54 54 lseek (stream->_handle, pos, SEEK_SET); … … 81 81 82 82 STREAM_LOCK (stream); 83 result = _fflush_nolock(stream);83 result = fflush_unlocked (stream); 84 84 STREAM_UNLOCK (stream); 85 85 return result; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/fgetc.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r2089 r2090 9 9 #include "getputc.h" 10 10 11 int _STD( fgetc)(FILE *stream)11 int _STD(getc)(FILE *stream) 12 12 { 13 int r; 13 return fgetc(stream); 14 } 14 15 15 STREAM_LOCK (stream); 16 r = _getc_inline (stream); 17 STREAM_UNLOCK (stream); 18 return r; 16 int _STD(fgetc)(FILE *stream) 17 { 18 STREAM_LOCK(stream); 19 int rc = _getc_inline(stream); 20 STREAM_UNLOCK(stream); 21 return rc; 19 22 } 23 24 int _STD(getc_unlocked)(FILE *stream) 25 { 26 return fgetc_unlocked(stream); 27 } 28 29 int _STD(fgetc_unlocked)(FILE *stream) 30 { 31 return _getc_inline(stream); 32 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/fileno.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r2089 r2090 4 4 #include <stdio.h> 5 5 6 int _STD(fileno) 6 int _STD(fileno)(FILE *s) 7 7 { 8 return s->_handle;8 return s->_handle; 9 9 } 10 11 int _STD(fileno_unlocked)(FILE *s) 12 { 13 return s->_handle; 14 } 15 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/flushall.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r2089 r2090 22 22 { 23 23 ++n; 24 _fflush_nolock(&sv->aFiles[i]);24 fflush_unlocked (&sv->aFiles[i]); 25 25 STREAM_UNLOCK (&sv->aFiles[i]); 26 26 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/fputc.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r2089 r2090 2 2 3 3 #include "libc-alias.h" 4 #include <sys/builtin.h> /* For <sys/fmutex.h> */5 4 #include <sys/fmutex.h> 6 5 #include <stdio.h> … … 9 8 #include "getputc.h" 10 9 11 int _STD( fputc)(int c, FILE *stream)10 int _STD(putc)(int c, FILE *stream) 12 11 { 13 int r; 12 return fputc(c, stream); 13 } 14 14 15 STREAM_LOCK (stream); 16 r = _putc_inline (c, stream); 17 STREAM_UNLOCK (stream); 18 return r; 15 int _STD(fputc)(int c, FILE *stream) 16 { 17 int r; 18 19 STREAM_LOCK(stream); 20 r = _putc_inline(c, stream); 21 STREAM_UNLOCK(stream); 22 return r; 19 23 } 24 25 int _STD(putc_unlocked)(int c, FILE *stream) 26 { 27 return fputc_unlocked(c, stream); 28 } 29 30 int _STD(fputc_unlocked)(int c, FILE *stream) 31 { 32 int r; 33 34 STREAM_LOCK(stream); 35 r = _putc_inline(c, stream); 36 STREAM_UNLOCK(stream); 37 return r; 38 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/fputs.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r2089 r2090 5 5 #include <string.h> 6 6 7 int _STD(fputs) 7 int _STD(fputs)(const char *string, FILE *stream) 8 8 { 9 int len; 9 int len = strlen (string); 10 return len == 0 || fwrite(string, len, 1, stream) == 1 11 ? 0 : EOF; 12 } 10 13 11 len = strlen (string); 12 return (len == 0 || fwrite (string, len, 1, stream) == 1 ? 0 : EOF); 14 int _STD(fputs_unlocked)(const char *string, FILE *stream) 15 { 16 int len = strlen(string); 17 return len == 0 || fwrite_unlocked(string, len, 1, stream) == 1 18 ? 0 : EOF; 13 19 } 20 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/fread.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r2089 r2090 12 12 #include <emx/io.h> 13 13 14 size_t _STD(fread) (void *buffer, size_t size, size_t count, FILE *stream) 14 size_t _STD(fread)(void *buffer, size_t size, size_t count, FILE *stream) 15 { 16 STREAM_LOCK(stream); 17 size_t cb = fread_unlocked(buffer, size, count, stream); 18 STREAM_UNLOCK(stream); 19 return cb; 20 } 21 22 size_t _STD(fread_unlocked)(void *buffer, size_t size, size_t count, FILE *stream) 15 23 { 16 24 size_t total, left, n; … … 28 36 } 29 37 30 STREAM_LOCK (stream);31 38 if (nbuf (stream)) 32 39 _fbuf (stream); … … 120 127 } 121 128 } 122 STREAM_UNLOCK (stream);123 129 return (total - left) / size; 124 130 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/fseek.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r2089 r2090 10 10 #include <emx/io.h> 11 11 12 int _fseek_ nolock(FILE *stream, off_t offset, int origin)12 int _fseek_unlocked (FILE *stream, off_t offset, int origin) 13 13 { 14 14 off_t cur_pos; … … 40 40 file_pos = tell (stream->_handle); 41 41 if (file_pos == -1) return EOF; 42 cur_pos = _ftell _nolock(stream);42 cur_pos = _ftello_unlocked (stream); 43 43 if (origin == SEEK_CUR) 44 44 { … … 146 146 147 147 if (origin == SEEK_CUR && cur_pos == -1) 148 cur_pos = _ftell _nolock(stream);148 cur_pos = _ftello_unlocked (stream); 149 149 #endif 150 150 151 fflush_result = _fflush_nolock(stream);151 fflush_result = fflush_unlocked (stream); 152 152 stream->_flags &= ~_IOEOF; 153 153 if (stream->_flags & _IORW) … … 157 157 { 158 158 if (cur_pos == -1) 159 cur_pos = _ftell _nolock(stream);159 cur_pos = _ftello_unlocked (stream); 160 160 if (cur_pos == -1) 161 161 { … … 184 184 185 185 STREAM_LOCK (stream); 186 result = _fseek_ nolock(stream, offset, origin);186 result = _fseek_unlocked (stream, offset, origin); 187 187 STREAM_UNLOCK (stream); 188 188 return result; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/ftell.c
-
Property cvs2svn:cvs-rev
changed from
1.7
to1.8
r2089 r2090 12 12 #include <emx/io.h> 13 13 14 off_t _ftell _nolock(FILE *stream)14 off_t _ftello_unlocked (FILE *stream) 15 15 { 16 16 off_t pos; … … 104 104 105 105 STREAM_LOCK (stream); 106 off = _ftell _nolock(stream);106 off = _ftello_unlocked (stream); 107 107 STREAM_UNLOCK (stream); 108 108 return off; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/fwrite.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r2089 r2090 102 102 } 103 103 104 105 size_t _fwrite_nolock (const void *buffer, size_t size, size_t count, 106 FILE *stream) 104 size_t _STD(fwrite_unlocked) (const void *buffer, size_t size, size_t count, FILE *stream) 107 105 { 108 106 size_t total, left, n; 109 107 const char *src, *newline; 110 108 111 if (stream->_flags & _IOREAD) /* File in read mode? */ 109 /* switch to write mode if necessary. */ 110 if (stream->_flags & _IOREAD) 112 111 { 113 stream->_flags |= _IOERR; 114 errno = EACCES; 115 return 0; 112 if (stream->_flags & _IORW) 113 { 114 int rc = _fseek_unlocked (stream, 0, SEEK_CUR); 115 if (rc) 116 return EOF; 117 } 118 if (stream->_flags & _IOREAD) 119 { 120 stream->_flags |= _IOERR; 121 errno = EACCES; 122 return EOF; 123 } 116 124 } 117 if ( count == 0)125 if (size == 0 || count == 0) 118 126 return 0; 119 if (size == 0)120 return count;121 127 total = size * count; 122 128 if (total / count != size) … … 143 149 { 144 150 /* Note that the return value will be inaccurate if 145 _fflush_nolock() fails, but that's also true for151 fflush_unlocked() fails, but that's also true for 146 152 _IOFBF. */ 147 153 148 if ( _fflush_nolock(stream) != 0)154 if (fflush_unlocked (stream) != 0) 149 155 left = total; 150 156 else if (left != 0) … … 164 170 165 171 STREAM_LOCK (stream); 166 r = _fwrite_nolock(buffer, size, count, stream);172 r = fwrite_unlocked (buffer, size, count, stream); 167 173 STREAM_UNLOCK (stream); 168 174 return r; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/getchar.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r2089 r2090 4 4 #include <stdio.h> 5 5 6 int _STD(getchar) 6 int _STD(getchar)(void) 7 7 { 8 return getc(stdin);8 return getc(stdin); 9 9 } 10 11 int _STD(getchar_unlocked)(void) 12 { 13 return getc_unlocked(stdin); 14 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/putchar.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r2089 r2090 4 4 #include <stdio.h> 5 5 6 int _STD(putchar) 6 int _STD(putchar)(int c) 7 7 { 8 return putc(c, stdout);8 return putc(c, stdout); 9 9 } 10 11 int _STD(putchar_unlocked)(int c) 12 { 13 return putc_unlocked(c, stdout); 14 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/puts.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r2089 r2090 12 12 int _STD(puts) (const char *string) 13 13 { 14 int result, len; 15 void *tb; 14 STREAM_LOCK(stdout); 15 int rc = puts_unlocked(string); 16 STREAM_UNLOCK(stdout); 17 return rc; 18 } 16 19 17 len = strlen (string); 18 STREAM_LOCK (stdout); 19 if (nbuf (stdout)) 20 _fbuf (stdout); 21 _tmpbuf (stdout, tb); 22 if (len == 0 || _fwrite_nolock (string, len, 1, stdout) == 1) 23 result = _putc_inline ('\n', stdout); 24 else 25 result = EOF; 26 if (_endbuf (stdout) != 0) 27 result = EOF; 28 STREAM_UNLOCK (stdout); 29 return result; 20 int _STD(puts_unlocked) (const char *string) 21 { 22 int result; 23 24 int len = strlen(string); 25 if (nbuf(stdout)) 26 _fbuf (stdout); 27 void *tb; 28 _tmpbuf(stdout, tb); 29 if ( len == 0 30 || fwrite_unlocked(string, len, 1, stdout) == 1) 31 result = _putc_inline('\n', stdout); 32 else 33 result = EOF; 34 if (_endbuf(stdout) != 0) 35 result = EOF; 36 return result; 30 37 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/rewind.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r2089 r2090 11 11 { 12 12 STREAM_LOCK (stream); 13 _fflush_nolock(stream);14 _fseek_ nolock(stream, 0, SEEK_SET);13 fflush_unlocked (stream); 14 _fseek_unlocked (stream, 0, SEEK_SET); 15 15 stream->_flags &= ~_IOERR; 16 16 STREAM_UNLOCK (stream); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/setvbuf.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r2089 r2090 15 15 16 16 STREAM_LOCK (stream); 17 _fflush_nolock(stream);17 fflush_unlocked (stream); 18 18 if ((stream->_flags & _IOBUFMASK) == _IOBUFLIB) 19 19 free (stream->_buffer); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/ungetc.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r2089 r2090 112 112 || ft != HT_FILE) 113 113 return EOF; 114 114 115 115 /* OK, we can flush the stream buffer. We flush the buffer 116 116 completely and don't attempt to keep some data (that would be … … 119 119 120 120 uc = stream->_ungetc_count; 121 if ( _fflush_nolock(stream) != 0)121 if (fflush_unlocked (stream) != 0) 122 122 return EOF; 123 123 stream->_ungetc_count = uc; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/libc.def
-
Property cvs2svn:cvs-rev
changed from
1.116
to1.117
r2089 r2090 533 533 "__fbuf" @546 534 534 "__fcloseall" @547 535 "__ fflush_nolock" @548535 "__std_fflush_unlocked" @548 536 536 "__filesys" @549 537 537 "__fill" @550 … … 558 558 "__fpreset" @571 559 559 "__fseek_hdr" @572 560 "__fseek_ nolock" @573560 "__fseek_unlocked" @573 561 561 "__fsetmode" @574 562 562 "__fsopen" @575 563 "__ftell _nolock" @576563 "__ftello_unlocked" @576 564 564 "__fullpath" @577 565 "__ fwrite_nolock" @578565 "__std_fwrite_unlocked" @578 566 566 "__fxam" @579 567 567 "__fxaml" @580 … … 1719 1719 "__std_mkdtemp" @1722 1720 1720 "__std_mkstemps" @1723 1721 ; unlocked file stream stuff. 1722 "__std_clearerr_unlocked" @1724 1723 "__std_feof_unlocked" @1725 1724 "__std_ferror_unlocked" @1726 1725 "__std_fgetc_unlocked" @1727 1726 "__std_fileno_unlocked" @1728 1727 "__std_flockfile" @1729 1728 "__std_ftrylockfile" @1730 1729 "__std_funlockfile" @1731 1730 "__std_getc" @1732 1731 "__std_getchar_unlocked" @1733 1732 "__std_getc_unlocked" @1734 1733 "__std_putchar_unlocked" @1735 1734 "__std_fputc_unlocked" @1736 1735 "__std_putc" @1737 1736 "__std_putc_unlocked" @1738 1737 "__std_fputs_unlocked" @1739 1738 "__std_puts_unlocked" @1740 1739 "__std_fread_unlocked" @1741 1740 "___isinff" @1742 1741 "___isinfl" @1743 1742 "__std_isinf" @1744 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/libc.smak
-
Property cvs2svn:cvs-rev
changed from
1.69
to1.70
r2089 r2090 364 364 365 365 $(INS)lib/$(notdir $(LIBC.DLL)): $(LIBC.DLL) 366 if test -f $@; then emxload emxomfld && unlock $(subst /,\\,$@) && cp $< $@ && emxload -u emxomfld; else cp $< $@; fi 366 if test -f $@; then rm -f $@ || (unlock $(subst /,\\,$@) && rm -f $@); fi 367 cp $< $@ 367 368 368 369 $(INS)lib/$(notdir $(LIBC.DLL:.dll=.map)): $(LIBC.DLL:.dll=.map) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/libc06b4.def
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r2089 r2090 531 531 "__fbuf" @546 532 532 "__fcloseall" @547 533 "__ fflush_nolock" @548533 "__std_fflush_unlocked" @548 534 534 "__filesys" @549 535 535 "__fill" @550 … … 556 556 "__fpreset" @571 557 557 "__fseek_hdr" @572 558 "__fseek_ nolock" @573558 "__fseek_unlocked" @573 559 559 "__fsetmode" @574 560 560 "__fsopen" @575 561 "__ftell _nolock" @576561 "__ftello_unlocked" @576 562 562 "__fullpath" @577 563 "__ fwrite_nolock" @578563 "__std_fwrite_unlocked" @578 564 564 "__fxam" @579 565 565 "__fxaml" @580 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/_realrealpath.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r2089 r2090 53 53 LIBCLOG_ENTER("pszPath=%p:{%s} pszResolved=%p cchResolved=%d\n", (void *)pszPath, pszPath, pszResolved, cchResolved); 54 54 55 if (!pszPath) 56 { 57 errno = EINVAL; 58 LIBC_ASSERTM_FAILED("pszPath is NULL!\n"); 59 LIBCLOG_RETURN_INT(NULL); 60 } 61 55 62 int rc; 56 63 if (!pszResolved) … … 75 82 else 76 83 rc = -ENOMEM; 77 } 78 else 79 { 80 rc = __libc_Back_fsPathResolve(pszPath, pszResolved, cchResolved, __LIBC_BACKFS_FLAGS_RESOLVE_NATIVE); 81 if (!rc) 82 LIBCLOG_RETURN_MSG(pszResolved, "ret %p:{%s}\n", pszResolved, pszResolved); 84 errno = -rc; 85 LIBCLOG_RETURN_P(NULL); 83 86 } 84 87 85 errno = -rc; 86 LIBCLOG_RETURN_P(NULL); 88 char *pszRet = pszResolved; 89 rc = __libc_Back_fsPathResolve(pszPath, pszResolved, cchResolved, __LIBC_BACKFS_FLAGS_RESOLVE_NATIVE); 90 if (rc) 91 { 92 errno = -rc; 93 pszRet = NULL; 94 } 95 LIBCLOG_RETURN_MSG(pszRet, "ret %p pszResolved=%p:{%s}\n", pszRet, pszResolved, pszResolved); 87 96 } 88 97 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/realpath.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r2089 r2090 53 53 LIBCLOG_ENTER("path=%p:{%s} resolved_path=%p\n", (void *)path, path, resolved_path); 54 54 55 if (!path) 56 { 57 errno = EINVAL; 58 LIBC_ASSERTM_FAILED("path is NULL!\n"); 59 LIBCLOG_RETURN_P(NULL); 60 } 61 55 62 int rc; 56 63 if (!resolved_path) … … 73 80 else 74 81 rc = -ENOMEM; 75 } 76 else 77 { 78 rc = __libc_Back_fsPathResolve(path, resolved_path, PATH_MAX, 0); 79 if (!rc) 80 LIBCLOG_RETURN_MSG(resolved_path, "ret %p:{%s}\n", resolved_path, resolved_path); 82 errno = -rc; 83 LIBCLOG_RETURN_P(NULL); 81 84 } 82 85 83 errno = -rc; 84 LIBCLOG_RETURN_P(NULL); 86 char *pszRet = resolved_path; 87 rc = __libc_Back_fsPathResolve(path, resolved_path, PATH_MAX, 0); 88 if (rc) 89 { 90 errno = -rc; 91 pszRet = NULL; 92 } 93 LIBCLOG_RETURN_MSG(pszRet, "ret %p resolved_path=%p:{%s}\n", pszRet, resolved_path, resolved_path); 85 94 } 86 95 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/msun/std-math.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r2089 r2090 284 284 double drem(double, double); 285 285 int finite(double) __pure2; 286 int isnanf(float) __pure2;286 int _STD(isnanf)(float) __pure2; 287 287 288 288 /* -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_fs.h
-
Property cvs2svn:cvs-rev
changed from
1.7
to1.8
r2089 r2090 106 106 * 107 107 * @returns 0 on success. 108 * @returns -1 and errno on failure.108 * @returns Negative error code (errno.h) on failiure. 109 109 * @param pszUserPath The user path. 110 110 * @parm fFlags Flags controlling the operation of the function. -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/b_fsPathResolve.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r2089 r2090 66 66 int fInUnixTree; 67 67 char szNativePath[PATH_MAX]; 68 szNativePath[0] = '\0'; 68 69 rc = __libc_back_fsResolve(pszPath, BACKFS_FLAGS_RESOLVE_FULL | BACKFS_FLAGS_RESOLVE_DIR_MAYBE, szNativePath, &fInUnixTree); 69 if (!rc) 70 71 /* 72 * Copy the (half) result back to the caller. 73 */ 74 char *pszSrc = &szNativePath[0]; 75 if (!(fFlags & __LIBC_BACKFS_FLAGS_RESOLVE_NATIVE) && fInUnixTree) 70 76 { 71 char *pszSrc = &szNativePath[0]; 72 if (!(fFlags & __LIBC_BACKFS_FLAGS_RESOLVE_NATIVE) && fInUnixTree) 73 { 74 pszSrc += __libc_gcchUnixRoot; 75 LIBC_ASSERTM(*pszSrc == '/', "bogus fInUnixTree flag! pszSrc='%s' whole think '%s'\n", pszSrc, szNativePath); 76 } 77 __libc_back_fsMutexRelease(); 77 pszSrc += __libc_gcchUnixRoot; 78 LIBC_ASSERTM(*pszSrc == '/', "bogus fInUnixTree flag! pszSrc='%s' whole thing is '%s'\n", pszSrc, szNativePath); 79 } 80 __libc_back_fsMutexRelease(); 78 81 79 int cch = strlen(pszSrc) + 1; 80 if (cch < cchBuf) 81 { 82 memcpy(pszBuf, pszSrc, cchBuf); 83 LIBCLOG_RETURN_MSG(0, "ret 0 pszPath=%p:{%s}\n", (void *)pszPath, pszPath); 84 } 85 else 86 rc = -ERANGE; 87 } 88 else 89 __libc_back_fsMutexRelease(); 90 LIBCLOG_RETURN_INT(rc); 82 int cch = strlen(pszSrc) + 1; 83 if (cch < cchBuf) 84 memcpy(pszBuf, pszSrc, cchBuf); 85 else if (!rc) 86 rc = -ERANGE; 87 88 LIBCLOG_RETURN_MSG(rc, "ret %d pszPath=%p:{%s}\n", rc, (void *)pszPath, pszPath); 91 89 } 92 90 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/sys/fs.c
-
Property cvs2svn:cvs-rev
changed from
1.17
to1.18
r2089 r2090 604 604 * @returns Number of bytes in the clean path. 605 605 * @param pszPath The path to cleanup. 606 * @parm fFlags Flags controlling the operation of the function. 607 * See the BACKFS_FLAGS_* defines. 608 */ 609 static int fsCleanPath(char *pszPath, int fFlags) 606 * @param fFlags Flags controlling the operation of the function. 607 * See the BACKFS_FLAGS_* defines. 608 * @param pfFlags Where to clear the BACKFS_FLAGS_RESOLVE_DIR_MAYBE_ flag if a 609 * trailing slash was found. 610 */ 611 static int fsCleanPath(char *pszPath, unsigned fFlags, unsigned *pfFlags) 610 612 { 611 613 /* … … 616 618 char *pszTrg = pszPath; 617 619 if ( (pszPath[0] == '\\' || pszPath[0] == '/') 618 && (pszPath[1] == '\\' || pszPath[1] == '/')) 620 && (pszPath[1] == '\\' || pszPath[1] == '/') 621 && pszPath[2] != '\\' && pszPath[2] != '/') 619 622 { /* Skip first slash in a unc path. */ 620 623 pszSrc++; … … 654 657 && pszTrg[-2] != ':' 655 658 && pszTrg[-2] != '/') 659 { 656 660 pszPath[--cch] = '\0'; 661 if (pfFlags) 662 *pfFlags &= ~BACKFS_FLAGS_RESOLVE_DIR_MAYBE_; 663 } 657 664 658 665 return cch; … … 664 671 * 665 672 * @returns 0 on success. 666 * @returns -1 and errno on failure.673 * @returns Negative error code (errno.h) on failiure. 667 674 * @param pszUserPath The user path. 668 675 * @parm fFlags Flags controlling the operation of the function. … … 674 681 int __libc_back_fsResolve(const char *pszUserPath, unsigned fFlags, char *pszNativePath, int *pfInUnixTree) 675 682 { 676 if (!__libc_gfNoUnix) 677 return fsResolveUnix(pszUserPath, fFlags, pszNativePath, pfInUnixTree); 678 else 679 return fsResolveOS2(pszUserPath, fFlags, pszNativePath, pfInUnixTree); 683 if (pszUserPath && *pszUserPath) 684 { 685 if (!__libc_gfNoUnix) 686 return fsResolveUnix(pszUserPath, fFlags, pszNativePath, pfInUnixTree); 687 else 688 return fsResolveOS2(pszUserPath, fFlags, pszNativePath, pfInUnixTree); 689 } 690 691 /* failure */ 692 *pszNativePath = '\0'; 693 if (pfInUnixTree) 694 *pfInUnixTree = 0; 695 696 LIBC_ASSERT(pszUserPath); 697 if (!pszUserPath) 698 return -EINVAL; 699 return -ENOENT; 680 700 } 681 701 … … 685 705 * 686 706 * @returns 0 on success. 687 * @returns -1 and errno on failure.707 * @returns Negative error code (errno.h) on failiure. 688 708 * @param pszUserPath The user path. 689 709 * @parm fFlags Flags controlling the operation of the function. … … 698 718 (void *)pszUserPath, pszUserPath, (void *)pszNativePath, (void *)pfInUnixTree); 699 719 const char *pszUserPathIn = pszUserPath; 700 char szTmp[PATH_MAX];701 720 char _achBuffer[SIZEOF_ACHBUFFER + 4]; 702 721 char *pachBuffer = (char *)((uintptr_t)&_achBuffer[3] & ~3); … … 739 758 ULONG ulDisk; 740 759 rc = DosQueryCurrentDisk(&ulDisk, &ul); 741 szTmp[0] = ulDisk + 'A' - 1;742 ul = sizeof(szTmp)- 2;760 pszNativePath[0] = ulDisk + 'A' - 1; 761 ul = PATH_MAX - 2; 743 762 if (!rc) 744 rc = DosQueryCurrentDir(0, (PSZ)& szTmp[3], &ul);763 rc = DosQueryCurrentDir(0, (PSZ)&pszNativePath[3], &ul); 745 764 iRoot = __libc_gfInUnixTree ? __libc_gcchUnixRoot : 2; 746 765 /* fInUnixTree remains whatever it is */ … … 751 770 * Drive letter but no root slash. 752 771 */ 753 szTmp[0] = pszUserPath[0];754 ul = sizeof(szTmp)- 2;755 rc = DosQueryCurrentDir(pszUserPath[0] - (pszUserPath[0] >= 'A' && pszUserPath[0] <= 'Z' ? 'A' : 'a') + 1, (PSZ)& szTmp[3], &ul);772 pszNativePath[0] = pszUserPath[0]; 773 ul = PATH_MAX - 2; 774 rc = DosQueryCurrentDir(pszUserPath[0] - (pszUserPath[0] >= 'A' && pszUserPath[0] <= 'Z' ? 'A' : 'a') + 1, (PSZ)&pszNativePath[3], &ul); 756 775 pszUserPath += 2; 757 776 iRoot = 2; … … 768 787 * Add the path stuff from the user. 769 788 */ 770 szTmp[1] = ':';771 szTmp[2] = '/';772 int cch = strlen( szTmp);773 szTmp[cch++] = '/';789 pszNativePath[1] = ':'; 790 pszNativePath[2] = '/'; 791 int cch = strlen(pszNativePath); 792 pszNativePath[cch++] = '/'; 774 793 int cchUserPath = strlen(pszUserPath) + 1; 775 794 if (cch + cchUserPath > PATH_MAX) … … 778 797 break; 779 798 } 780 memcpy(& szTmp[cch], pszUserPath, cchUserPath);781 pszUserPath = memcpy(pachBuffer, szTmp, cch + cchUserPath);799 memcpy(&pszNativePath[cch], pszUserPath, cchUserPath); 800 pszUserPath = memcpy(pachBuffer, pszNativePath, cch + cchUserPath); 782 801 } 783 802 … … 802 821 /* 803 822 * Apply rewrite rules. 804 * Path now goes to szTmpbuffer.823 * Path now goes to pszNativePath buffer. 805 824 */ 806 int cch Tmp = __libc_PathRewrite(pszUserPath, szTmp, sizeof(szTmp));807 if (cch Tmp> 0)825 int cchNativePath = __libc_PathRewrite(pszUserPath, pszNativePath, PATH_MAX); 826 if (cchNativePath > 0) 808 827 { 809 828 /* 810 829 * Redetermin root because of rewrite. 811 830 */ 812 iRoot = szTmp[1] == ':' ? 2 : 0;831 iRoot = pszNativePath[1] == ':' ? 2 : 0; 813 832 } 814 else if (!cch Tmp)815 { 816 cch Tmp= strlen(pszUserPath);817 if (cch Tmp + 2 > sizeof(szTmp))833 else if (!cchNativePath) 834 { 835 cchNativePath = strlen(pszUserPath); 836 if (cchNativePath + 2 > PATH_MAX) 818 837 { 819 838 rcRet = -ENAMETOOLONG; 820 839 break; 821 840 } 822 memcpy( szTmp, pszUserPath, cchTmp+ 1);841 memcpy(pszNativePath, pszUserPath, cchNativePath + 1); 823 842 } 824 843 else … … 831 850 * Check if special OS/2 name. 832 851 */ 833 if ( szTmp[0] == '/' || szTmp[0] == '\\')852 if (pszNativePath[0] == '/' || pszNativePath[0] == '\\') 834 853 { 835 854 int fDone = 0; 836 if ( ( szTmp[1] == 'p' || szTmp[1] == 'P')837 && ( szTmp[2] == 'i' || szTmp[2] == 'I')838 && ( szTmp[3] == 'p' || szTmp[3] == 'P')839 && ( szTmp[4] == 'e' || szTmp[4] == 'E')840 && ( szTmp[5] == '/' || szTmp[5] == '\\'))855 if ( (pszNativePath[1] == 'p' || pszNativePath[1] == 'P') 856 && (pszNativePath[2] == 'i' || pszNativePath[2] == 'I') 857 && (pszNativePath[3] == 'p' || pszNativePath[3] == 'P') 858 && (pszNativePath[4] == 'e' || pszNativePath[4] == 'E') 859 && (pszNativePath[5] == '/' || pszNativePath[5] == '\\')) 841 860 fDone = 1; 842 else if (( szTmp[1]== 'd' || szTmp[1] == 'D')843 && ( szTmp[2] == 'e' || szTmp[2] == 'E')844 && ( szTmp[3] == 'v' || szTmp[3] == 'V')845 && ( szTmp[4] == '/' || szTmp[4] == '\\')861 else if ((pszNativePath[1]== 'd' || pszNativePath[1] == 'D') 862 && (pszNativePath[2] == 'e' || pszNativePath[2] == 'E') 863 && (pszNativePath[3] == 'v' || pszNativePath[3] == 'V') 864 && (pszNativePath[4] == '/' || pszNativePath[4] == '\\') 846 865 ) 847 866 { 848 867 PFSQBUFFER2 pfsqb = (PFSQBUFFER2)pachBuffer; 849 868 ULONG cb = SIZEOF_ACHBUFFER; 850 fDone = !DosQueryFSAttach((PCSZ) szTmp, 0, FSAIL_QUERYNAME, pfsqb, &cb);851 } 852 853 /* If it was, copy path to szTmpand go to exit code. */869 fDone = !DosQueryFSAttach((PCSZ)pszNativePath, 0, FSAIL_QUERYNAME, pfsqb, &cb); 870 } 871 872 /* If it was, copy path to pszNativePath and go to exit code. */ 854 873 if (fDone) 855 874 { 856 int cch = strlen( szTmp) + 1;875 int cch = strlen(pszNativePath) + 1; 857 876 if (cch <= PATH_MAX) 858 877 { 859 fsCleanPath( &szTmp[0], fFlags);878 fsCleanPath(pszNativePath, fFlags, NULL); 860 879 rcRet = 0; 861 880 } … … 869 888 * Remove excessive slashing and convert all slashes to '/'. 870 889 */ 871 cch Tmp = fsCleanPath(&szTmp[0],fFlags);890 cchNativePath = fsCleanPath(pszNativePath, fFlags, &fFlags); 872 891 873 892 /* 874 893 * Expand unix root or add missing drive letter. 875 894 */ 876 if ( szTmp[0] == '/' && szTmp[1] != '/')877 { 878 memcpy(pachBuffer, szTmp, cchTmp+ 1);895 if (pszNativePath[0] == '/' && pszNativePath[1] != '/') 896 { 897 memcpy(pachBuffer, pszNativePath, cchNativePath + 1); 879 898 if (__libc_gcchUnixRoot) 880 899 { 881 900 iRoot = __libc_gcchUnixRoot; 882 if (cch Tmp+ iRoot >= PATH_MAX)901 if (cchNativePath + iRoot >= PATH_MAX) 883 902 { 884 903 rcRet = -ENAMETOOLONG; 885 904 break; 886 905 } 887 memcpy( szTmp, __libc_gszUnixRoot, iRoot);906 memcpy(pszNativePath, __libc_gszUnixRoot, iRoot); 888 907 fInUnixTree = 1; 889 908 } … … 894 913 ULONG ul; 895 914 DosQueryCurrentDisk(&ulDisk, &ul); 896 if (cch Tmp+ iRoot >= PATH_MAX)915 if (cchNativePath + iRoot >= PATH_MAX) 897 916 { 898 917 rcRet = -ENAMETOOLONG; 899 918 break; 900 919 } 901 szTmp[0] = ulDisk + 'A' - 1;902 szTmp[1] = ':';903 } 904 if (cch Tmp!= 1 || iRoot <= 2)905 memcpy(& szTmp[iRoot], pachBuffer, cchTmp+ 1);920 pszNativePath[0] = ulDisk + 'A' - 1; 921 pszNativePath[1] = ':'; 922 } 923 if (cchNativePath != 1 || iRoot <= 2) 924 memcpy(&pszNativePath[iRoot], pachBuffer, cchNativePath + 1); 906 925 else 907 szTmp[iRoot] = szTmp[iRoot + 1] = '\0'; /* The +1 fixes '/' access in an compartement (pszPrev below). */908 cch Tmp+= iRoot;926 pszNativePath[iRoot] = pszNativePath[iRoot + 1] = '\0'; /* The +1 fixes '/' access in an compartement (pszPrev below). */ 927 cchNativePath += iRoot; 909 928 } 910 929 … … 920 939 * up with an optimal path in the end. 921 940 */ 941 /** @todo If we've retreived the current directory, we can safely save of the effort of validating it! */ 922 942 923 943 /* … … 926 946 char *pszPrev; 927 947 char *psz; 928 if ( szTmp[0] == '/' && szTmp[1] == '/')948 if (pszNativePath[0] == '/' && pszNativePath[1] == '/' && pszNativePath[2] != '/') 929 949 { 930 950 /* UNC - skip past the share name. */ 931 psz = strchr(& szTmp[2], '/');951 psz = strchr(&pszNativePath[2], '/'); 932 952 if (!psz) 933 953 { … … 938 958 if (!psz) 939 959 { 940 strupr( szTmp);/* The server + share is uppercased for consistant ino_t calculations. */960 strupr(pszNativePath); /* The server + share is uppercased for consistant ino_t calculations. */ 941 961 rcRet = 0; 942 962 break; 943 963 } 944 964 *psz = '\0'; /* The server + share is uppercased for consistant ino_t calculations. */ 945 strupr( szTmp);965 strupr(pszNativePath); 946 966 *psz = '/'; 947 967 pszPrev = ++psz; 948 968 fInUnixTree = 0; /* Unix root cannot be UNC. */ 949 iRoot = psz - &szTmp[0];969 iRoot = psz - pszNativePath; 950 970 psz = strchr(psz, '/'); 951 971 } … … 953 973 { 954 974 /* drive letters are always uppercase! (inode dev number req) */ 955 LIBC_ASSERT( szTmp[1] == ':');956 if ( szTmp[0] >= 'a' && szTmp[0] <= 'z')957 szTmp[0] -= 'a' - 'A';958 pszPrev = & szTmp[iRoot + 1];975 LIBC_ASSERT(pszNativePath[1] == ':'); 976 if (pszNativePath[0] >= 'a' && pszNativePath[0] <= 'z') 977 pszNativePath[0] -= 'a' - 'A'; 978 pszPrev = &pszNativePath[iRoot + 1]; 959 979 psz = strchr(pszPrev, '/'); 960 980 } 961 LIBC_ASSERTM(pszPrev - &szTmp[0] >= iRoot, "iRoot=%d pszPrev offset %d szTmp=%s\n", iRoot, pszPrev - &szTmp[0], szTmp);981 LIBC_ASSERTM(pszPrev - pszNativePath >= iRoot, "iRoot=%d pszPrev offset %d pszNativePath=%s\n", iRoot, pszPrev - pszNativePath, pszNativePath); 962 982 /* If only one component, we'll check if the fVerifyLast was requested. */ 963 983 if ( !psz 964 984 && (fFlags & (BACKFS_FLAGS_RESOLVE_FULL | BACKFS_FLAGS_RESOLVE_FULL_SYMLINK)) 965 985 && *pszPrev) 966 psz = strchr( szTmp, '\0');986 psz = strchr(pszNativePath, '\0'); 967 987 968 988 /* … … 983 1003 { 984 1004 if ( pszPrev[1] != '\0' 985 && (uintptr_t)(pszPrev - &szTmp[0]) != iRoot + 1)1005 && (uintptr_t)(pszPrev - pszNativePath) != iRoot + 1) 986 1006 { 987 1007 for (pszPrev -= 2; *pszPrev != '/'; pszPrev--) … … 990 1010 } 991 1011 *psz = chSlash; 992 memmove(pszPrev - 1, psz, cch Tmp - (psz - &szTmp[0]) + 1);993 cch Tmp -= psz - pszPrev - 1;1012 memmove(pszPrev - 1, psz, cchNativePath - (psz - pszNativePath) + 1); 1013 cchNativePath -= psz - (pszPrev - 1); 994 1014 995 1015 /* … … 1036 1056 * getting the caseing resolved.) 1037 1057 */ 1038 LIBC_ASSERT(psz - szTmp == cchTmp);1058 LIBC_ASSERT(psz - pszNativePath == cchNativePath); 1039 1059 PFILEFINDBUF4 pFindBuf = (PFILEFINDBUF4)pachBuffer; 1040 1060 ULONG cFiles = 1; … … 1042 1062 psz[0] = '?'; 1043 1063 psz[1] = '\0'; 1044 int rc = DosFindFirst((PCSZ) &szTmp[0], &hDir, FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM | FILE_DIRECTORY | FILE_ARCHIVED,1064 int rc = DosFindFirst((PCSZ)pszNativePath, &hDir, FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM | FILE_DIRECTORY | FILE_ARCHIVED, 1045 1065 pFindBuf, SIZEOF_ACHBUFFER, &cFiles, FIL_QUERYEASIZE); 1046 1066 psz[0] = '\0'; … … 1054 1074 if (rc || cFiles == 0) 1055 1075 { 1056 LIBCLOG_MSG("DosFindFirst/Next('%s',,,,,) -> %d resolving '%s'\n", szTmp, rc, pszUserPathIn);1076 LIBCLOG_MSG("DosFindFirst/Next('%s',,,,,) -> %d resolving '%s'\n", pszNativePath, rc, pszUserPathIn); 1057 1077 if ((fFlags & BACKFS_FLAGS_RESOLVE_FULL_MAYBE_) && !chSlash) 1058 1078 { … … 1085 1105 EaOp.oError = 0; 1086 1106 EaOp.fpFEA2List->cbList = SIZEOF_ACHBUFFER; 1087 rc = DosQueryPathInfo((PCSZ) &szTmp[0], FIL_QUERYEASFROMLIST, &EaOp, sizeof(EaOp));1107 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_QUERYEASFROMLIST, &EaOp, sizeof(EaOp)); 1088 1108 if (rc) 1089 1109 { 1090 LIBCLOG_MSG("DosQueryPathInfo('%s',,,) -> %d resolving '%s'\n", szTmp, rc, pszUserPathIn);1110 LIBCLOG_MSG("DosQueryPathInfo('%s',,,) -> %d resolving '%s'\n", pszNativePath, rc, pszUserPathIn); 1091 1111 if ((fFlags & BACKFS_FLAGS_RESOLVE_FULL_MAYBE_) && !chSlash) 1092 1112 rcRet = 0; … … 1125 1145 /* Cleanup the symlink and find it's length. */ 1126 1146 pszSymlink[pusType[1]] = '\0'; 1127 int cchSymlink = fsCleanPath(pszSymlink, fFlags );1147 int cchSymlink = fsCleanPath(pszSymlink, fFlags, NULL); 1128 1148 1129 1149 /* Merge symlink with the path. */ 1130 int cchLeft = cch Tmp - (psz - &szTmp[0]);1150 int cchLeft = cchNativePath - (psz - pszNativePath); 1131 1151 if (*pszSymlink == '/' || *pszSymlink == '\\' || pszSymlink[1] == ':') 1132 1152 { … … 1156 1176 * Squeeze the symlink in instead of the current path component. 1157 1177 */ 1158 if (cchSymlink + cch Tmp+ 2 >= PATH_MAX)1178 if (cchSymlink + cchNativePath + 2 >= PATH_MAX) 1159 1179 { 1160 1180 rcRet = -ENAMETOOLONG; … … 1190 1210 1191 1211 /* 1192 * If we get here it was not a symlink and we should check ifthe directoryness1212 * If we get here it was not a symlink and we should check how the directoryness 1193 1213 * of it fit's into the big picture... 1194 1214 */ 1195 1215 if (!fIsDirectory && chSlash) 1196 1216 { 1197 LIBCLOG_MSG("'%s' is not a directory (resolving '%s')\n", szTmp, pszUserPathIn);1217 LIBCLOG_MSG("'%s' is not a directory (resolving '%s')\n", pszNativePath, pszUserPathIn); 1198 1218 rcRet = -ENOTDIR; 1199 1219 break; … … 1207 1227 { 1208 1228 rcRet = 0; 1229 if ( (fFlags & (BACKFS_FLAGS_RESOLVE_DIR | BACKFS_FLAGS_RESOLVE_DIR_MAYBE_)) == BACKFS_FLAGS_RESOLVE_DIR 1230 && !fIsDirectory) 1231 rcRet = -ENOTDIR; 1209 1232 break; 1210 1233 } … … 1241 1264 if (!rcRet) 1242 1265 { 1243 int cch = strlen( szTmp) + 1;1244 if (cch == 1 || (cch == 3 && szTmp[1] == ':'))1245 { 1246 szTmp[cch - 1] = '/';1247 szTmp[cch++] = '\0';1266 int cch = strlen(pszNativePath) + 1; 1267 if (cch == 1 || (cch == 3 && pszNativePath[1] == ':')) 1268 { 1269 pszNativePath[cch - 1] = '/'; 1270 pszNativePath[cch] = '\0'; 1248 1271 } 1249 memcpy(pszNativePath, szTmp, cch);1250 1272 if (pfInUnixTree) 1251 1273 *pfInUnixTree = fInUnixTree; … … 1263 1285 * 1264 1286 * @returns 0 on success. 1265 * @returns -1 and errno on failure.1287 * @returns Negative error code (errno.h) on failiure. 1266 1288 * @param pszUserPath The user path. 1267 1289 * @parm fFlags Flags controlling the operation of the function. … … 1279 1301 * Apply rewrite rule. 1280 1302 */ 1281 int cch = __libc_PathRewrite(pszUserPath, pszNativePath, sizeof(pszNativePath));1303 int cch = __libc_PathRewrite(pszUserPath, pszNativePath, PATH_MAX); 1282 1304 if (cch < 0) 1283 1305 LIBCLOG_RETURN_INT(-EINVAL); -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.