Changeset 1234
- Timestamp:
- Feb 12, 2004, 9:33:43 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/src/lib/sys/filehandles.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1233 r1234 121 121 * Was previously done in init_files() in startup.c. 122 122 * We need to allocate the handles and initialize them accordingly. 123 * Note! This duplicates a bit of the __ioctl2 functionality for 124 * reasons of speed. 125 */ 123 * Bird Feb 12 2004 9:12pm: We do not have to do more than the first 3 handles. 124 * Other open files will be automatically added when __libc_FH() is called 125 * for usage validation in any of LIBC apis. 126 */ 127 if (cMaxFHs > 3) 128 cMaxFHs = 3; 126 129 for (i = 0; i < cMaxFHs; i++) 127 { 128 ULONG fulType; 129 ULONG fulDevFlags; 130 ULONG fulMode; 131 unsigned fLibc; 132 133 /* 134 * Is it in use and if so what kind of handle? 135 */ 136 if ( (rc = DosQueryHType((HFILE)i, &fulType, &fulDevFlags)) != NO_ERROR 137 || (rc = DosQueryFHState((HFILE)i, &fulMode)) != NO_ERROR) 138 { 139 #ifdef DEBUG 140 if (rc != ERROR_INVALID_HANDLE) 141 __asm__("int $3"); 142 #endif 143 continue; 144 } 145 146 /* 147 * Determin initial flags. 148 */ 149 switch (fulType & 0xff) 150 { 151 default: /* paranoia */ 152 case HANDTYPE_FILE: 153 fLibc = F_FILE; 154 break; 155 case HANDTYPE_DEVICE: 156 fLibc = F_DEV; 157 /* @todo inherit O_NDELAY */ 158 break; 159 case HANDTYPE_PIPE: 160 fLibc = F_PIPE; 161 break; 162 } 163 164 /* 165 * There is some init_streams() dependency on all files to have non 166 * zero flags. Sure, we might change this, but for now keep this in mind 167 * when omitting O_TEXT. 168 * @todo inherit non text files. 169 */ 170 fLibc |= O_TEXT; 171 172 /* 173 * Read write flags. 174 */ 175 switch (fulMode & (OPEN_ACCESS_READONLY | OPEN_ACCESS_WRITEONLY | OPEN_ACCESS_READWRITE)) 176 { 177 case OPEN_ACCESS_READONLY: fLibc |= O_RDONLY; break; 178 case OPEN_ACCESS_WRITEONLY: fLibc |= O_WRONLY; break; 179 default: /* paranoia */ 180 case OPEN_ACCESS_READWRITE: fLibc |= O_RDWR; break; 181 } 182 183 /* 184 * Enforce rules on the three standard handles - is this strictly 185 * speaking such a good idea? It's apparently required for the con device 186 * as that is opened as readwrite for all three in OS/2 (to safe SFNs?). 187 * However I think when it's not the console device this might be sort 188 * of rushing to conclusions... 189 */ 190 if (i < 2 && (fulDevFlags & 0x3 /* CON or KBD dev */)) 191 { 192 if (i == 0) 193 fLibc = (fLibc & ~O_ACCMODE) | O_RDONLY; 194 else 195 fLibc = (fLibc & ~O_ACCMODE) | O_WRONLY; 196 } 197 198 /* 199 * Allocate handle and initialize handle. 200 */ 201 rc = __libc_fhAllocate(i, fLibc, sizeof(LIBCFH), NULL, NULL, NULL, 1); 202 if (rc) 203 { 204 #ifdef DEBUG 205 __asm__("int $3"); 206 #endif 207 return -1; 208 } 209 } /* fh init loop */ 130 __libc_fh(i); 210 131 211 132 return 0; -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.