mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-10-15 20:21:19 +08:00
Use RTEMS API for file handling
This commit is contained in:
59
rtemsbsd/rtems/rtems-bsd-get-file.c
Normal file
59
rtemsbsd/rtems/rtems-bsd-get-file.c
Normal file
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @ingroup rtems_bsd_rtems
|
||||
*
|
||||
* @brief TODO.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2013 embedded brains GmbH. All rights reserved.
|
||||
*
|
||||
* embedded brains GmbH
|
||||
* Dornierstr. 4
|
||||
* 82178 Puchheim
|
||||
* Germany
|
||||
* <rtems@embedded-brains.de>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <machine/rtems-bsd-config.h>
|
||||
|
||||
#include <sys/file.h>
|
||||
|
||||
struct file *
|
||||
rtems_bsd_get_file(int fd)
|
||||
{
|
||||
struct file *fp;
|
||||
|
||||
if ((uint32_t) fd < rtems_libio_number_iops) {
|
||||
fp = rtems_bsd_fd_to_fp(fd);
|
||||
if ((fp->f_io.flags & LIBIO_FLAGS_OPEN) != LIBIO_FLAGS_OPEN) {
|
||||
fp = NULL;
|
||||
}
|
||||
} else {
|
||||
fp = NULL;
|
||||
}
|
||||
|
||||
return fp;
|
||||
}
|
@@ -61,9 +61,6 @@ RTEMS_CHAIN_DEFINE_EMPTY(rtems_bsd_thread_chain);
|
||||
static struct ucred FIXME_ucred = {
|
||||
.cr_ref = 1 /* reference count */
|
||||
};
|
||||
static struct filedesc FIXME_fd = {
|
||||
.fd_ofiles = NULL /* file structures for open files */
|
||||
};
|
||||
static struct proc FIXME_proc = {
|
||||
.p_ucred = NULL /* (c) Process owner's identity. */
|
||||
};
|
||||
@@ -222,8 +219,6 @@ rtems_bsd_threads_init(void *arg __unused)
|
||||
mtx_init(&FIXME_proc.p_mtx, "process lock", NULL, MTX_DEF | MTX_DUPOK);
|
||||
FIXME_proc.p_pid = getpid();
|
||||
FIXME_proc.p_fibnum = 0;
|
||||
FIXME_proc.p_fd = &FIXME_fd;
|
||||
sx_init_flags(&FIXME_fd.fd_sx, "config SX thread lock", SX_DUPOK);
|
||||
}
|
||||
|
||||
SYSINIT(rtems_bsd_threads, SI_SUB_INTRINSIC, SI_ORDER_ANY, rtems_bsd_threads_init, NULL);
|
||||
|
Reference in New Issue
Block a user