RTEMS Logo

RTEMS 4.7.2 On-Line Library


open

PREV UP NEXT Bookshelf RTEMS Filesystem Design Guide

4.21: open

File:

open.c

Processing:

This routine is layered on both RTEMS calls and filesystem specific implementations of the open() function. These functional interfaces should not change for new filesystems and therefore this code should be stable as new file systems are introduced.

Development Comments:

This routine will allocate a file control block for the file or device that we are about to open.

It will then test to see if the pathname exists. If it does a rtems_filesystem_location_info_t data structure will be filled out. This structure contains information that associates node information, filesystem specific functions and mount table chain information with the pathname.

If the create option has been it will attempt to create a node for a regular file along the specified path. If a file already exists along this path, an error will be generated; otherwise, a node will be allocated for the file under the filesystem that contains the pathname. When a new node is created, it is also evaluated so that an appropriate rtems_filesystem_location_info_t data structure can be filled out for the newly created node.

If the file exists or the new file was created successfully, the file control block structure will be initialized with handler table information, node information and the rtems_filesystem_location_info_t data structure that describes the node and filesystem data in detail.

If an open() function exists in the filesystem specific handlers table for the node that we are trying to open, it will be called at this time.

If any error is detected in the process, cleanup is performed. It consists of freeing the file control block structure that was allocated at the beginning of the generic open() routine.

On a successful open(), the index into the file descriptor table will be calculated and returned to the calling routine.


PREV UP NEXT Bookshelf RTEMS Filesystem Design Guide

Copyright © 1988-2004 OAR Corporation