| RTOS_MSPM0 1.1 ECE445M starter code

Functions
eFile.h File Reference

high-level file system More...

Go to the source code of this file.

## Functions
int | eFile_Init (void)
| Activate the file system, without formating. More...
int | eFile_Format (void)
| Format the disk. More...
int | eFile_Mount (void)
| Mount the disk. More...
int | eFile_Create (const char name[])
| Create a new file. More...
int | eFile_WOpen (const char name[])
| Open an existing file for writing. More...
int | eFile_Write (const char data)
| Write one byte. More...
int | eFile_WriteString (const char *pt)
| Write string. More...
int | eFile_WriteUDec (uint32_t n)
int | eFile_WriteSDec (int32_t num)
int | eFile_WriteSFix2 (int32_t n)
int | eFile_WriteUFix2 (uint32_t num)
int | eFile_WClose (void)
| Close the file that was being written. More...
int | eFile_ROpen (const char name[])
| Open an existing file for reading. More...
int | eFile_ReadNext (char *pt)
| Retreive data from open file. More...
uint32_t | eFileReadNextWord (uint32_t *pt)
| Retreive data from open file. More...
int | eFile_RClose (void)
| Close the file that was being read. More...
int | eFile_Delete (const char name[])
| delete this file More...
int | eFile_DOpen (const char name[])
int | eFile_DirNext (char *name[], unsigned long *size)
int | eFile_DClose (void)
int | eFile_Unmount (void)
| Unmount the disk. More...

## Detailed Description

high-level file system

This file system sits on top of eDisk.

Version
  V1.0

Author
  Valvano

Copyright
  Copyright 2026 by Jonathan W. Valvano, valva.nosp@m.no@m.nosp@m.ail.u.nosp@m.texa.nosp@m.s.edu,

Warning
  AS-IS

Note
  For more information see http://users.ece.utexas.edu/~valvano/

Date
  Dec 30, 2025

## Function Documentation

## ◆ eFile_Create()

int eFile_Create | ( | const char | name[] | ) |

Create a new file.

Create a new, empty file with one allocated block

Parameters

  name | file name is an ASCII string up to seven characters

Returns
  0 if successful and 1 on failure (e.g., already exists)

## ◆ eFile_DClose()

int eFile_DClose | ( | void |  | ) |

Close the directory

Parameters

  none |

Returns
  0 if successful and 1 on failure (e.g., wasn't open)

## ◆ eFile_Delete()

int eFile_Delete | ( | const char | name[] | ) |

delete this file

Delete the file with this name, recover blocks so they can be used by another file

Parameters

  name | file name is an ASCII string up to seven characters

Returns
  0 if successful and 1 on failure (e.g., file doesn't exist)

## ◆ eFile_DirNext()

int eFile_DirNext | ( | char * | name[],
|  | unsigned long * | size
| ) |  |

Retreive directory entry from open directory

Parameters

  pointers | to return file name and size by reference

Returns
  0 if successful and 1 on failure (e.g., end of directory)

## ◆ eFile_DOpen()

int eFile_DOpen | ( | const char | name[] | ) |

Open a (sub)directory, read into RAM

Parameters

  directory | name is an ASCII string up to seven characters if subdirectories are supported (optional, empty sring for root directory)

Returns
  0 if successful and 1 on failure (e.g., trouble reading from flash)

## ◆ eFile_Format()

int eFile_Format | ( | void |  | ) |

Format the disk.

Erase all files, create blank directory, initialize free space manager

Parameters

  none |

Returns
  0 if successful and 1 on failure (e.g., trouble writing to flash)

## ◆ eFile_Init()

int eFile_Init | ( | void |  | ) |

Activate the file system, without formating.

This function must be called first, before calling any of the other eFile functions

Parameters

  none |

Returns
  0 if successful and 1 on failure (already initialized)

## ◆ eFile_Mount()

int eFile_Mount | ( | void |  | ) |

Mount the disk.

Mount disk and load file system metadata information

Parameters

  none |

Returns
  0 if successful and 1 on failure (e.g., already mounted)

## ◆ eFile_RClose()

int eFile_RClose | ( | void |  | ) |

Close the file that was being read.

Close the file, leave disk in a state power can be removed.

Parameters

  none |

Returns
  0 if successful and 1 on failure (e.g., wasn't open)

## ◆ eFile_ReadNext()

int eFile_ReadNext | ( | char * | pt | ) |

Retreive data from open file.

Read one byte from disk into RAM

Parameters

  pt | call by reference pointer to place to save data

Returns
  0 if successful and 1 on failure (e.g., trouble reading from flash)

## ◆ eFile_ROpen()

int eFile_ROpen | ( | const char | name[] | ) |

Open an existing file for reading.

Open the file for reading, read first block into RAM

Parameters

  name | file name is an ASCII string up to seven characters

Returns
  0 if successful and 1 on failure (e.g., trouble reading from flash)

## ◆ eFile_Unmount()

int eFile_Unmount | ( | void |  | ) |

Unmount the disk.

Unmount and deactivate the file system.

Parameters

  none |

Returns
  0 if successful and 1 on failure (e.g., trouble writing to flash)

## ◆ eFile_WClose()

int eFile_WClose | ( | void |  | ) |

Close the file that was being written.

Close the file, leave disk in a state power can be removed. This function will flush all RAM buffers to the disk.

Parameters

  none |

Returns
  0 if successful and 1 on failure (e.g., trouble writing to flash)

## ◆ eFile_WOpen()

int eFile_WOpen | ( | const char | name[] | ) |

Open an existing file for writing.

Open the file for writing, read into RAM last block

Parameters

  name | file name is an ASCII string up to seven characters

Returns
  0 if successful and 1 on failure (e.g., trouble reading from flash)

## ◆ eFile_Write()

int eFile_Write | ( | const char | data | ) |

Write one byte.

Save one byte at end of the open file

Parameters

  data | byte to be saved on the disk

Returns
  0 if successful and 1 on failure (e.g., trouble writing to flash)

## ◆ eFile_WriteString()

int eFile_WriteString | ( | const char * | pt | ) |

Write string.

Save string at end of the open file

Parameters

  pt | pointer to string to be saved

Returns
  0 if successful and 1 on failure (e.g., trouble writing to flash)

## ◆ eFileReadNextWord()

uint32_t eFileReadNextWord | ( | uint32_t * | pt | ) |

Retreive data from open file.

Read one 32-bit word from disk into RAM, little endian

Parameters

  pt | call by reference pointer to place to save data

Returns
  0 if successful and 1 on failure (e.g., trouble reading from flash)