fs/streams: Move the file streams from the group structure into TLS

This is preparation for flushing streams from user space, like it should
be done.

- Move tg_streamlist (group, kernel space) ->
       ta_streamlist (TLS, user space)
- Access stream list via tg_info in kernel
- Access stream list via TLS in user space
- Remove / rename nxsched_get_streams -> lib_getstreams
- Remove system call for nxsched_get_streams
This commit is contained in:
Ville Juven
2022-12-21 15:13:14 +02:00
committed by Xiang Xiao
parent 1a8cbc0b99
commit 2ed51d026c
15 changed files with 32 additions and 111 deletions
+6 -1
View File
@@ -107,7 +107,12 @@ extern "C"
struct task_group_s;
void lib_stream_initialize(FAR struct task_group_s *group);
void lib_stream_release(FAR struct task_group_s *group);
#endif
/* Functions contained in lib_getstreams.c **********************************/
struct streamlist;
FAR struct streamlist *lib_get_streams(void);
#endif /* CONFIG_FILE_STREAM */
/* Functions defined in lib_srand.c *****************************************/
-18
View File
@@ -495,21 +495,6 @@ struct task_group_s
struct filelist tg_filelist; /* Maps file descriptor to file */
#ifdef CONFIG_FILE_STREAM
/* FILE streams ***********************************************************/
/* In a flat, single-heap build. The stream list is allocated with this
* structure. But kernel mode with a kernel allocator,
* it must be separately allocated using a user-space allocator.
*/
#ifdef CONFIG_MM_KERNEL_HEAP
FAR struct streamlist *tg_streamlist;
#else
struct streamlist tg_streamlist; /* Holds C buffered I/O info */
#endif
#endif
#ifdef CONFIG_ARCH_ADDRENV
/* Address Environment ****************************************************/
@@ -841,9 +826,6 @@ int nxsched_release_tcb(FAR struct tcb_s *tcb, uint8_t ttype);
*/
FAR struct filelist *nxsched_get_files(void);
#ifdef CONFIG_FILE_STREAM
FAR struct streamlist *nxsched_get_streams(void);
#endif /* CONFIG_FILE_STREAM */
/****************************************************************************
* Name: nxtask_init
+4
View File
@@ -29,6 +29,7 @@
#include <nuttx/arch.h>
#include <nuttx/atexit.h>
#include <nuttx/fs/fs.h>
#include <sys/types.h>
#include <pthread.h>
@@ -146,6 +147,9 @@ struct task_info_s
#if CONFIG_LIBC_MAX_EXITFUNS > 0
struct atexit_list_s ta_exit; /* Exit functions */
#endif
#ifdef CONFIG_FILE_STREAM
struct streamlist ta_streamlist; /* Holds C buffered I/O info */
#endif
};
/* struct pthread_cleanup_s *************************************************/
+4 -4
View File
@@ -32,7 +32,7 @@
#include <time.h>
#include <nuttx/fs/fs.h>
#include <nuttx/sched.h>
#include <nuttx/lib/lib.h>
/****************************************************************************
* Pre-processor Definitions
@@ -63,9 +63,9 @@
/* The first three _iob entries are reserved for standard I/O */
#define stdin (&nxsched_get_streams()->sl_std[0])
#define stdout (&nxsched_get_streams()->sl_std[1])
#define stderr (&nxsched_get_streams()->sl_std[2])
#define stdin (&lib_get_streams()->sl_std[0])
#define stdout (&lib_get_streams()->sl_std[1])
#define stderr (&lib_get_streams()->sl_std[2])
/* Path to the directory where temporary files can be created */
-1
View File
@@ -268,7 +268,6 @@ SYSCALL_LOOKUP(futimens, 2)
#ifdef CONFIG_FILE_STREAM
SYSCALL_LOOKUP(fs_fdopen, 4)
SYSCALL_LOOKUP(nxsched_get_streams, 0)
#endif
#ifndef CONFIG_DISABLE_MOUNTPOINT