CONFIG_NFILE_DESCRIPTORS=0 can no longer be used to disable the file system. NuttX with no file system does not make sense.

Squashed commit of the following:

    configs/:  The few configurations that formerly set CONFIG_NFILE_DESCRIPTORS=0 should not default, rather they should set the number of descriptors to 3.
    fs/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    tools/:  Tools updates for changes to usage of CONFIG_NFILE_DESCRIPTORS.
    syscall/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    libs/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    include/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    drivers/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    Documentation/:  Remove all references to CONFIG_NFILE_DESCRIPTORS == 0
    binfmt/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    arch/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    net/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    sched/:  Remove all conditional logic based on CONFIG_NFILE_DESCRIPTORS == 0
    sched/Kconfig:  CONFIG_NFILE_DESCRIPTORS may no longer to set to a value less than 3
    configs/:  Remove all settings for CONFIG_NFILE_DESCRIPTORS < 3
This commit is contained in:
Gregory Nutt
2019-02-11 12:09:26 -06:00
parent 07bcc6292a
commit a64869aa67
141 changed files with 374 additions and 1008 deletions
-37
View File
@@ -33,42 +33,6 @@
#
############################################################################
# If there are no file descriptors configured, then a small part of the
# logic in this directory may still apply to socket descriptors
ifeq ($(CONFIG_NFILE_DESCRIPTORS),0)
ifneq ($(CONFIG_NSOCKET_DESCRIPTORS),0)
# Socket descriptor support
CSRCS += fs_close.c fs_read.c fs_write.c fs_ioctl.c
# Support for network access using streams
ifneq ($(CONFIG_NFILE_STREAMS),0)
CSRCS += fs_fdopen.c
endif
# Support for poll() and select() (which derives from poll()
ifneq ($(CONFIG_DISABLE_POLL),y)
CSRCS += fs_poll.c fs_select.c
endif
# Support for sendfile()
ifeq ($(CONFIG_NET_SENDFILE),y)
CSRCS += fs_sendfile.c
endif
# Include vfs build support
DEPPATH += --dep-path vfs
VPATH += :vfs
endif
else
# Common file/socket descriptor support
CSRCS += fs_close.c fs_dup.c fs_dup2.c fs_fcntl.c fs_dupfd.c fs_dupfd2.c
@@ -106,4 +70,3 @@ endif
DEPPATH += --dep-path vfs
VPATH += :vfs
endif
+1 -8
View File
@@ -82,24 +82,20 @@
int close(int fd)
{
int errcode;
#if CONFIG_NFILE_DESCRIPTORS > 0
int ret;
#endif
/* close() is a cancellation point */
(void)enter_cancellation_point();
#if CONFIG_NFILE_DESCRIPTORS > 0
/* Did we get a valid file descriptor? */
if ((unsigned int)fd >= CONFIG_NFILE_DESCRIPTORS)
#endif
{
/* Close a socket descriptor */
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
if ((unsigned int)fd < (CONFIG_NFILE_DESCRIPTORS+CONFIG_NSOCKET_DESCRIPTORS))
if ((unsigned int)fd < (CONFIG_NFILE_DESCRIPTORS + CONFIG_NSOCKET_DESCRIPTORS))
{
ret = net_close(fd);
if (ret < 0)
@@ -119,7 +115,6 @@ int close(int fd)
}
}
#if CONFIG_NFILE_DESCRIPTORS > 0
/* Close the driver or mountpoint. NOTES: (1) there is no
* exclusion mechanism here, the driver or mountpoint must be
* able to handle concurrent operations internally, (2) The driver
@@ -142,8 +137,6 @@ int close(int fd)
leave_cancellation_point();
return OK;
#endif
errout:
set_errno(errcode);
leave_cancellation_point();
+1 -3
View File
@@ -65,7 +65,6 @@ int dup(int fd)
/* Check the range of the descriptor to see if we got a file or a socket
* descriptor. */
#if CONFIG_NFILE_DESCRIPTORS > 0
if ((unsigned int)fd < CONFIG_NFILE_DESCRIPTORS)
{
/* Its a valid file descriptor.. dup the file descriptor using any
@@ -76,12 +75,11 @@ int dup(int fd)
ret = fs_dupfd(fd, 0);
}
else
#endif
{
/* Not a valid file descriptor. Did we get a valid socket descriptor? */
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
if ((unsigned int)fd < (CONFIG_NFILE_DESCRIPTORS+CONFIG_NSOCKET_DESCRIPTORS))
if ((unsigned int)fd < (CONFIG_NFILE_DESCRIPTORS + CONFIG_NSOCKET_DESCRIPTORS))
{
/* Yes.. dup the socket descriptor. The errno value is not set. */
+5 -4
View File
@@ -1,7 +1,8 @@
/****************************************************************************
* fs/vfs/fs_dup2.c
*
* Copyright (C) 2007-2009, 2011, 2013, 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2009, 2011, 2013, 2017 Gregory Nutt. All rights
* reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -50,7 +51,7 @@
* performed.
*/
#if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
/****************************************************************************
* Public Functions
@@ -77,7 +78,7 @@ int dup2(int fd1, int fd2)
/* Not a valid file descriptor. Did we get a valid socket descriptor? */
if ((unsigned int)fd1 < (CONFIG_NFILE_DESCRIPTORS+CONFIG_NSOCKET_DESCRIPTORS))
if ((unsigned int)fd1 < (CONFIG_NFILE_DESCRIPTORS + CONFIG_NSOCKET_DESCRIPTORS))
{
/* Yes.. dup the socket descriptor. The errno value is not set. */
@@ -110,5 +111,5 @@ int dup2(int fd1, int fd2)
}
}
#endif /* CONFIG_NFILE_DESCRIPTORS > 0 ... */
#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS > 0 */
+2 -5
View File
@@ -1,7 +1,8 @@
/****************************************************************************
* fs/vfs/fs_dupfd.c
*
* Copyright (C) 2007-2009, 2011-2014, 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2009, 2011-2014, 2017 Gregory Nutt. All rights
* reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -47,8 +48,6 @@
#include "inode/inode.h"
#if CONFIG_NFILE_DESCRIPTORS > 0
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@@ -147,5 +146,3 @@ errout:
return ERROR;
}
#endif /* CONFIG_NFILE_DESCRIPTORS > 0 */
-4
View File
@@ -46,8 +46,6 @@
#include "inode/inode.h"
#if CONFIG_NFILE_DESCRIPTORS > 0
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@@ -133,5 +131,3 @@ errout:
return ERROR;
}
#endif /* CONFIG_NFILE_DESCRIPTORS > 0 */
+1 -7
View File
@@ -75,7 +75,6 @@
*
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
int file_vfcntl(FAR struct file *filep, int cmd, va_list ap)
{
int ret = -EINVAL;
@@ -212,7 +211,6 @@ int file_vfcntl(FAR struct file *filep, int cmd, va_list ap)
return ret;
}
#endif /* CONFIG_NFILE_DESCRIPTORS > 0 */
/****************************************************************************
* Name: file_fcntl
@@ -233,7 +231,6 @@ int file_vfcntl(FAR struct file *filep, int cmd, va_list ap)
*
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
int file_fcntl(FAR struct file *filep, int cmd, ...)
{
va_list ap;
@@ -252,7 +249,6 @@ int file_fcntl(FAR struct file *filep, int cmd, ...)
va_end(ap);
return ret;
}
#endif
/****************************************************************************
* Name: fcntl
@@ -289,7 +285,6 @@ int fcntl(int fd, int cmd, ...)
/* Did we get a valid file descriptor? */
#if CONFIG_NFILE_DESCRIPTORS > 0
if ((unsigned int)fd < CONFIG_NFILE_DESCRIPTORS)
{
/* Get the file structure corresponding to the file descriptor. */
@@ -307,12 +302,11 @@ int fcntl(int fd, int cmd, ...)
}
}
else
#endif
{
/* No... check for operations on a socket descriptor */
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
if ((unsigned int)fd < (CONFIG_NFILE_DESCRIPTORS+CONFIG_NSOCKET_DESCRIPTORS))
if ((unsigned int)fd < (CONFIG_NFILE_DESCRIPTORS + CONFIG_NSOCKET_DESCRIPTORS))
{
/* Yes.. defer socket descriptor operations to net_vfcntl(). The
* errno is not set on failures.
+3 -7
View File
@@ -62,7 +62,6 @@
*
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
static inline int fs_checkfd(FAR struct tcb_s *tcb, int fd, int oflags)
{
FAR struct file *filep;
@@ -110,7 +109,6 @@ static inline int fs_checkfd(FAR struct tcb_s *tcb, int fd, int oflags)
return OK;
}
#endif
/****************************************************************************
* Public Functions
@@ -159,9 +157,7 @@ FAR struct file_struct *fs_fdopen(int fd, int oflags, FAR struct tcb_s *tcb)
* lie in a different range.
*/
#if CONFIG_NFILE_DESCRIPTORS > 0
if ((unsigned int)fd >= CONFIG_NFILE_DESCRIPTORS)
#endif
{
/* No.. If networking is enabled then this might be a socket
* descriptor.
@@ -177,14 +173,14 @@ FAR struct file_struct *fs_fdopen(int fd, int oflags, FAR struct tcb_s *tcb)
#endif
}
/* The descriptor is in a valid range to file descriptor... perform some more checks */
/* The descriptor is in a valid range to file descriptor... perform some
* more checks.
*/
#if CONFIG_NFILE_DESCRIPTORS > 0
else
{
ret = fs_checkfd(tcb, fd, oflags);
}
#endif
/* Do we have a good descriptor of some sort? */
+1 -9
View File
@@ -75,7 +75,6 @@
*
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
int file_ioctl(FAR struct file *filep, int req, unsigned long arg)
{
FAR struct inode *inode;
@@ -101,7 +100,6 @@ int file_ioctl(FAR struct file *filep, int req, unsigned long arg)
return (int)inode->u.i_ops->ioctl(filep, req, arg);
}
#endif /* CONFIG_NFILE_DESCRIPTORS > 0 */
/****************************************************************************
* Name: ioctl/fs_ioctl
@@ -139,19 +137,17 @@ int ioctl(int fd, int req, unsigned long arg)
#endif
{
int errcode;
#if CONFIG_NFILE_DESCRIPTORS > 0
FAR struct file *filep;
int ret;
/* Did we get a valid file descriptor? */
if ((unsigned int)fd >= CONFIG_NFILE_DESCRIPTORS)
#endif
{
/* Perform the socket ioctl */
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
if ((unsigned int)fd < (CONFIG_NFILE_DESCRIPTORS+CONFIG_NSOCKET_DESCRIPTORS))
if ((unsigned int)fd < (CONFIG_NFILE_DESCRIPTORS + CONFIG_NSOCKET_DESCRIPTORS))
{
ret = netdev_ioctl(fd, req, arg);
if (ret < 0)
@@ -170,7 +166,6 @@ int ioctl(int fd, int req, unsigned long arg)
}
}
#if CONFIG_NFILE_DESCRIPTORS > 0
/* Get the file structure corresponding to the file descriptor. */
ret = fs_getfilep(fd, &filep);
@@ -194,9 +189,6 @@ int ioctl(int fd, int req, unsigned long arg)
}
return ret;
#else
errcode = ENOTTY;
#endif
errout:
set_errno(errcode);
-3
View File
@@ -47,8 +47,6 @@
#include "inode/inode.h"
#if CONFIG_NFILE_DESCRIPTORS > 0
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -194,4 +192,3 @@ errout:
return (off_t)ERROR;
}
#endif
+2 -12
View File
@@ -98,7 +98,6 @@ static int poll_semtake(FAR sem_t *sem)
*
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
static int poll_fdsetup(int fd, FAR struct pollfd *fds, bool setup)
{
/* Check for a valid file descriptor */
@@ -121,7 +120,6 @@ static int poll_fdsetup(int fd, FAR struct pollfd *fds, bool setup)
return fdesc_poll(fd, fds, setup);
}
#endif
/****************************************************************************
* Name: poll_setup
@@ -131,7 +129,6 @@ static int poll_fdsetup(int fd, FAR struct pollfd *fds, bool setup)
*
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
static inline int poll_setup(FAR struct pollfd *fds, nfds_t nfds, sem_t *sem)
{
unsigned int i;
@@ -227,7 +224,6 @@ static inline int poll_setup(FAR struct pollfd *fds, nfds_t nfds, sem_t *sem)
return OK;
}
#endif
/****************************************************************************
* Name: poll_teardown
@@ -238,9 +234,8 @@ static inline int poll_setup(FAR struct pollfd *fds, nfds_t nfds, sem_t *sem)
*
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
static inline int poll_teardown(FAR struct pollfd *fds, nfds_t nfds, int *count,
int ret)
static inline int poll_teardown(FAR struct pollfd *fds, nfds_t nfds,
FAR int *count, int ret)
{
unsigned int i;
int status = OK;
@@ -299,7 +294,6 @@ static inline int poll_teardown(FAR struct pollfd *fds, nfds_t nfds, int *count,
return ret;
}
#endif
/****************************************************************************
* Public Functions
@@ -324,7 +318,6 @@ static inline int poll_teardown(FAR struct pollfd *fds, nfds_t nfds, int *count,
*
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
int file_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup)
{
FAR struct inode *inode;
@@ -370,7 +363,6 @@ int file_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup)
return ret;
}
#endif
/****************************************************************************
* Name: fdesc_poll
@@ -391,7 +383,6 @@ int file_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup)
*
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
int fdesc_poll(int fd, FAR struct pollfd *fds, bool setup)
{
FAR struct file *filep;
@@ -411,7 +402,6 @@ int fdesc_poll(int fd, FAR struct pollfd *fds, bool setup)
return file_poll(filep, fds, setup);
}
#endif
/****************************************************************************
* Name: poll
-9
View File
@@ -140,9 +140,7 @@ ssize_t nx_read(int fd, FAR void *buf, size_t nbytes)
{
/* Did we get a valid file descriptor? */
#if CONFIG_NFILE_DESCRIPTORS > 0
if ((unsigned int)fd >= CONFIG_NFILE_DESCRIPTORS)
#endif
{
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
/* No.. If networking is enabled, read() is the same as recv() with
@@ -156,8 +154,6 @@ ssize_t nx_read(int fd, FAR void *buf, size_t nbytes)
return -EBADF;
#endif
}
#if CONFIG_NFILE_DESCRIPTORS > 0
else
{
FAR struct file *filep;
@@ -178,11 +174,6 @@ ssize_t nx_read(int fd, FAR void *buf, size_t nbytes)
return file_read(filep, buf, nbytes);
}
#else
/* I don't think we can get here */
return -ENOSYS;
#endif
}
/****************************************************************************
+3 -2
View File
@@ -50,7 +50,7 @@
#include <nuttx/sched.h>
#include <nuttx/net/net.h>
#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NET_SENDFILE
#ifdef CONFIG_NET_SENDFILE
/****************************************************************************
* Public Functions
@@ -148,4 +148,5 @@ ssize_t sendfile(int outfd, int infd, off_t *offset, size_t count)
return lib_sendfile(outfd, infd, offset, count);
}
#endif /* CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NET_SENDFILE */
#endif /* CONFIG_NET_SENDFILE */
-7
View File
@@ -137,9 +137,7 @@ ssize_t file_write(FAR struct file *filep, FAR const void *buf, size_t nbytes)
ssize_t nx_write(int fd, FAR const void *buf, size_t nbytes)
{
#if CONFIG_NFILE_DESCRIPTORS > 0
FAR struct file *filep;
#endif
ssize_t ret;
if (buf == NULL)
@@ -149,9 +147,7 @@ ssize_t nx_write(int fd, FAR const void *buf, size_t nbytes)
/* Did we get a valid file descriptor? */
#if CONFIG_NFILE_DESCRIPTORS > 0
if ((unsigned int)fd >= CONFIG_NFILE_DESCRIPTORS)
#endif
{
#if defined(CONFIG_NET_TCP) && CONFIG_NSOCKET_DESCRIPTORS > 0
/* Write to a socket descriptor is equivalent to send with flags == 0. */
@@ -161,8 +157,6 @@ ssize_t nx_write(int fd, FAR const void *buf, size_t nbytes)
ret = -EBADF;
#endif
}
#if CONFIG_NFILE_DESCRIPTORS > 0
else
{
/* The descriptor is in the right range to be a file descriptor..
@@ -180,7 +174,6 @@ ssize_t nx_write(int fd, FAR const void *buf, size_t nbytes)
ret = file_write(filep, buf, nbytes);
}
}
#endif
return ret;
}