diff options
| -rw-r--r-- | firmware/common/file.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/firmware/common/file.c b/firmware/common/file.c index a7facc3..75adc87 100644 --- a/firmware/common/file.c +++ b/firmware/common/file.c @@ -485,13 +485,16 @@ static int readwrite(int fd, void* buf, long count, bool write) { long sectors; long nread=0; - struct filedesc* file = &openfiles[fd]; + struct filedesc* file; int rc; if (fd < 0 || fd > MAX_OPEN_FILES-1) { errno = EINVAL; return -1; } + + file = &openfiles[fd]; + if ( !file->busy ) { errno = EBADF; return -1; |