mirror of
https://github.com/elua/elua.git
synced 2025-01-25 01:02:54 +08:00
Make sure we actually get a file descriptor before creating new WOFS file
This commit is contained in:
parent
fc8f3e4a3d
commit
5c0f204775
17
src/romfs.c
17
src/romfs.c
@ -211,6 +211,14 @@ static int romfs_open_r( struct _reent *r, const char *path, int flags, int mode
|
||||
r->_errno = ENOSPC;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Make sure we can get a file descriptor before writing
|
||||
if( ( i = romfs_find_empty_fd() ) < 0 )
|
||||
{
|
||||
r->_errno = ENFILE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Write the name of the file
|
||||
pfsdata->writef( path, firstfree, strlen( path ) + 1, pfsdata );
|
||||
firstfree += strlen( path ) + 1; // skip over the name
|
||||
@ -229,10 +237,15 @@ static int romfs_open_r( struct _reent *r, const char *path, int flags, int mode
|
||||
r->_errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( ( i = romfs_find_empty_fd() ) < 0 )
|
||||
{
|
||||
r->_errno = ENFILE;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
// Find a free FD and copy the descriptor information
|
||||
// Copy the descriptor information
|
||||
tempfs.flags = lflags;
|
||||
i = romfs_find_empty_fd();
|
||||
memcpy( fd_table + i, &tempfs, sizeof( FD ) );
|
||||
romfs_num_fd ++;
|
||||
return i;
|
||||
|
Loading…
x
Reference in New Issue
Block a user