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

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

Added Base File System chapter. Builds completely.

  • Property mode set to 100644
File size: 10.1 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 Base File System
11
12RTEMS initially mounts a RAM based file system known as the base file system.
13The root directory of this file system tree serves as the logical root of the directory
14hierarchy (Figure 3). Under the root directory a `/dev' directory is created under which all
15I/O device directories and files are registered as part of the file system hierarchy.
16
17A RAM based file system draws its management resources from memory. File
18and directory nodes are simply allocated blocks of memory. Data associated with regular
19files is stored in collections of memory blocks. When the system is turned off or restarted
20all memory-based components of the file system are lost.
21
22The base file system serves as a starting point for the mounting of file systems
23that are resident on semi-permanent storage media. Examples of such media include non-
24volatile memory, flash memory and IDE hard disk drives (Figure 3). File systems of other
25types will be mounted onto mount points within the base file system or other file systems
26that are subordinate to the base file system. The framework set up under the base file
27system will allow for these new file system types and the unique data and functionality
28that is required to manage the future file systems.
29
30@section Base File System Mounting
31
32At present, the first file system to be mounted is the `In Memory File System'. It
33is mounted using a standard MOUNT() command in which the mount point is NULL.
34This flags the mount as the first file system to be registered under the operating system
35and appropriate initialization of file system management information is performed (See
36figures 4 and 5). If a different file system type is desired as the base file system,
37alterations must be made to base_fs.c. This routine handles the mount of the base file
38system.
39
40
41@example
42Figure 4
43@end example
44
45
46Once the root of the base file system has been established and it has been
47recorded as the mount point of the base file system, devices are integrated into the base
48file system. For every device that is configured into the system (See ioman.c) a device
49registration process is performed. Device registration produces a unique dev_t handle that
50consists of a major and minor device number. In addition, the configuration information
51for each device contains a text string that represents the fully qualified pathname to that
52device's place in the base file system's hierarchy. A file system node is created for the
53device along the specified registration path.
54
55
56
57@example
58Figure 5
59@end example
60
61
62Note: Other file systems can be mounted but they are mounted onto points (directory
63mount points) in the base file system.
64
65
66@subsection Base File System Node Structure and Function
67
68Each regular file, device, hard link, and directory is represented by a data
69structure called a @code{jnode}. The -jnode- is formally represented by the structure:
70
71@example
72struct IMFS_jnode_tt @{
73  Chain_Node                 Node;             /* for chaining them together */
74  IMFS_jnode_t              *Parent;           /* Parent node */
75  char                       name[NAME_MAX+1]; /* "basename" */
76  mode_t                     st_mode;          /* File mode */
77  nlink_t                    st_nlink;         /* Link count */
78  ino_t                      st_ino;           /* inode */
79
80  uid_t                      st_uid;           /* User ID of owner */
81  gid_t                      st_gid;           /* Group ID of owner */
82
83  time_t                     st_atime;         /* Time of last access */
84  time_t                     st_mtime;         /* Time of last modification */
85  time_t                     st_ctime;         /* Time of last status change */
86  IMFS_jnode_types_t         type;             /* Type of this entry */
87  IMFS_typs_union            info;
88@};
89@end example
90
91The key elements of this structure are listed below together with a brief explanation of
92their role in the file system.
93
94@table @b
95
96@item node
97This element exists simply to allow the entire @code{jnode} structure to be
98included in a chain.
99
100@item parent
101A pointer to another @code{jnode} structure that is the logical parent of the
102node in which it appears. There are circumstances that will produce a null parent
103pointer within a @code{jnode}. This can occur when a hard link is created to a file and
104the file is then removed without removing the hard link.
105
106@item name
107The name of this node within the file system hierarchical tree. Example:
108If the fully qualified pathname to the @code{jnode} was /a/b/c, the -jnode- name field
109would contain the null terminated string "c"
110
111@item st_mode
112The standard Unix access permissions for the file or directory.
113
114@item st_nlink
115The number of hard links to this file. When a @code{jnode} is first created its
116link count is set to 1. A @code{jnode} and its associated resources cannot be deleted
117unless its link count is less than 1.
118
119@item st_ino
120A unique node identification number
121
122@item st_uid
123The user ID of the file's owner
124
125@item st_gid
126The group ID of the file's owner
127
128@item st_atime
129The time of the last access to this file
130
131@item st_mtime
132The time of the last modification of this file
133
134@item st_ctime
135The time of the last status change to the file
136
137@item type
138The indication of node type must be one of the following states:
139
140@itemize @bullet
141@item IMFS_DIRECTORY
142@item IMFS_MEMORY_FILE
143@item IMFS_HARD_LINK
144@item IMFS_SYM_LINK
145@item IMFS_DEVICE
146@end itemize
147
148
149@item info
150This contains a structure that is unique to file type(See IMFS_typs_union in
151imfs.h )
152
153@itemize @bullet
154
155@item IMFS_DIRECTORY
156An in memory file system directory contains a
157dynamic chain structure that records all files and directories that are
158subordinate to the directory node.
159
160@item IMFS_MEMORY_FILE
161Under the in memory file system regular files hold
162data. Data is dynamically allocated to the file in 128 byte chunks of memory.
163The individual chunks of memory are tracked by arrays of pointers that record
164the address of the allocated chunk of memory. Single, double, and triple
165indirection pointers are used to record the locations of all segments of the file.
166These memory-tracking techniques are graphically depicted in figures XXX
167and XXX of appendix A.
168
169@item IMFS_HARD_LINK
170The IMFS file system supports the concept of hard
171links to other nodes in the IMFS file system. These hard links are actual
172pointers to the memory associated with other nodes in the file system. This
173type of link cannot cross-file system boundaries.
174
175@item IMFS_SYM_LINK
176The IMFS file system supports the concept of symbolic
177links to other nodes in any file system. A symbolic link consists of a pointer to
178a character string that represents the pathname to the target node. This type of
179link can cross-file system boundaries.
180
181@item IMFS_DEVICE
182All RTEMS devices now appear as files under the in
183memory file system. On system initialization, all devices are registered as
184nodes under the file system.
185
186@end itemize
187
188@end table
189
190
191@subsection Node removal constraints for the base files system
192
193@itemize @bullet
194
195@item If a node is a directory with children it cannot be removed.
196@item The root node of the base file system or the mounted file system
197cannot be removed.
198
199@item A node that is a directory that is acting as the mount point of a file
200system cannot be removed.
201
202@item Prior to node removal, decrement the node's link count by one. The
203link count must be less than one to allow for removal of the node.
204
205@end itemize
206
207@subsection Housekeeping
208
209@itemize @bullet
210
211@item If the global variable rtems_filesystem_current refers to the node that
212we are trying to remove, the node_access element of this structure
213must be set to NULL to invalidate it.
214
215@item If the node was of IMFS_MEMORY_FILE type, free the memory
216associated with the memory file before freeing the node. Use the
217IMFS_memfile_remove() function.
218
219@end itemize
220
221
222@section IMFS
223
224@subsection OPS Table Functions for the In Memory File System (IMFS)
225
226@example
227OPS Table Functions             File                    Routine Name
228
229Evalpath Imfs_eval.c IMFS_eval_path()
230Evalformake Imfs_eval.c IMFS_evaluate_for_make()
231Link Imfs_link.c IMFS_link()
232Unlink Imfs_unlink.c IMFS_unlink()
233Node_type Imfs_ntype.c IMFS_node_type()
234Mknod Imfs_mknod.c IMFS_mknod()
235Rmnod Imfs_rmnod.c IMFS_rmnod()
236Chown Imfs_chown.c IMFS_chown()
237Freenod Imfs_free.c IMFS_freenodinfo()
238Mount Imfs_mount.c IMFS_mount()
239Fsmount_me Imfs_init.c IMFS_initialize()
240Unmount Imfs_unmount.c IMFS_unmount()
241Fsunmount_me Imfs_init.c IMFS_fsunmount()
242Utime Imfs_utime.c IMFS_utime()
243Eval_link Imfs_eval.c IMFS_evaluate_link()
244Symlink Imfs_symlink.c IMFS_symlink()
245Readlink Imfs_readlink.c IMFS_readlink()
246@end example
247
248
249
250@subsection Handler Functions for Regular Files of In Memory File System
251
252@example
253Handler Function            File            Routine Name
254
255Open Memfile.c Memfile_open()
256Close Memfile.c Memfile_close()
257Read Memfile.c Memfile_read()
258Write Memfile.c Memfile_write()
259Ioctl Memfile.c Memfile_ioctl()
260Lseek Memfile.c Memfile_lseek()
261Fstat Imfs_stat.c IMFS_stat()
262Fchmod Imfs_fchmod.c IMFS_fchmod()
263Ftruncate Memfile.c Memfile_ftruncate()
264Fpathconf NA NULL
265Fsync NA NULL
266Fdatasync NA NULL
267@end example
268
269
270@subsection Handler Functions for Directories of In Memory File System
271
272@example
273Handler Function             File                Routine Name
274
275Open imfs_directory.c Imfs_dir_open()
276Close imfs_directory.c Imfs_dir_close()
277Read imfs_directory.c Imfs_dir_read()
278Write imfs_directory.c NULL
279Ioctl imfs_directory.c NULL
280Lseek imfs_directory.c Imfs_dir_lseek()
281Fstat imfs_directory.c Imfs_dir_fstat()
282Fchmod imfs_fchmod.c IMFS_fchmod()
283Ftruncate NA NULL
284Fpathconf NA NULL
285Fsync NA NULL
286Fdatasync NA NULL
287@end example
288
289
290
291@subsection Handler Functions for Devices of In Memory File System
292
293@example
294Handler Function          File                  Routine Name
295
296Open deviceio.c Device_open()
297Close deviceio.c Device_close()
298Read deviceio.c Device_read()
299Write deviceio.c Device_write()
300Ioctl deviceio.c Device_ioctl()
301Lseek deviceio.c Device_lseek()
302Fstat imfs_stat.c IMFS_stat()
303Fchmod imfs_fchmod.c IMFS_fchmod()
304Ftruncate NA NULL
305Fpathconf NA NULL
306Fsync NA NULL
307Fdatasync NA NULL
308@end example
309
Note: See TracBrowser for help on using the repository browser.