- Timestamp:
- Feb 12, 2004, 9:12:42 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/src/emx/src/lib/sys/filehandles.c (modified) (4 diffs, 1 prop)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/src/lib/sys/filehandles.c
-
Property cvs2svn:cvs-rev
changed from
1.4to1.5
r1232 r1233 64 64 static int __libc_fhMoreHandles(unsigned cMin); 65 65 static int __libc_fhAllocate(int fh, unsigned fFlags, int cb, PLIBCFHOPS pOps, PLIBCFH *ppFH, int *pfh, int fOwnSem); 66 66 67 67 68 … … 630 631 * Validate input. 631 632 */ 632 if ( (fh < 0 && fh >= gcFHs) 633 || !gpapFHs[fh]) 634 { 635 _fmutex_release(&gmtx); 633 if (!__libc_fh(fh)) 634 { 636 635 #ifdef DEBUG 637 636 __asm__("int $3"); 638 637 #endif 638 639 639 errno = EBADF; 640 640 return -1; … … 657 657 { 658 658 int rc2; 659 659 660 /* 660 661 * Close the OS/2 handle and remove the handle from the array … … 702 703 * @returns NULL on failure. 703 704 * @param fh Handle to lookup. 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 704 809 */ 705 810 PLIBCFH __libc_FH(int fh) 706 811 { 707 PLIBCFH pFH = NULL;812 PLIBCFH pFH; 708 813 709 814 /** @todo shared access */ 710 if (!_fmutex_request(&gmtx, 0)) 711 { 712 if (fh >= 0 && fh < gcFHs) 713 { 714 pFH = gpapFHs[fh]; 715 if (!pFH) 716 { 717 /* 718 * Try import the handle. 719 */ 720 ULONG rc; 721 ULONG fulType; 722 ULONG fulDevFlags; 723 ULONG fulMode; 724 unsigned fLibc; 725 726 /* 727 * Is it in use and if so what kind of handle? 728 */ 729 if ( (rc = DosQueryHType((HFILE)fh, &fulType, &fulDevFlags)) != NO_ERROR 730 || (rc = DosQueryFHState((HFILE)fh, &fulMode)) != NO_ERROR) 731 { 732 errno = EBADF; 733 _fmutex_release(&gmtx); 734 return NULL; 735 } 736 737 /* 738 * Determin initial flags. 739 */ 740 switch (fulType & 0xff) 741 { 742 default: /* paranoia */ 743 case HANDTYPE_FILE: 744 fLibc = F_FILE; 745 break; 746 case HANDTYPE_DEVICE: 747 fLibc = F_DEV; 748 /* @todo inherit O_NDELAY */ 749 break; 750 case HANDTYPE_PIPE: 751 fLibc = F_PIPE; 752 break; 753 } 754 755 /* 756 * Read write flags. 757 */ 758 switch (fulMode & (OPEN_ACCESS_READONLY | OPEN_ACCESS_WRITEONLY | OPEN_ACCESS_READWRITE)) 759 { 760 case OPEN_ACCESS_READONLY: fLibc |= O_RDONLY; break; 761 case OPEN_ACCESS_WRITEONLY: fLibc |= O_WRONLY; break; 762 default: /* paranoia */ 763 case OPEN_ACCESS_READWRITE: fLibc |= O_RDWR; break; 764 } 765 766 /* 767 * Textflag. 768 */ 769 if (!_fmode_bin) 770 fLibc |= O_TEXT; 771 772 773 /* 774 * Allocate a new handle for this filehandle. 775 */ 776 rc = __libc_fhAllocate(fh, fLibc, sizeof(LIBCFH), NULL, &pFH, NULL, 1); 777 if (rc) 778 pFH = NULL; 779 } 780 } 781 782 _fmutex_release(&gmtx); 783 } 784 815 if (_fmutex_request(&gmtx, 0)) 816 return NULL; 817 818 pFH = __libc_fh(fh); 819 820 _fmutex_release(&gmtx); 785 821 return pFH; 786 822 } -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.
