Embedded Systems December 2000 Vol13_13

Issue link:

Contents of this Issue


Page 77 of 197

available for use by TFS. If the -d option is specified, then list the memolJl that is available for that device only. Since there is per-file overhead, the value returned he re is the amount of data space avail- able if one additional file is tored in TFS. If additional files are to be stored, the user must take into account the TFS overhead • info lfi lename} Ivarname} Load the shell variable 'varname' with the information fi eld stored with the fil e ' fil ename ' • init Initialize the fil e system (remove all fil es and erase fl ash) • Id Load an executable COFF, ELF, or a.o ut file from flash to RAM • Idv Verify that the executable COFF, ELF, or a.out file in flash space matches what was copied to RAM space • log [Ionloffllm essage}] Turn on or off (or determine the current state of) the change-log facili ty. With no args, the current state is re turned. If "on or off' is specified, then it must be fo llowed by a message string that is append- edto the change log as an infonna- tion fi eld to log the reason for the change in the logging state • Is [filter] [filter ... ] List the current set of files in the file system. The -m option can be used to throttle the output of the Ii tin g. There are four different lev- els of verbosity for Is: • Ivl 0: 0 verbosity, short list of all active fil es • Ivl 1: Display "hidden" fil es (beginning with '.') in short format • Ivl 2: Display active files in long format • Ivl 3: Display active and deleted fil es in long format Specifying the filter can limit tile number of fi les listed: • *filter indicates a suffix match • filter* indicates a prefi x match • fil ter indicates a full filename match • rWl lfilename} Execute tile specified file based on tile creation attributes (see below) • rm lfi lter} [filter ... ] Remove the specified fil e(s). See the previous discussion on "Is" for de tails on the filter. Note that the file is not actually removed; it is simply marked as removed • size lfilename} Ivarname} Load the shell variable 'varname' with the size of the file ' filename ' • stat Display file system statistics • Trace IIvl} Turn on one of three different lev- els of trace so that as an application uses the TFS API, output is gener- ated (printed to console) indicat- ing what is going on TheTFS API This section provides a brief in troduc- Lion to tile API that TFS presents to the application code with which it in terfaces. Comple te details are omit- ted at this point, but the reader should get a good feel for the capabili ties pro- vided. • int tfsadd (char *name, char *info, char *flags, uchar *src, int size) Add a file to th e fi Ie s to rage space • int tfsinit(void ) Initialize tile fl ash used by TFS • int tfsc1ose (in t tfd, char *info) Similar to standard c1ose() on a TFS file • int tfsctrl (in t rqst, long argl , lo ng arg2) Pe rform vario us control fun cLions on TFS • int tfsgetIine (in t tfd, char *buffer, int max) Retrieve next line of an opened ASCII fil e in TFS • int tfsipmod(char *name, char *buffe r, int offset, int ize) Do an in-place-modification on a TFS file • struct tfshdr *tfsnext(struct tfshdr *tfp) 76 DECEMBER 2000 Embedded Systems Programming Step tllrough the list of file headers in TFS. • in t tfsopen(char *fil ename, long fl agmode, char *buffe r) Similar to standard open () on a TFS file • int tfsread(int tfd , char *buffer, int size) Similar to standard read() on a TFS fil e • int tfsrWl (cha r *al-gli st[], int verbose) Run some executable fil e in TFS • in t tfsseek(int tfd, int offse t, int whence) Similar to standard seek() on a TFS fil e • in t tfseof(int Lfd ) Return EOF state of an o pened fil e • int tfsfstat(char *fil ename, struct tfshdr ':'hdr) Return the status of a fil e (1 if pre- sent, else -1 ) and populate a local stru cture with the current fil e header • struct tfshdr *tfsstat (char *fiI e- name) Re turn the status of a file (pointer to the fil e's header) in TFS • int tfsunlink (char *fiI ename) Remove a file from TFS • int tfswrite (int tfd , char *buffer, int size) Similar to standard write() on a TFS fil e Implementation details The following details assume a basic system: CPU, 10, RAM, and one flash device. Note that TFS can span aero s several different devices (where each device is considered a directory) and the devices need not be in contiguous memory space. Fo r this discussion we will assume just one flash devi ce. The system flash memory has three defined sections: fl ash space used by tile monitor code itself, the flash space used to store the fil es, and space dedi- cated to interruptible defragm e nta- Lion. The fl ash that is used by TFS fO I file storage begins on a sector bound- ary and the "spare" sector is located immediate ly after the last sector in -

Articles in this issue

Archives of this issue

view archives of EETimes - Embedded Systems December 2000 Vol13_13