RTEMS Logo

RTEMS 4.9.3 On-Line Library


File/Device/Directory function access via file control block - rtems_libio_t structure

PREV UP NEXT Bookshelf RTEMS Filesystem Design Guide

5.3.2: File/Device/Directory function access via file control block - rtems_libio_t structure

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.

  1. File Descriptor Table

    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.

  2. Allocation of entry in the File Descriptor Table

    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.

  3. Maximum number of entries in the file descriptor table is configurable through the src/exec/sapi/headers/confdefs.h file. If the CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS constant is defined its value will represent the maximum number of file descriptors that are allowed. If CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS is not specified a default value of 20 will be used as the maximum number of file descriptors allowed.
  4. File control block - rtems_libio_t structure
    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:


PREV UP NEXT Bookshelf RTEMS Filesystem Design Guide

Copyright © 1988-2008 OAR Corporation