mirror of
https://github.com/apache/nuttx.git
synced 2026-05-22 13:52:22 +08:00
fs: allocate file/socket dynamically
Change-Id: I8aea63eaf0275f47f21fc8d5482b51ffecd5c906 Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
@@ -113,11 +113,7 @@ struct aiocb
|
||||
FAR volatile void *aio_buf; /* Location of buffer */
|
||||
off_t aio_offset; /* File offset */
|
||||
size_t aio_nbytes; /* Length of transfer */
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 127
|
||||
int16_t aio_fildes; /* File descriptor (should be int) */
|
||||
#else
|
||||
int8_t aio_fildes; /* File descriptor (should be int) */
|
||||
#endif
|
||||
int8_t aio_reqprio; /* Request priority offset (not used, should be int) */
|
||||
uint8_t aio_lio_opcode; /* Operation to be performed (should be int) */
|
||||
|
||||
|
||||
+2
-2
@@ -120,10 +120,10 @@
|
||||
#define _POSIX_MAX_INPUT 255
|
||||
#define _POSIX_NAME_MAX CONFIG_NAME_MAX
|
||||
#define _POSIX_NGROUPS_MAX 0
|
||||
#define _POSIX_OPEN_MAX CONFIG_NFILE_DESCRIPTORS
|
||||
#define _POSIX_OPEN_MAX INT_MAX
|
||||
#define _POSIX_PATH_MAX CONFIG_PATH_MAX
|
||||
#define _POSIX_PIPE_BUF 512
|
||||
#define _POSIX_STREAM_MAX CONFIG_NFILE_DESCRIPTORS
|
||||
#define _POSIX_STREAM_MAX INT_MAX
|
||||
#define _POSIX_TZNAME_MAX 3
|
||||
|
||||
#ifdef CONFIG_SMALL_MEMORY
|
||||
|
||||
+23
-3
@@ -377,12 +377,18 @@ struct file
|
||||
FAR void *f_priv; /* Per file driver private data */
|
||||
};
|
||||
|
||||
/* This defines a list of files indexed by the file descriptor */
|
||||
/* This defines a two layer array of files indexed by the file descriptor.
|
||||
* Each row of this array is fixed size: CONFIG_NFILE_DESCRIPTORS_PER_BLOCK.
|
||||
* You can get file instance in filelist by the follow methods:
|
||||
* (file descriptor / CONFIG_NFILE_DESCRIPTORS_PER_BLOCK) as row index and
|
||||
* (file descriptor % CONFIG_NFILE_DESCRIPTORS_PER_BLOCK) as column index.
|
||||
*/
|
||||
|
||||
struct filelist
|
||||
{
|
||||
sem_t fl_sem; /* Manage access to the file list */
|
||||
struct file fl_files[CONFIG_NFILE_DESCRIPTORS];
|
||||
sem_t fl_sem; /* Manage access to the file list */
|
||||
uint8_t fl_rows; /* The number of rows of fl_files array */
|
||||
FAR struct file **fl_files; /* The pointer of two layer file descriptors array */
|
||||
};
|
||||
|
||||
/* The following structure defines the list of files used for standard C I/O.
|
||||
@@ -713,6 +719,20 @@ void files_initlist(FAR struct filelist *list);
|
||||
|
||||
void files_releaselist(FAR struct filelist *list);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: files_duplist
|
||||
*
|
||||
* Description:
|
||||
* Duplicate parent task's file descriptors.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; a negated errno value is returned on
|
||||
* any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int files_duplist(FAR struct filelist *plist, FAR struct filelist *clist);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: file_dup
|
||||
*
|
||||
|
||||
@@ -77,13 +77,6 @@
|
||||
# define _NX_RECVFROM(s,b,l,f,a,n) recvfrom(s,b,l,f,a,n)
|
||||
#endif
|
||||
|
||||
/* Socket descriptors are the index into the TCB sockets list, offset by the
|
||||
* following amount. This offset is used to distinguish file descriptors from
|
||||
* socket descriptors
|
||||
*/
|
||||
|
||||
#define __SOCKFD_OFFSET CONFIG_NFILE_DESCRIPTORS
|
||||
|
||||
/* Capabilities of a socket */
|
||||
|
||||
#define SOCKCAP_NONBLOCKING (1 << 0) /* Bit 0: Socket supports non-blocking
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
/* Get the total number of descriptors that we will have to support */
|
||||
|
||||
#define FD_SETSIZE CONFIG_NFILE_DESCRIPTORS
|
||||
#define FD_SETSIZE 256
|
||||
|
||||
/* We will use a 32-bit bitsets to represent the set of descriptors. How
|
||||
* many uint32_t's do we need to span all descriptors?
|
||||
|
||||
Reference in New Issue
Block a user