The POSIX open() function returns an integer file descriptor that is used as a reference to file control block information for a specific file. The file control block contains information that is used to locate node, file system, mount table and functional handler information. The diagram in Figure 8 depicts the relationship between and among the following components.
This is an internal RTEMS structure that tracks all currently defined file descriptors in the system. The index that is returned by the file open() operation references a slot in this table. The slot contains a pointer to the file descriptor table entry for this file. The rtems_libio_t structure represents the file control block.
Access to the file descriptor table is controlled through a semaphore that is implemented using the rtems_libio_allocate() function. This routine will grab a semaphore and then scan the file control blocks to determine which slot is free for use. The first free slot is marked as used and the index to this slot is returned as the file descriptor for the open() request. After the alterations have been made to the file control block table, the semaphore is released to allow further operations on the table.
struct rtems_libio_tt { rtems_driver_name_t *driver; off_t size; off_t offset; unsigned32 flags; rtems_filesystem_location_info_t pathinfo; Objects_Id sem; unsigned32 data0; void data1; void file_info; rtems_filesystem_file_handlers_r handlers; };
A file control block can exist for regular files, devices and directories. The following fields are important for regular file and directory access:
Copyright © 1988-2000 OAR Corporation