2008-01-30 00:58:39 +01:00
|
|
|
/****************************************************************************
|
2021-03-08 22:39:04 +01:00
|
|
|
* sched/group/group_setuptaskfiles.c
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
2020-04-28 18:17:03 +02:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
2008-01-30 00:58:39 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2008-01-30 00:58:39 +01:00
|
|
|
/****************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Included Files
|
2008-01-30 00:58:39 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
2007-09-01 20:06:15 +02:00
|
|
|
|
2007-02-18 00:21:28 +01:00
|
|
|
#include <sched.h>
|
2021-05-18 08:59:14 +02:00
|
|
|
#include <assert.h>
|
2007-09-01 20:06:15 +02:00
|
|
|
|
2012-03-21 19:01:07 +01:00
|
|
|
#include <nuttx/fs/fs.h>
|
2007-09-01 20:06:15 +02:00
|
|
|
|
2014-08-09 01:53:55 +02:00
|
|
|
#include "sched/sched.h"
|
2014-08-08 22:06:42 +02:00
|
|
|
#include "group/group.h"
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2008-01-30 00:58:39 +01:00
|
|
|
/****************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Public Functions
|
2008-01-30 00:58:39 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2008-01-30 00:58:39 +01:00
|
|
|
/****************************************************************************
|
2013-01-27 00:49:02 +01:00
|
|
|
* Name: group_setuptaskfiles
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Configure a newly allocated TCB so that it will inherit
|
|
|
|
* file descriptors and streams from the parent task.
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2007-02-18 00:21:28 +01:00
|
|
|
* tcb - tcb of the new task.
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2013-01-07 20:35:47 +01:00
|
|
|
* Zero (OK) is returned on success; A negated errno value is returned on
|
|
|
|
* failure.
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
*
|
2008-01-30 00:58:39 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2013-02-04 22:24:00 +01:00
|
|
|
int group_setuptaskfiles(FAR struct task_tcb_s *tcb)
|
2007-02-18 00:21:28 +01:00
|
|
|
{
|
2013-02-04 22:24:00 +01:00
|
|
|
FAR struct task_group_s *group = tcb->cmn.group;
|
2021-03-16 13:13:02 +01:00
|
|
|
#ifndef CONFIG_FDCLONE_DISABLE
|
|
|
|
FAR struct tcb_s *rtcb = this_task();
|
|
|
|
int ret;
|
|
|
|
#endif
|
2013-01-26 21:17:29 +01:00
|
|
|
|
|
|
|
DEBUGASSERT(group);
|
2022-03-01 07:28:15 +01:00
|
|
|
#ifndef CONFIG_DISABLE_PTHREAD
|
|
|
|
DEBUGASSERT((tcb->cmn.flags & TCB_FLAG_TTYPE_MASK) !=
|
|
|
|
TCB_FLAG_TTYPE_PTHREAD);
|
|
|
|
#endif
|
2013-01-26 21:17:29 +01:00
|
|
|
|
2021-03-16 13:13:02 +01:00
|
|
|
#ifndef CONFIG_FDCLONE_DISABLE
|
|
|
|
DEBUGASSERT(rtcb->group);
|
|
|
|
|
2022-03-01 07:28:15 +01:00
|
|
|
/* Duplicate the parent task's file descriptors */
|
2009-06-15 21:50:06 +02:00
|
|
|
|
2022-03-01 07:28:15 +01:00
|
|
|
ret = files_duplist(&rtcb->group->tg_filelist, &group->tg_filelist);
|
2021-03-16 13:13:02 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
#endif
|
2009-06-15 21:50:06 +02:00
|
|
|
|
2012-07-14 21:30:31 +02:00
|
|
|
/* Allocate file/socket streams for the new TCB */
|
2009-06-15 21:50:06 +02:00
|
|
|
|
2020-08-13 12:17:29 +02:00
|
|
|
#ifdef CONFIG_FILE_STREAM
|
2013-01-27 00:49:02 +01:00
|
|
|
return group_setupstreams(tcb);
|
2012-07-14 21:30:31 +02:00
|
|
|
#else
|
|
|
|
return OK;
|
2009-06-15 21:50:06 +02:00
|
|
|
#endif
|
2007-02-18 00:21:28 +01:00
|
|
|
}
|