Basic IO module
Feature API » Internals of Feature API

## Functions

TSS2_RC | ifapi_io_check_file_writeable (const char *file)
TSS2_RC | ifapi_io_dirfiles (const char *dirname, char ***files, size_t *numfiles)
TSS2_RC | ifapi_io_dirfiles_all (const char *searchPath, char ***pathlist, size_t *numPaths)
bool | ifapi_io_path_exists (const char *path)
TSS2_RC | ifapi_io_poll (IFAPI_IO *io)
TSS2_RC | ifapi_io_poll_handles (IFAPI_IO *io, FAPI_POLL_HANDLE **handles, size_t *num_handles)
TSS2_RC | ifapi_io_read_async (struct IFAPI_IO *io, const char *filename)
TSS2_RC | ifapi_io_read_finish (struct IFAPI_IO *io, uint8_t **buffer, size_t *length)
TSS2_RC | ifapi_io_remove_file (const char *file)
TSS2_RC | ifapi_io_write_async (struct IFAPI_IO *io, const char *filename, const uint8_t *buffer, size_t length)
TSS2_RC | ifapi_io_write_finish (struct IFAPI_IO *io)

## Detailed Description

Provides internal basic IO functions for policy and key store module.

## Function Documentation

## ifapi_io_check_file_writeable()

TSS2_RC ifapi_io_check_file_writeable | ( | const char * | file | ) |

Check whether a file is writeable.

Parameters

  [in] | file | The name of the fileto be checked.

Return values

  TSS2_RC_SUCCESS | if the directories existed or were successfully created
  TSS2_FAPI_RC_IO_ERROR | if an I/O error occurred

## ifapi_io_dirfiles()

TSS2_RC ifapi_io_dirfiles | ( | const char * | dirname,
|  | char *** | files,
|  | size_t * | numfiles )

Enumerate the list of files in a directory.

Enumerage the regular files (no directories, symlinks etc) from a given directory.

Parameters

  [in] | dirname | The directory to list files from.
  [out] | files | The list of file names.
  [out] | numfiles | The size of files.

Return values

  TSS2_RC_SUCCESS | if the directories were successfully removed
  TSS2_FAPI_RC_IO_ERROR | if an I/O error occurred
  TSS2_FAPI_RC_MEMORY | if memory could not be allocated to hold the read data.
  TSS2_FAPI_RC_BAD_REFERENCE | a invalid null pointer is passed.

## ifapi_io_dirfiles_all()

TSS2_RC ifapi_io_dirfiles_all | ( | const char * | searchPath,
|  | char *** | pathlist,
|  | size_t * | numPaths )

Recursive enumerate the list of files in a directory.

Enumerage the regular files (no directories, symlinks etc) from a given directory.

Parameters

  [in] | searchPath | The directory to list files from.
  [out] | pathlist | The list of file names.
  [out] | numPaths | The size of files.

Return values

  TSS2_RC_SUCCESS | if the directories were successfully removed
  TSS2_FAPI_RC_IO_ERROR | if an I/O error occurred
  TSS2_FAPI_RC_MEMORY | if memory could not be allocated to hold the read data.

## ifapi_io_path_exists()

bool ifapi_io_path_exists | ( | const char * | path | ) |

Determine whether a path exists.

Parameters

  [in] | path | The absolute path of the file.

Return values

  true | The file exists.
  false | The file does not exist.

## ifapi_io_poll()

TSS2_RC ifapi_io_poll | ( | IFAPI_IO * | io | ) |

Wait for file I/O to be ready.

If FAPI state automata are in a file I/O state it will be waited for an event on a file descriptor.

Parameters

  [in] | io | The input/output context being used for file I/O.

Return values

  TSS2_RC_SUCCESS | After the end of the wait.
  TSS2_FAPI_RC_IO_ERROR | if the poll function returns an error.
  TSS2_FAPI_RC_BAD_REFERENCE | a invalid null pointer is passed.

## ifapi_io_poll_handles()

