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

4.104.114.84.95
Last change on this file since ffce9b39 was ffce9b39, checked in by Joel Sherrill <joel.sherrill@…>, on 10/11/99 at 20:10:03

More cleanup.

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