pC/TFS



Often, a possibility of the storage of miscellaneous data and information is required in smaller appliances. A small File-System was exactly the correct solution there. Only, professional solutions for appliances with low storage often are to big. MS-DOS compatible systems come fast on 150kB codes already once there. Only the data once simply so any where controls casts off... ?

The here introduced Tiny-File-System is based on hierarchical, lists double-interlinked, through what no limitation is available in number of the files within a table or file size (max 4GB). Each file can produce on that occasion in fragmented or none-fragmented form, administers and is deleted.
This file-system handles all names of directories/files as a STRING, so can used special characters in the names. Not to use are two points in series and the slashes.

reserved names-elements:

.. - one directory back
/  - on the beginning of the Path: for from ROOT
/  - in middle of the Path: as separation for directory/file-names

The whole file-system works case-sensitive !
Parallel battery-buffered sRAM, EEPROM, FRAM, MRAM or 256byte-page NOR-flash as hardware are tested and port's produces. For critical applications, one variation each with Roll-Back-Buffering arrived for a sure letter however, which leads to the duplication of the writing accesses.
The application of other Flash-Memory became on reason of the sector size of >=64kB, the necessary buffering of a such against the update, as well as the long programming time of a whole side intended not. Furthermore, a safeguarding would be to be timewise hardly represented like by an above-mentioned Roll-Back-mechanism.
A use of modern data Flashes with PAGE sizes of 128byte .. 64kbytes can be made possible at any time by means of a "ReadPageToBuffer-UpdateBuffer-ErasePage-WriteBufferToPage" mechanism, however the TinyFileSystem does not examine for optimized (summarized) PageWrite.
When using NOR-Flash, however, it is important to remember that 10.000 .. 100.000 cycles is a very short life with frequent updates in the same page.
In addition, the TinyFileSystem do not respect hot spots (high-update files).


memory consumption of the pC/TFS V2.38b:

ROM: approximately 14 kBytes on a 32bit CPU
         approximately 22 kBytes on a 8bit CPU
RAM: approximately 24 bytes global + 16..24 bytes per user + 9 bytes * TFS_HANDLES
         plus approximately 100 bytes stack


Ports:

sRAM

battery-buffered IS62WV51216, EM7644SU16                            

FRAM

FM22L16

MRAM

MR4A16

NOR

AT91SAM7SE512 / ATSAM3SD8B

NOR

SAMD21

plus some special processors and their NOR or EEPROM based internal memory



But no mechanisms of the File-sharing are deposited. So a file can be opened simultaneously from many Users to reading but only from one User to writing.
As directory and File-Attribute, Read-Only and Hidden(System) to the disposal, stand. Hidden entries are not declared on that occasion with a TFS_GetFirst.. or TFS_GetNext.., can be grabbed directly, however.
The entire File-System does 4 GBytes on a linear storage area of maximum. The utilization of a MMU is included possible without further.

The optional functions TFS_Defrag to the defragmentation of the drive and TFS_Repair to repairing defect hierarchical concatenations are ready.
Since V2.00 can used links (to files or directories). Since V2.01 are some parameters of functions changed.


pCTFS_238b.zip
download pC/TFS 2.38b (as ZIP)


Releases:

1.00a

first alpa-release

1.20d

some little bug-fixes in TFS_GetFirstEntry() und TFS_GetNextEntry() and two additional fileattributes. Directories havn't attribs. Optimising code.

2.00a

alpha-release with links. Tripple-source for Keil, gcc and Microsoft-C

2.01b

Changed return-parameter of TFS_OpenFile(), TFS_FileRead() and TFS_FileWrite(). Implementation of TFS_GetErrNo(). Implementation of a additional LINUX-Host port's to simulate the TFS in RAM of a PC.

2.10a

handling of users changed - every Task can only be one User, but every User can open TFS_HANDLES files. Adaption of API-Calls. Function of TFS_ExpandFile() changed, new function TFS_ResizeFile() added. For a FileSystem smaller than 64kByte TFSLONG for all length-parameter implemented to minimize the API- and Memory- Overhead. Now a file can opened simultaneously from many Users to reading - but only one User can open a file to writing. If a file opened (more than once) to reading, an other User can't open this file to writing - if a file from one User opened to writing, no other User can open this file for reading or writing.

2.11b

TFS_GetFileSize(), TFS_GetFileAttrib() and TFS_TellFile() added. Little bugfix in internal function TFSChange_Entry().

2.20b

complete code-optimizing.

2.21a

TFS_GetFreeSize() and TFS_MoveFile() added. Bugfix in TFS_RenameFile() and TFS_RenameDir().

2.23b

TFS_WriteFileE() added. SpeedUp in internal function TFSChange_Entry().

2.30d