TSS2_RC ifapi_io_poll_handles | ( | IFAPI_IO * | io,
|  | FAPI_POLL_HANDLE ** | handles,
|  | size_t * | num_handles )

Get a list of poll handles.

Parameters

  [in] | io | The input/output context being used for file I/O.
  [out] | handles | The array with the poll handles.
  [out] | num_handles | The number of poll handles.

Return values

  TSS2_RC_SUCCESS | on success.
  TSS2_FAPI_RC_NO_HANDLE | In no poll events are stored in IO context.
  TSS2_FAPI_RC_MEMORY | If the output data cannot be allocated.
  TSS2_FAPI_RC_BAD_REFERENCE | a invalid null pointer is passed.

## ifapi_io_read_async()

TSS2_RC ifapi_io_read_async | ( | struct IFAPI_IO * | io,
|  | const char * | filename )

Start reading a file's complete content into memory in an asynchronous way.

Parameters

  [in,out] | io | The input/output context being used for file I/O.
  [in] | filename | The name of the file to be read into memory.

Return values

  TSS2_RC_SUCCESS | if the function call was a success.
  TSS2_FAPI_RC_IO_ERROR | if an I/O error was encountered; such as the file was not found.
  TSS2_FAPI_RC_MEMORY | if memory could not be allocated to hold the read data.

## ifapi_io_read_finish()

TSS2_RC ifapi_io_read_finish | ( | struct IFAPI_IO * | io,
|  | uint8_t ** | buffer,
|  | size_t * | length )

Finish reading a file's complete content into memory in an asynchronous way.

This function needs to be called repeatedly until it does not return TSS2_FAPI_RC_TRY_AGAIN.

Parameters

  [in,out] | io | The input/output context being used for file I/O.
  [out] | buffer | The data that was read from file. (callee-allocated; use free())
  [out] | length | The length of the data that was read from file.

Return values

  TSS2_RC_SUCCESS | if the function call was a success.
  TSS2_FAPI_RC_IO_ERROR | if an I/O error was encountered; such as the file was not found.
  TSS2_FAPI_RC_TRY_AGAIN | if the asynchronous operation is not yet complete. Call this function again later.

## ifapi_io_remove_file()

TSS2_RC ifapi_io_remove_file | ( | const char * | file | ) |

Remove a file.

Parameters

  [in] | file | The absolute path of the file to be removed.

Return values

  TSS2_RC_SUCCESS | If the file was successfully removed
  TSS2_FAPI_RC_IO_ERROR | If the file could not be removed.

## ifapi_io_write_async()

TSS2_RC ifapi_io_write_async | ( | struct IFAPI_IO * | io,
|  | const char * | filename,
|  | const uint8_t * | buffer,
|  | size_t | length )

Start writing a buffer into a file in an asynchronous way.

Parameters

  [in,out] | io | The input/output context being used for file I/O.
  [in] | filename | The name of the file to be read into memory.
  [in] | buffer | The buffer to be written.
  [in] | length | The number of bytes to be written.

Return values

  TSS2_RC_SUCCESS | if the function call was a success.
  TSS2_FAPI_RC_IO_ERROR | if an I/O error was encountered; such as the file was not found.
  TSS2_FAPI_RC_MEMORY | if memory could not be allocated to hold the read data.

## ifapi_io_write_finish()

TSS2_RC ifapi_io_write_finish | ( | struct IFAPI_IO * | io | ) |

Finish writing a buffer into a file in an asynchronous way.

This function needs to be called repeatedly until it does not return TSS2_FAPI_RC_TRY_AGAIN.

Parameters

  [in,out] | io | The input/output context being used for file I/O.

Return values

  TSS2_RC_SUCCESS | if the function call was a success.
  TSS2_FAPI_RC_IO_ERROR | if an I/O error was encountered; such as the file was not found.
  TSS2_FAPI_RC_TRY_AGAIN | if the asynchronous operation is not yet complete. Call this function again later.