IMFS question
Joel Sherrill
joel.sherrill at OARcorp.com
Fri May 10 18:00:04 UTC 2002
Glen M Cornell wrote:
>
> Chris Johns wrote:
>
> > Glen M Cornell wrote:
> >
> >> Is there a utility or procedure to convert a directory of files into
> >> an in-memory file system?
> >>
> >
> > What I have done with a m68k target is make a tar file (not
> > compressed) of the files to serve. Then run:
> >
> >
> > m68k-rtems-ld -r -o pages-tar.o -b binary pages.tar
> >
> very cool. I've been converting files to c code, then compiling - which
> could take a long time. I use the following bourne shell function:
This is a good alternative and I have used it for other static
data in the past.
> convert_file() {
> FILE=$1
> NAME=$2
>
> cat - <<EOF
> /*
> * File data for ${FILE}
> */
> static unsigned char file_${NAME}[] = {
> EOF
>
> # Because a file may not be a text file, we can't place the
> # code in a string of bytes as characters. Instead, we will
> # use od to print out the hexadecimal values of each character
> # as an element in an array of unsigned bytes:
> cat $FILE | /bin/od -v -t xC | cut -c9- |
> sed -e '/^[ ]*$/d' -e 's/\([0-9a-f][0-9a-f]\)/0x\1,/g'
>
> echo "};"
> echo ""
> }
>
> to essentially do the same thing as the ld trick.
>
> However, what I'm looking to do is create the file system at compile
> time to avoid any startup-time penalties associated with creating the
> file system and creating/copying the directories and files.
It doesn't copy the files, it leaves them in the tar image until
modified. If they are read-only, they will never leave the
static image.
--
Joel Sherrill, Ph.D. Director of Research & Development
joel at OARcorp.com On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35805
Support Available (256) 722-9985
More information about the users
mailing list