Skip to content

Commit

Permalink
fix: iomanX use device instead of mode for allocation check
Browse files Browse the repository at this point in the history
  • Loading branch information
uyjulian committed Nov 27, 2024
1 parent 400d8fc commit 990612c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions iop/system/iomanx/src/iomanX.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,14 @@ static inline void handle_result_pre(int in_result, iomanX_iop_file_t *f, int op
{
if ( f )
{
f->mode = 0;
// Unofficial: don't clear mode
f->device = NULL;
}
}
if ( (op & HANDLE_RESULT_CLEAR_INFO_ON_ERROR) )
{
if ( f && (in_result < 0) )
{
// Unofficial: also clear mode
f->mode = 0;
f->device = NULL;
}
}
Expand Down Expand Up @@ -903,13 +901,13 @@ static iomanX_iop_file_t *new_iob(void)

CpuSuspendIntr(&state);
file_table_entry = file_table;
while ( (file_table_entry < &file_table[sizeof(file_table) / sizeof(file_table[0])]) && file_table_entry->mode )
while ( (file_table_entry < &file_table[sizeof(file_table) / sizeof(file_table[0])]) && file_table_entry->device )
file_table_entry += 1;
if ( file_table_entry >= &file_table[sizeof(file_table) / sizeof(file_table[0])] )
file_table_entry = NULL;
// fill in "mode" temporarily to mark the fd as allocated.
// fill in "device" temporarily to mark the fd as allocated.
if ( file_table_entry )
file_table_entry->mode = -20;
file_table_entry->device = (iomanX_iop_device_t *)(uiptr)0xFFFFFFEC;
CpuResumeIntr(state);
if ( !file_table_entry )
_ioabort("out of file descriptors", "[too many open]");
Expand Down

0 comments on commit 990612c

Please sign in to comment.