mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
Merge remote-tracking branch 'origin/master' into vnc
This commit is contained in:
@@ -11642,4 +11642,8 @@
|
|||||||
* net/sockets/listen.c and accept.c and include/nuttx/net: Separate
|
* net/sockets/listen.c and accept.c and include/nuttx/net: Separate
|
||||||
out psock_listen() and psock_accepti() for internal OS usage
|
out psock_listen() and psock_accepti() for internal OS usage
|
||||||
(2016-04-14).
|
(2016-04-14).
|
||||||
|
* fs/inode/, fs/vfs/, and sched/task/: File and socket descriptors are
|
||||||
|
no longer allocated for kernel threads. They must use SYSLOG for
|
||||||
|
output and the low-level psock interfaces for network I/O. This
|
||||||
|
saves a little memory which might be important for small footprint
|
||||||
|
configurations (2015-04-14).
|
||||||
|
|||||||
+26
-21
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* fs/inode/fs_files.c
|
* fs/inode/fs_files.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2009, 2011-2013 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007-2009, 2011-2013, 2016 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -51,22 +51,6 @@
|
|||||||
|
|
||||||
#include "inode/inode.h"
|
#include "inode/inode.h"
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Types
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Data
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Data
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -222,9 +206,18 @@ int file_dup2(FAR struct file *filep1, FAR struct file *filep2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
list = sched_getfiles();
|
list = sched_getfiles();
|
||||||
DEBUGASSERT(list);
|
|
||||||
|
|
||||||
|
/* The file list can be NULL under two cases: (1) One is an 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. The other other is (2) if this is a kernel
|
||||||
|
* thread. Kernel threads have no allocated file descriptors.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (list != NULL)
|
||||||
|
{
|
||||||
_files_semtake(list);
|
_files_semtake(list);
|
||||||
|
}
|
||||||
|
|
||||||
/* If there is already an inode contained in the new file structure,
|
/* If there is already an inode contained in the new file structure,
|
||||||
* close the file and release the inode.
|
* close the file and release the inode.
|
||||||
@@ -278,7 +271,11 @@ int file_dup2(FAR struct file *filep1, FAR struct file *filep2)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (list != NULL)
|
||||||
|
{
|
||||||
_files_semgive(list);
|
_files_semgive(list);
|
||||||
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
/* Handler various error conditions */
|
/* Handler various error conditions */
|
||||||
@@ -291,7 +288,11 @@ errout_with_inode:
|
|||||||
|
|
||||||
errout_with_ret:
|
errout_with_ret:
|
||||||
err = -ret;
|
err = -ret;
|
||||||
|
|
||||||
|
if (list != NULL)
|
||||||
|
{
|
||||||
_files_semgive(list);
|
_files_semgive(list);
|
||||||
|
}
|
||||||
|
|
||||||
errout:
|
errout:
|
||||||
set_errno(err);
|
set_errno(err);
|
||||||
@@ -312,8 +313,10 @@ int files_allocate(FAR struct inode *inode, int oflags, off_t pos, int minfd)
|
|||||||
FAR struct filelist *list;
|
FAR struct filelist *list;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
/* Get the file descriptor list. It should not be NULL in this context. */
|
||||||
|
|
||||||
list = sched_getfiles();
|
list = sched_getfiles();
|
||||||
DEBUGASSERT(list);
|
DEBUGASSERT(list != NULL);
|
||||||
|
|
||||||
_files_semtake(list);
|
_files_semtake(list);
|
||||||
for (i = minfd; i < CONFIG_NFILE_DESCRIPTORS; i++)
|
for (i = minfd; i < CONFIG_NFILE_DESCRIPTORS; i++)
|
||||||
@@ -349,10 +352,12 @@ int files_close(int fd)
|
|||||||
FAR struct filelist *list;
|
FAR struct filelist *list;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Get the thread-specific file list */
|
/* Get the thread-specific file list. It should never be NULL in this
|
||||||
|
* context.
|
||||||
|
*/
|
||||||
|
|
||||||
list = sched_getfiles();
|
list = sched_getfiles();
|
||||||
DEBUGASSERT(list);
|
DEBUGASSERT(list != NULL);
|
||||||
|
|
||||||
/* If the file was properly opened, there should be an inode assigned */
|
/* If the file was properly opened, there should be an inode assigned */
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* Is it better to allocate the struct inode_path_s from the heap? or
|
/* Is it better to allocate the struct inode_path_s from the heap? or
|
||||||
* from the stack? This decision depends on how often this is down and
|
* from the stack? This decision depends on how often this is down and
|
||||||
* how much stack space you can afford.
|
* how much stack space you can afford.
|
||||||
|
|||||||
+2
-1
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* fs/inode/fs_inode.c
|
* fs/inode/fs_inode.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007-2009, 2011-2012, 2016 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -57,6 +57,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Types
|
* Private Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* Implements a re-entrant mutex for inode access. This must be re-entrant
|
/* Implements a re-entrant mutex for inode access. This must be re-entrant
|
||||||
* because there can be cycles. For example, it may be necessary to destroy
|
* because there can be cycles. For example, it may be necessary to destroy
|
||||||
* a block driver inode on umount() after a removable block device has been
|
* a block driver inode on umount() after a removable block device has been
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* fs/vfs/fs_getfilep.c
|
* fs/vfs/fs_getfilep.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -91,12 +91,14 @@ FAR struct file *fs_getfilep(int fd)
|
|||||||
|
|
||||||
list = sched_getfiles();
|
list = sched_getfiles();
|
||||||
|
|
||||||
/* The file list can be NULL under one obscure cornercase: When memory
|
/* The file list can be NULL under two cases: (1) One is an obscure
|
||||||
* management debug output is enabled. Then there may be attempts to
|
* cornercase: When memory management debug output is enabled. Then
|
||||||
* write to stdout from malloc before the group data has been allocated.
|
* there may be attempts to write to stdout from malloc before the group
|
||||||
|
* data has been allocated. The other other is (2) if this is a kernel
|
||||||
|
* thread. Kernel threads have no allocated file descriptors.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!list)
|
if (list == NULL)
|
||||||
{
|
{
|
||||||
errcode = EAGAIN;
|
errcode = EAGAIN;
|
||||||
goto errout;
|
goto errout;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* sched/task/task_create.c
|
* sched/task/task_create.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2010, 2013-2014 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007-2010, 2013-2014, 2016 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -85,7 +85,8 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int thread_create(FAR const char *name, uint8_t ttype, int priority,
|
static int thread_create(FAR const char *name, uint8_t ttype, int priority,
|
||||||
int stack_size, main_t entry, FAR char * const argv[])
|
int stack_size, main_t entry,
|
||||||
|
FAR char * const argv[])
|
||||||
{
|
{
|
||||||
FAR struct task_tcb_s *tcb;
|
FAR struct task_tcb_s *tcb;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
@@ -115,15 +116,21 @@ static int thread_create(FAR const char *name, uint8_t ttype, int priority,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Associate file descriptors with the new task */
|
|
||||||
|
|
||||||
#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NSOCKET_DESCRIPTORS > 0
|
#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||||
|
/* Associate file descriptors with the new task. Exclude kernel threads;
|
||||||
|
* kernel threads do not have file or socket descriptors. They must use
|
||||||
|
* SYSLOG for output and the low-level psock interfaces for network I/O.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (ttype != TCB_FLAG_TTYPE_KERNEL)
|
||||||
|
{
|
||||||
ret = group_setuptaskfiles(tcb);
|
ret = group_setuptaskfiles(tcb);
|
||||||
if (ret < OK)
|
if (ret < OK)
|
||||||
{
|
{
|
||||||
errcode = -ret;
|
errcode = -ret;
|
||||||
goto errout_with_tcb;
|
goto errout_with_tcb;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Allocate the stack for the TCB */
|
/* Allocate the stack for the TCB */
|
||||||
@@ -228,7 +235,8 @@ errout:
|
|||||||
int task_create(FAR const char *name, int priority,
|
int task_create(FAR const char *name, int priority,
|
||||||
int stack_size, main_t entry, FAR char * const argv[])
|
int stack_size, main_t entry, FAR char * const argv[])
|
||||||
{
|
{
|
||||||
return thread_create(name, TCB_FLAG_TTYPE_TASK, priority, stack_size, entry, argv);
|
return thread_create(name, TCB_FLAG_TTYPE_TASK, priority, stack_size,
|
||||||
|
entry, argv);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -251,5 +259,6 @@ int task_create(FAR const char *name, int priority,
|
|||||||
int kernel_thread(FAR const char *name, int priority,
|
int kernel_thread(FAR const char *name, int priority,
|
||||||
int stack_size, main_t entry, FAR char * const argv[])
|
int stack_size, main_t entry, FAR char * const argv[])
|
||||||
{
|
{
|
||||||
return thread_create(name, TCB_FLAG_TTYPE_KERNEL, priority, stack_size, entry, argv);
|
return thread_create(name, TCB_FLAG_TTYPE_KERNEL, priority, stack_size,
|
||||||
|
entry, argv);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user