IMFS TAR load.
janovetz at uiuc.edu
Tue Jan 30 15:15:23 UTC 2001
I believe several people are using tar files to construct the
initial filesystem on their RTEMS devices. Joel and I have added
a new call: rtems_tarfs_load() to the IMFS to mount a tar file so
that its storage may be used rather than copying the data to new
memory file storage. Here is a brief summary. It would be nice
if some people could try this out and give me feedback.
int rtems_tarfs_load(char *mountpoint,
unsigned char *tar_image,
unsigned long tar_size)
[mountpoint] is a string which describes the path at which the
new "tarfs" will be mounted. Tarfs is in quotes because
it is not really a filesystem, but sort of an extension
to the IMFS.
[tar_imag] is a pointer to the TAR image in ROM or RAM. The TAR image
is never modified, so no writes will be made to this memory.
[tar_size] is the size of the TAR image. This is needed because
(to my knowledge), there is no other way to determine the
end of a TAR file. (or at least discriminate between the
end of the file and an invalid TAR header)
rtems_tarfs_load first evaluates the path "mountpoint" and makes sure
it is valid. It does not create a directory for the mount. You must
do this. It then goes through the TAR file and generates IMFS nodes
1. Directories are created as standard IMFS directories.
2. Files are created in two ways:
a. If write permission is granted to the file in the TAR, then
a new file is created using creat() and written to. This file
is then a standard IMFS file and contains a _copy_ of the data
in the TAR.
b. If write permission is not granted, then a new node is created
as a "linear file" node (new to IMFS). The pointer to the data
is set to point to the data in the TAR file. Of course, the
file is created with read-only permission.
This new "linear file" shares most of the same handlers as the "memory file"
originally in IMFS. The differences are handled in the function calls
themselves. Notably, memfile_read() performs reads in a much more
simplistic manner because files are not fragmented as they are in IMFS
chmod() has a little different functionality, though. If the file
is a "linear file" -- that is, it points to the TAR file, then it
is read-only. If you chmod() it to be read/write, then the call
changes the node from a "linear file" to a "memory file" and copies
Oh, and in case you were wondering, "rtems_tarfs_load("/", ...)"
does, indeed, work. TARFS is not really a filesystem. The call
just loads the TAR file into the filesystem.
More information about the users