complete update to U08..U32 types. Typechanges from HANDLE to TFS_HANDLE, TFSLONG to TFS_LONG and ATTR to TFS_ATTR. Small correction in TFS_SeekFile(). Better portability for RTOS-less use implemented. Clean-Up in comments and some code-lines.

2.32a

TFS_GetFirstEntry() and TFS_GetNextEntry() renamed to TFS_GetFirstName() and TFS_GetNextName(). TFS_GetFirst() and TFS_GetNext() added, this functions returns all informations about an entry (DIR/FILE) in the given structure. TFS_GetRev() added.

2.34b

TFS_BecomeUserSubROOT(), TFS_GetCurrentPath(), TFS_ChangeDirTemp() and TFS_BackDirTemp() added.

2.35a

change to task-ID on use of pC/OS for unique identify of running task, TFS_SetEOF() added.

2.36a

correct user-check for GCC & unknown user.

2.37b

TFS_GetEntry added and small correction in internal function TFSChange_Entry.

2.38b

TFS_PATHNAME central for all strings added, internal functions as static as far as possible



Services of the pC/TFS version 2.38b (abbreviation)
This here presented function overview only serves as short overview.
For detailed information, you please look in Reference-Manual about pC/TFS.


TFS-Control:

Description

TFS_Init

Initialization of the File-System

TFS_GetRev

It returns a pointer on TFS revision

TFS_Flush

save the TFS as image into a LINUX-file

TFS_Format

Format the drive



User:

Description

TFS_BecomeUser

As User announce

TFS_BecomeUserSubROOT

As User in a subdirectory as user-ROOT announce

TFS_CloseUser

As User cancel

TFS_GetFreeSize

Return the brutto free-memory of the drive



Directories:

Description

TFS_CreateDir

Create a directory

TFS_RemoveDir

Remove a directory

TFS_RenameDir

Rename a directory

TFS_ChangeDir

Change current path

TFS_ChangeDirTemp

Change current path temorary

TFS_BackDirTemp

returns from temporary path

TFS_GetCurrentDir

Return the name of current directory

TFS_GetCurrentPath

Return the complete current path from (user-)ROOT



Files:

Description

TFS_CreateFile

Create a file

TFS_RemoveFile

Remove a file

TFS_RenameFile

Rename a file

TFS_MoveFile

Move a file

TFS_AttribFile

Change the attributes of a file

TFS_GetFileAttrib

It returns the attributes of a file

TFS_ResizeFile

Resize a file

TFS_GetFileSize

It returns the size of a file

TFS_OpenFile

Open a file in "mode"

TFS_CloseFile

Close the opened file

TFS_SeekFile

Place the pointer in opened file absolutely

TFS_TellFile

It returns the pointer in opened file

TFS_ExpandFile

Expand the size of opened file

TFS_SetEOF

Set EndOfFile in opened file to actual R/W-pointer

TFS_ReadFile

Read data from opened file

TFS_WriteFile

Write data into opened file

TFS_WriteFileE

Write data into opened file, expand this file if its needed

TFS_GetErrNo

read the error-code from Open, Read, Write ...



Links:

Description

TFS_CreateLink

Create a Link to a directory or file

TFS_RemoveLink

Remove a Link

TFS_RenameLink

Rename a Link

TFS_ReadLink

It returns the name of the linked directory or file



Entries:

Description

TFS_GetFirstName

It returns the name of first entry in current directory

TFS_GetNextName

It returns the name of next entry in current directory

TFS_GetFirst

It returns all infos of first entry in current directory into a struct

TFS_GetNext

It returns all infos of next entry in current directory into a struct

TFS_GetEntry

It returns all infos of the given entry (dir/file/link) into a struct



Optional:

Description

TFS_Defrag

Defragment the drive

TFS_Repair

Repair the hierarchical pointer-system



Error-Codes:

Name

Decimal_Value

TFS_NO_ERR

0

TFS_USR_OVF

200

TFS_DBL_USER

201

TFS_NO_USER

202

TFS_SUB_USER

203

TFS_NAME_EXIST

210

TFS_NOT_EXIST

211

TFS_PATH_ERR

212

TFS_TMP_DIR

213

TFS_NO_FILE

214

TFS_FILE_RO

215

TFS_FILE_WO

216

TFS_FILE_EOF

217

TFS_NOT_EMPTY

218

TFS_FILE_OPEN

219

TFS_NO_DATA

220

TFS_WRONG_PTR

221

TFS_LINKED

230

TFS_MAX_LINK

231

TFS_LINK_ERR

232

TFS_NO_LINK

233

TFS_MEM_ERR

250

TFS_MEM_OVF

251

TFS_WR_PTR

252

TFS_WRITE_ERR

253

TFS_INVALID

254