source: rtems/doc/filesystem/applayering.t @ 6408000

4.104.114.84.95
Last change on this file since 6408000 was 6408000, checked in by Joel Sherrill <joel.sherrill@…>, on 10/07/99 at 22:39:16

Added applayering but did not finish it.

  • Property mode set to 100644
File size: 9.6 KB
RevLine 
[6408000]1@c
2
3@c  COPYRIGHT (c) 1988-1998.
4@c  On-Line Applications Research Corporation (OAR).
5@c  All rights reserved.
6@c
7@c  $Id$
8@c
9
10
11@chapter Applications and Functional Layering
12
13@section General
14
15The RTEMS file system framework was intended to be compliant with the POSIX
16Files and Directories interface standard. The following file system characteristics
17resulted in a functional switching layer (See figures 6 and 7).
18
19
20@example
21Figure 6
22@end example
23
24@enumerate
25
26@item Application programs are presented with a standard set of POSIX compliant
27functions that allow them to interface with the files, devices and directories in the
28file system. The interfaces to these routines do not reflect the type of subordinate
29file system implementation in which the file will be found.
30
31@item The file system framework developed under RTEMS allows for mounting file
32systems of different types under the base file system.( Figure 3 )
33
34@item The mechanics of locating file information may be quite different between file
35system types.
36
37@item The process of locating a file may require crossing file system boundaries.
38
39@item The transitions between file systems and the processing required to access
40information in different file systems is not visible at the level of the POSIX
41function call.
42
43@item The POSIX interface standard provides file access by character pathname to the
44file in some functions and through an integer file descriptor (Figure 8) in other
45functions.
46
47@item The nature of the integer file descriptor and its associated processing is operating
48system and file system specific.
49
50@item Directory and device information must be processed with some of the same
51routines that apply to files.
52
53@item The form and content of directory and device information differs greatly from that
54of a regular file.
55
56@item Files, directories and devices represent elements (nodes) of a tree hierarchy.
57
58@item The rules for processing each of the node types that exist under the file system are
59node specific but are still not reflected in the POSIX interface routines.
60
61@end enumerate
62
63
64@example
65Figure 7
66@end example
67
68
69
70
71
72@example
73Figure 8
74@end example
75
76
77
78
79
80
81@section  Mapping of Generic System Calls to File System Specific OP Table or Handler Functions
82
83@subsection Generic routines (open (), read (), write (), close (), . )
84
85The Files and Directories section of the POSIX Application Programs Interface
86specifies a set of functions with calling arguments that are used to gain access to the
87information in a file system. To the application program, these functions allow access
88to information in any mounted file system without explicit knowledge of the file
89system type or the file system mount configuration. The following are functions that
90are provided to the application:
91
92@enumerate
93@item access()
94@item chdir()
95@item chmod()
96@item chown()
97@item close()
98@item closedir()
99@item fchmod()
100@item fcntl()
101@item fdatasync()
102@item fpathconf()
103@item fstat()
104@item fsync()
105@item ftruncate()
106@item link()
107@item lseek()
108@item mkdir()
109@item mknod()
110@item mount()
111@item open()
112@item opendir()
113@item pathconf()
114@item read()
115@item readdir()
116@item rewinddir()
117@item rmdir()
118@item rmnod()
119@item scandir()
120@item seekdir()
121@item stat()
122@item telldir()
123@item umask()
124@item unlink()
125@item unmount()
126@item utime()
127@item write()
128@end enumerate
129
130The file system's type as well as the node type within the file system determine the
131nature of the processing that must be performed for each of the functions above. The
132RTEMS file system provides a framework that allows new file systems to be
133developed and integrated without alteration to the basic framework. 
134
135? Use of function pointers for functional redirection
136To provide the functional switching that is required, each of the POSIX file and
137directory functions have been implemented as a shell function. The shell function
138adheres to the POSIX interface standard. Within this functional shell, file system and
139node type information is accessed which is then used to invoke the appropriate file
140system and node type specific routine to process the POSIX function call.
141
142? File/Device/Directory function access via file control block - rtems_libio_t
143structure
144The POSIX open() function returns an integer file descriptor that is used as a
145reference to file control block information for a specific file. The file control block
146contains information that is used to locate node, file system, mount table and
147functional handler information. The diagram in Figure 8 depicts the relationship
148between and among the following components.
149
1501. File Descriptor Table - This is an internal RTEMS structure that tracks all
151currently defined file descriptors in the system. The index that is returned by
152the file open() operation references a slot in this table. The slot contains a
153pointer to the file descriptor table entry for this file. The rtems_libio_t
154structure represents the file control block.
1552. Allocation of entry in the File Descriptor Table - Access to the file descriptor
156table is controlled through a semaphore that is implemented using the
157rtems_libio_allocate() function. This routine will grab a semaphore and then
158scan the file control blocks to determine which slot is free for use. The first
159free slot is marked as used and the index to this slot is returned as the file
160descriptor for the open () request. After the alterations have been made to the
161file control block table, the semaphore is released to allow further operations
162on the table.
1633. Maximum number of entries in the file descriptor table is configurable
164through the src/exec/sapi/headers/confdefs.h file. If the
165CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS constant is
166defined its value will represent the maximum number of file descriptors that
167are allowed.                                                   
168If CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS is not
169specified a default value of 20 will be used as the maximum number of file
170descriptors allowed.
1714. File control block - rtems_libio_t structure
172struct rtems_libio_tt @{
173    rtems_driver_name_t            *driver;
174    off_t                                   size;      /* size of file */
175    off_t                                   offset;    /* current offset into file */
176    unsigned32                            flags;
177    rtems_filesystem_location_info_t    pathinfo;
178    Objects_Id                            sem;
179    unsigned32                            data0;   /* private to "driver" */
180    void                                   data1;     / . */
181    void                                   file_info; /used by file handlers/
182    rtems_filesystem_file_handlers_r   handlers; /type specific handlers/
183@};
184
185A file control block can exist for regular files, devices and directories. The
186following fields are important for regular file and directory access:
187? Size - For a file this represents the number of bytes currently stored in
188a file. For a directory this field is not filled in.
189? Offset - For a file this is the byte file position index relative to the start
190of the file. For a directory this is the byte offset into a sequence of
191dirent structures.
192? Pathinfo - This is a structure that provides a pointer to node
193information, OPS table functions, Handler functions and the mount
194table entry associated with this node.
195? file_info - A pointer to node information that is used by Handler
196functions
197? handlers - A pointer to a table of handler functions that operate on a
198file, device or directory through a file descriptor index
199
200? File/Directory function access via rtems_filesystem_location_info_t structure
201
202The rtems_filesystem_location_info_tt structure below provides sufficient
203information to process nodes under a mounted file system.
204
205struct rtems_filesystem_location_info_tt
206@{
207    void                                         *node_access;
208    rtems_filesystem_file_handlers_r         *handlers;
209    rtems_filesystem_operations_table        *ops;
210    rtems_filesystem_mount_table_entry_t     *mt_entry;
211@};
212
213It contains a void pointer to file system specific nodal structure, pointers to the
214OPS table for the file system that contains the node, the node type specific
215handlers for the node and a reference pointer to the mount table entry associated
216with the file system containing the node
217
218? File System Functional Interface to Files and Directories
219? Access using relative or absolute path names to file
220? OP Table for File System - rtems_filesystem_operations_table
2211. evalpath ()
2222. evalformake ()
2233. link ()
2244. unlink ()
2255. node_type ()
2266. mknod ()
2277. rmnod ()
2288. chown ()
2299. freenod ()
23010. mount ()
23111. fsmount_me ()
23212. unmount ()
23313. fsunmount_me ()
23414. utime ()
23515. eval_link ()
23616. symlink ()
23717. readlink ()
238
239? Access using file handle
240? Handlers for file system node types ( regular file, directories, and devices ) -
241rtems_filesystem_file_handlers_r
2421. open ()
2432. close ()
2443. read ()
2454. write ()
2465. ioctl ()
2476. lseek ()
2487. fstat ()
2498. fchmod ()
2509. ftruncate ()
25110. fpathconf ()
25211. fsync ()
25312. fdatasync ()
254
255
256
257? POSIX Directory Access Functions
258
259BSD/newlib has provided a set of POSIX directory access routines. These routines
260allow directories to be open and the entries under the directory read. The getdents
261routine allows for customization of the BSD routines to a particular file system
262implementation. Some of the original BSD routines were modified, but maintain the
263same calling interface as the original BSD/newlib routine.
264The following directory access routines are included in the BSD set:
265
266? opendir ()closedir ()
267? readdir ()
268? getdents ()
269? closedir ()
270? ***   rewinddir ()
271? scandir () (built on fstat () )
272? ***   seekdir ()
273? telldir ()
274
275*** Not the original BSD stuff
276
277
278Jennifer will fill this section in.
279
280
Note: See TracBrowser for help on using the repository browser.