diff --git a/configs/sim/README.txt b/configs/sim/README.txt index 7db2e11a870..c1b105aebe5 100644 --- a/configs/sim/README.txt +++ b/configs/sim/README.txt @@ -165,6 +165,9 @@ I never did get networking to work on the sim target. It tries to use the tap d (/dev/net/tun) to emulate an Ethernet NIC, but I never got it correctly integrated with the NuttX networking (I probably should try using raw sockets instead). +Update: Max Holtzberg reports to me that the tap device actually does work properly, +but not in an NSH configuration because of stdio operations freeze the simulation. + X11 Issues ---------- There is an X11-based framebuffer driver that you can use exercise the NuttX graphics diff --git a/fs/fs_lseek.c b/fs/fs_lseek.c index bcf66f51ba5..d2a2a8ca79e 100644 --- a/fs/fs_lseek.c +++ b/fs/fs_lseek.c @@ -80,7 +80,7 @@ off_t file_seek(FAR struct file *filep, off_t offset, int whence) int ret; int err = OK; - DEBUGASSERT(seekfile); + DEBUGASSERT(filep); inode = filep->f_inode; /* Invoke the file seek method if available */ @@ -173,9 +173,6 @@ errout: off_t lseek(int fd, off_t offset, int whence) { FAR struct filelist *list; - FAR struct file *filep; - FAR struct inode *inode; - int err; /* Did we get a valid file descriptor? */ @@ -184,15 +181,17 @@ off_t lseek(int fd, off_t offset, int whence) set_errno(EBADF); return (off_t)ERROR; } + else + { + /* Get the thread-specific file list */ - /* Get the thread-specific file list */ + list = sched_getfiles(); + DEBUGASSERT(list); - list = sched_getfiles(); - DEBUGASSERT(list); + /* Then let file_seek do the real work */ - /* Then let file_seek do the real work */ - - return file_seek(&list->fl_files[fd], offset, whence); + return file_seek(&list->fl_files[fd], offset, whence); + } } #endif diff --git a/fs/fs_write.c b/fs/fs_write.c index 7b6a8172f95..3aad823a8e9 100644 --- a/fs/fs_write.c +++ b/fs/fs_write.c @@ -67,7 +67,17 @@ static inline ssize_t file_write(int fd, FAR const void *buf, size_t nbytes) /* Get the thread-specific file list */ list = sched_getfiles(); - DEBUGASSERT(list); + + /* The file list can be NULL under one obscure cornercase: When memory + * management debug output is enabled. Then there may be attempts to + * write to stdout from malloc before the group data has been allocated. + */ + + if (!list) + { + err = EAGAIN; + goto errout; + } /* Was this file opened for write access? */ diff --git a/include/nuttx/fs/fs.h b/include/nuttx/fs/fs.h index a1678b6031c..4a883792aec 100644 --- a/include/nuttx/fs/fs.h +++ b/include/nuttx/fs/fs.h @@ -621,7 +621,7 @@ int lib_flushall(FAR struct streamlist *list); ssize_t lib_sendfile(int outfd, int infd, off_t *offset, size_t count); #endif -/* fs/fs_fileread.c *********************************************************/ +/* fs/fs_read.c *************************************************************/ /**************************************************************************** * Name: file_read * @@ -636,7 +636,7 @@ ssize_t lib_sendfile(int outfd, int infd, off_t *offset, size_t count); ssize_t file_read(FAR struct file *filep, FAR void *buf, size_t nbytes); #endif -/* fs/fs_fileread.c *********************************************************/ +/* fs/fs_lseek.c ************************************************************/ /**************************************************************************** * Name: file_seek *