<< Previous | Next >>

fs_init (FS2)

int fs_init( long reserveblocks, int num_blocks );

Description

Initialize the filesystem. The static structure _fs contains information that defines the number and parameters associated with each extent or "partition." This function must be called before any of the other functions in this library, except for fs_setup(), fs_get_*_lx() and fs_get_lx_size().

Pre-main initialization will create up to 3 devices:

  • The second flash device (if available on the board)

  • Battery-backed SRAM (if FS2_RAM_RESERVE defined)

  • The first (program) flash (if both XMEM_RESERVE_SIZE and FS2_USE_PROGRAM_FLASH defined)

The LX numbers of the default devices can be obtained using the fs_get_flash_lx(), fs_get_ram_lx() and fs_get_other_lx() calls. If none of these devices can be set up successfully, fs_init() will return ENOSPC when called.

This function performs complete consistency checks and, if necessary, fixups for each LX. It may take up to several seconds to run. It should only be called once at application initialization time.

NOTE When using µC/OS-II, fs_init() must be called before OSInit().

Parameters

reserveblocks
Must be zero. Retained for backward compatibility.

num_blocks
Ignored (backward compatibility).

Return value

 0: Success.
!0: Failure.

ERRNO values

EINVAL - the reserveblocks parameter was non-zero.
EIO - I/O error. This indicates a hardware problem.
ENOMEM - Insufficient memory for required buffers.
ENOSPC - No valid extents obtained e.g. there is no recognized flash or RAM memory device available.

Library

fs2.lib

See also

fs_setup (FS2), fs_get_flash_lx (FS2)


Dynamic C Functions << Previous | Next >> rabbit.com