RTEMS: File System Node Handler

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
Files | Data Structures | Typedefs | Functions | Variables
File System Node Handler
IO Library

File system node handler. More...

## Files
file | default_kqfilter.c
| Default Kernel Event Filter Handler.
file | default_mmap.c
| Default MMAP Handler.
file | default_poll.c
| Default Poll Handler.
file | default_readv.c
| Default Read IO Vector Handler.
file | default_writev.c
| Default Read IO Vector Handler.

## Data Structures
struct | _rtems_filesystem_file_handlers_r
| File system node operations table. More...

## Typedefs
typedef int(* | rtems_filesystem_open_t) (rtems_libio_t *iop, const char *path, int oflag, mode_t mode)
| Opens a node.
typedef int(* | rtems_filesystem_close_t) (rtems_libio_t *iop)
| Closes a node.
typedef ssize_t(* | rtems_filesystem_read_t) (rtems_libio_t *iop, void *buffer, size_t count)
| Reads from a node.
typedef ssize_t(* | rtems_filesystem_readv_t) (rtems_libio_t *iop, const struct iovec *iov, int iovcnt, ssize_t total)
| Reads an IO vector from a node.
typedef ssize_t(* | rtems_filesystem_write_t) (rtems_libio_t *iop, const void *buffer, size_t count)
| Writes to a node.
typedef ssize_t(* | rtems_filesystem_writev_t) (rtems_libio_t *iop, const struct iovec *iov, int iovcnt, ssize_t total)
| Writes an IO vector to a node.
typedef int(* | rtems_filesystem_ioctl_t) (rtems_libio_t *iop, ioctl_command_t request, void *buffer)
| IO control of a node.
typedef off_t(* | rtems_filesystem_lseek_t) (rtems_libio_t *iop, off_t offset, int whence)
| Moves the read/write file offset.
typedef int(* | rtems_filesystem_fstat_t) (const rtems_filesystem_location_info_t *loc, struct stat *buf)
| Gets a node status.
typedef int(* | rtems_filesystem_ftruncate_t) (rtems_libio_t *iop, off_t length)
| Truncates a file to a specified length.
typedef int(* | rtems_filesystem_fsync_t) (rtems_libio_t *iop)
| Synchronizes changes to a file.
typedef int(* | rtems_filesystem_fdatasync_t) (rtems_libio_t *iop)
| Synchronizes the data of a file.
typedef int(* | rtems_filesystem_fcntl_t) (rtems_libio_t *iop, int cmd)
| File control.
typedef int(* | rtems_filesystem_poll_t) (rtems_libio_t *iop, int events)
| Poll and select support.
typedef int(* | rtems_filesystem_kqfilter_t) (rtems_libio_t *iop, struct knote *kn)
| Kernel event filter support.
typedef int(* | rtems_filesystem_mmap_t) (rtems_libio_t *iop, void **addr, size_t len, int prot, off_t off)
| MMAP support.

## Functions
int | rtems_filesystem_default_open (rtems_libio_t *iop, const char *path, int oflag, mode_t mode)
int | rtems_filesystem_default_close (rtems_libio_t *iop)
ssize_t | rtems_filesystem_default_read (rtems_libio_t *iop, void *buffer, size_t count)
ssize_t | rtems_filesystem_default_readv (rtems_libio_t *iop, const struct iovec *iov, int iovcnt, ssize_t total)
| Calls the read handler for each IO vector entry.
ssize_t | rtems_filesystem_default_write (rtems_libio_t *iop, const void *buffer, size_t count)
ssize_t | rtems_filesystem_default_writev (rtems_libio_t *iop, const struct iovec *iov, int iovcnt, ssize_t total)
| Calls the write handler for each IO vector entry.
int | rtems_filesystem_default_ioctl (rtems_libio_t *iop, ioctl_command_t request, void *buffer)
off_t | rtems_filesystem_default_lseek (rtems_libio_t *iop, off_t offset, int whence)
off_t | rtems_filesystem_default_lseek_directory (rtems_libio_t *iop, off_t offset, int whence)
| An offset 0 with a whence of SEEK_SET will perform a directory rewind operation.
off_t | rtems_filesystem_default_lseek_file (rtems_libio_t *iop, off_t offset, int whence)
| Default lseek() handler for files.
int | rtems_filesystem_default_fstat (const rtems_filesystem_location_info_t *loc, struct stat *buf)
| Sets the mode to S_IRWXU | S_IRWXG | S_IRWXO.
int | rtems_filesystem_default_ftruncate (rtems_libio_t *iop, off_t length)
int | rtems_filesystem_default_ftruncate_directory (rtems_libio_t *iop, off_t length)
int | rtems_filesystem_default_fsync_or_fdatasync (rtems_libio_t *iop)
int | rtems_filesystem_default_fsync_or_fdatasync_success (rtems_libio_t *iop)
int | rtems_filesystem_default_fcntl (rtems_libio_t *iop, int cmd)
int | rtems_filesystem_default_poll (rtems_libio_t *iop, int events)
| Default poll handler.
int | rtems_filesystem_default_kqfilter (rtems_libio_t *iop, struct knote *kn)
| Default kernel event filter handler.
int | rtems_filesystem_default_mmap (rtems_libio_t *iop, void **addr, size_t len, int prot, off_t off)
| Default MMAP handler.

## Variables
const rtems_filesystem_file_handlers_r | rtems_filesystem_handlers_default
| File system node handler table with default node handlers.

## Detailed Description

File system node handler.

## Typedef Documentation

## ◆ rtems_filesystem_close_t

typedef int(* rtems_filesystem_close_t) (rtems_libio_t *iop)

Closes a node.

Parameters

  [in,out] | iop | The IO pointer.

Return values

  0 | Successful operation.
  -1 | An error occurred. The errno is set to indicate the error.

See also
  rtems_filesystem_default_close().

## ◆ rtems_filesystem_fcntl_t

typedef int(* rtems_filesystem_fcntl_t) (rtems_libio_t *iop, int cmd)

File control.

Parameters

  [in,out] | iop | The IO pointer.
  [in] | cmd | Control command.

Return values

  0 | Successful operation.
  errno | An error occurred. This value is assigned to errno.

See also
  rtems_filesystem_default_fcntl().

## ◆ rtems_filesystem_fdatasync_t

typedef int(* rtems_filesystem_fdatasync_t) (rtems_libio_t *iop)

Synchronizes the data of a file.

Parameters

  [in,out] | iop | The IO pointer.

Return values

  0 | Successful operation.
  -1 | An error occurred. The errno is set to indicate the error.

See also
  rtems_filesystem_default_fsync_or_fdatasync() and rtems_filesystem_default_fsync_or_fdatasync_success().

## ◆ rtems_filesystem_fstat_t

typedef int(* rtems_filesystem_fstat_t) (const rtems_filesystem_location_info_t *loc, struct stat *buf)

Gets a node status.

Parameters

  [in,out] | iop | The IO pointer.
  [out] | stat | The buffer to status information.

Return values

  0 | Successful operation.
  -1 | An error occurred. The errno is set to indicate the error.

See also
  rtems_filesystem_default_fstat().

## ◆ rtems_filesystem_fsync_t

typedef int(* rtems_filesystem_fsync_t) (rtems_libio_t *iop)

Synchronizes changes to a file.

Parameters

  [in,out] | iop | The IO pointer.

Return values

  0 | Successful operation.
  -1 | An error occurred. The errno is set to indicate the error.

See also
  rtems_filesystem_default_fsync_or_fdatasync() and rtems_filesystem_default_fsync_or_fdatasync_success().

## ◆ rtems_filesystem_ftruncate_t

typedef int(* rtems_filesystem_ftruncate_t) (rtems_libio_t *iop, off_t length)

Truncates a file to a specified length.

Parameters

  [in,out] | iop | The IO pointer.
  [in] | length | The new length in characters.

Return values

  0 | Successful operation.
  -1 | An error occurred. The errno is set to indicate the error.

See also
  rtems_filesystem_default_ftruncate() and rtems_filesystem_default_ftruncate_directory().

## ◆ rtems_filesystem_ioctl_t

typedef int(* rtems_filesystem_ioctl_t) (rtems_libio_t *iop, ioctl_command_t request, void *buffer)

IO control of a node.

Parameters

  [in,out] | iop | The IO pointer.
  [in] | request | The IO control request.
  [in,out] | buffer | The buffer for IO control request data.

Return values

  0 | Successful operation.
  -1 | An error occurred. The errno is set to indicate the error.

See also
  rtems_filesystem_default_ioctl().

## ◆ rtems_filesystem_kqfilter_t

typedef int(* rtems_filesystem_kqfilter_t) (rtems_libio_t *iop, struct knote *kn)

Kernel event filter support.

Parameters

  [in,out] | iop | The IO pointer.
  [in] | kn | The kernel event note.

Return values

  0 | Successful operation.
  error | An error occurred. This is usually EINVAL.

See also
  rtems_filesystem_default_kqfilter().

## ◆ rtems_filesystem_lseek_t

typedef off_t(* rtems_filesystem_lseek_t) (rtems_libio_t *iop, off_t offset, int whence)

Moves the read/write file offset.

Parameters

  [in,out] | iop | The IO pointer.
  [in] | offset | The offset.
  [in] | whence | The reference position for the offset.

Return values

  non-negative | The new offset from the beginning of the file.
  -1 | An error occurred. The errno is set to indicate the error.

See also
  rtems_filesystem_default_lseek(), rtems_filesystem_default_lseek_file(), and rtems_filesystem_default_lseek_directory().

## ◆ rtems_filesystem_mmap_t

typedef int(* rtems_filesystem_mmap_t) (rtems_libio_t *iop, void **addr, size_t len, int prot, off_t off)

MMAP support.

Parameters

  [in,out] | iop | The IO pointer.
  [in,out] | addr | The starting address of the mapped memory.
  [in] | len | The maximum number of bytes to map.
  [in] | prot | The desired memory protection.
  [in] | off | The offset within the file descriptor to map.

Return values

  0 | Successful operation.
  error | An error occurred. This is usually EINVAL.

See also
  rtems_filesystem_default_mmap().

## ◆ rtems_filesystem_open_t

typedef int(* rtems_filesystem_open_t) (rtems_libio_t *iop, const char *path, int oflag, mode_t mode)

Opens a node.

Parameters

  [in,out] | iop | The IO pointer.
  [in] | path | The path.
  [in] | oflag | The open flags.
  [in] | mode | Optional mode for node creation.

Return values

  0 | Successful operation.
  -1 | An error occurred. The errno is set to indicate the error.

See also
  rtems_filesystem_default_open().

## ◆ rtems_filesystem_poll_t

typedef int(* rtems_filesystem_poll_t) (rtems_libio_t *iop, int events)

Poll and select support.

Parameters

  [in,out] | iop | The IO pointer.
  [in] | events | The poll events.

Returns
  The poll return events.

See also
  rtems_filesystem_default_poll().

## ◆ rtems_filesystem_read_t

typedef ssize_t(* rtems_filesystem_read_t) (rtems_libio_t *iop, void *buffer, size_t count)

Reads from a node.

This handler is responsible to update the offset field of the IO descriptor.

Parameters

  [in,out] | iop | The IO pointer.
  [out] | buffer | The buffer for read data.
  [in] | count | The size of the buffer in characters.

Return values

  non-negative | Count of read characters.
  -1 | An error occurred. The errno is set to indicate the error.

See also
  rtems_filesystem_default_read().

## ◆ rtems_filesystem_readv_t

typedef ssize_t(* rtems_filesystem_readv_t) (rtems_libio_t *iop, const struct iovec *iov, int iovcnt, ssize_t total)

Reads an IO vector from a node.

This handler is responsible to update the offset field of the IO descriptor.

Parameters

  [in,out] | iop | The IO pointer.
  [in] | iov | The IO vector with buffer for read data. The caller must ensure that the IO vector values are valid.
  [in] | iovcnt | The count of buffers in the IO vector.
  [in] | total | The total count of bytes in the buffers in the IO vector.

Return values

  non-negative | Count of read characters.
  -1 | An error occurred. The errno is set to indicate the error.

See also
  rtems_filesystem_default_readv().

## ◆ rtems_filesystem_write_t

typedef ssize_t(* rtems_filesystem_write_t) (rtems_libio_t *iop, const void *buffer, size_t count)

Writes to a node.

This handler is responsible to update the offset field of the IO descriptor.

Parameters

  [in,out] | iop | The IO pointer.
  [out] | buffer | The buffer for write data.
  [in] | count | The size of the buffer in characters.

Return values

  non-negative | Count of written characters.
  -1 | An error occurred. The errno is set to indicate the error.

See also
  rtems_filesystem_default_write().

## ◆ rtems_filesystem_writev_t

typedef ssize_t(* rtems_filesystem_writev_t) (rtems_libio_t *iop, const struct iovec *iov, int iovcnt, ssize_t total)

Writes an IO vector to a node.

This handler is responsible to update the offset field of the IO descriptor.

Parameters

  [in,out] | iop | The IO pointer.
  [in] | iov | The IO vector with buffer for write data. The caller must ensure that the IO vector values are valid.
  [in] | iovcnt | The count of buffers in the IO vector.
  [in] | total | The total count of bytes in the buffers in the IO vector.

Return values

  non-negative | Count of written characters.
  -1 | An error occurred. The errno is set to indicate the error.

See also
  rtems_filesystem_default_writev().

## Function Documentation

## ◆ rtems_filesystem_default_close()

int rtems_filesystem_default_close | ( | rtems_libio_t * | iop | ) |

Return values

  0 | Always.

See also
  rtems_filesystem_close_t.

## ◆ rtems_filesystem_default_fcntl()

int rtems_filesystem_default_fcntl | ( | rtems_libio_t * | iop,
|  | int | cmd
| ) |  |

Return values

  0 | Always.

See also
  rtems_filesystem_fcntl_t.

## ◆ rtems_filesystem_default_fstat()

int rtems_filesystem_default_fstat | ( | const rtems_filesystem_location_info_t * | loc,
|  | struct stat * | buf
| ) |  |

Sets the mode to S_IRWXU | S_IRWXG | S_IRWXO.

Return values

  0 | Always.

See also
  rtems_filesystem_fstat_t.

## ◆ rtems_filesystem_default_fsync_or_fdatasync()

int rtems_filesystem_default_fsync_or_fdatasync | ( | rtems_libio_t * | iop | ) |

Return values

  -1 | Always. The errno is set to EINVAL.

See also
  rtems_filesystem_fsync_t and rtems_filesystem_fdatasync_t.

## ◆ rtems_filesystem_default_fsync_or_fdatasync_success()

int rtems_filesystem_default_fsync_or_fdatasync_success | ( | rtems_libio_t * | iop | ) |

Return values

  0 | Always.

See also
  rtems_filesystem_fsync_t and rtems_filesystem_fdatasync_t.

## ◆ rtems_filesystem_default_ftruncate()

int rtems_filesystem_default_ftruncate | ( | rtems_libio_t * | iop,
|  | off_t | length
| ) |  |

Return values

  -1 | Always. The errno is set to EINVAL.

See also
  rtems_filesystem_ftruncate_t.

## ◆ rtems_filesystem_default_ftruncate_directory()

int rtems_filesystem_default_ftruncate_directory | ( | rtems_libio_t * | iop,
|  | off_t | length
| ) |  |

Return values

  -1 | Always. The errno is set to EISDIR.

See also
  rtems_filesystem_ftruncate_t.

## ◆ rtems_filesystem_default_ioctl()

int rtems_filesystem_default_ioctl | ( | rtems_libio_t * | iop,
|  | ioctl_command_t | request,
|  | void * | buffer
| ) |  |

Return values

  -1 | Always. The errno is set to ENOTTY.

See also
  rtems_filesystem_ioctl_t.

## ◆ rtems_filesystem_default_kqfilter()

int rtems_filesystem_default_kqfilter | ( | rtems_libio_t * | iop,
|  | struct knote * | kn
| ) |  |

Default kernel event filter handler.

Return values

  EINVAL | Always.

See also
  rtems_filesystem_kqfilter_t.

## ◆ rtems_filesystem_default_lseek()

off_t rtems_filesystem_default_lseek | ( | rtems_libio_t * | iop,
|  | off_t | offset,
|  | int | whence
| ) |  |

Return values

  -1 | Always. The errno is set to ESPIPE.

See also
  rtems_filesystem_lseek_t.

## ◆ rtems_filesystem_default_lseek_directory()

off_t rtems_filesystem_default_lseek_directory | ( | rtems_libio_t * | iop,
|  | off_t | offset,
|  | int | whence
| ) |  |

An offset 0 with a whence of SEEK_SET will perform a directory rewind operation.

This function has no protection against concurrent access.

Return values

  -1 | The offset is not zero or the whence is not SEEK_SET.
  0 | Successful rewind operation.

See also
  rtems_filesystem_lseek_t.

## ◆ rtems_filesystem_default_lseek_file()

off_t rtems_filesystem_default_lseek_file | ( | rtems_libio_t * | iop,
|  | off_t | offset,
|  | int | whence
| ) |  |

Default lseek() handler for files.

The fstat() handler will be used to obtain the file size in case whence is SEEK_END.

This function has no protection against concurrent access.

Return values

  -1 | An error occurred. In case an integer overflow occurred, then the errno will be set to EOVERFLOW. In case the new offset is negative, then the errno will be set to EINVAL. In case the whence is SEEK_END and the fstat() handler to obtain the current file size returned an error status, then the errno will be set by the fstat() handler.
  offset | The new offset.

See also
  rtems_filesystem_lseek_t.

## ◆ rtems_filesystem_default_mmap()

int rtems_filesystem_default_mmap | ( | rtems_libio_t * | iop,
|  | void ** | addr,
|  | size_t | len,
|  | int | prot,
|  | off_t | off
| ) |  |

Default MMAP handler.

Return values

  ENOTSUP | Always.

See also
  rtems_filesystem_mmap_t.

## ◆ rtems_filesystem_default_open()

int rtems_filesystem_default_open | ( | rtems_libio_t * | iop,
|  | const char * | path,
|  | int | oflag,
|  | mode_t | mode
| ) |  |

Return values

  0 | Always.

See also
  rtems_filesystem_open_t.

## ◆ rtems_filesystem_default_poll()

int rtems_filesystem_default_poll | ( | rtems_libio_t * | iop,
|  | int | events
| ) |  |

Default poll handler.

Return values

  POLLERR | Always.

See also
  rtems_filesystem_poll_t.

## ◆ rtems_filesystem_default_read()

ssize_t rtems_filesystem_default_read | ( | rtems_libio_t * | iop,
|  | void * | buffer,
|  | size_t | count
| ) |  |

Return values

  -1 | Always. The errno is set to ENOTSUP.

See also
  rtems_filesystem_read_t.

## ◆ rtems_filesystem_default_readv()

ssize_t rtems_filesystem_default_readv | ( | rtems_libio_t * | iop,
|  | const struct iovec * | iov,
|  | int | iovcnt,
|  | ssize_t | total
| ) |  |

Calls the read handler for each IO vector entry.

See also
  rtems_filesystem_readv_t.

## ◆ rtems_filesystem_default_write()

ssize_t rtems_filesystem_default_write | ( | rtems_libio_t * | iop,
|  | const void * | buffer,
|  | size_t | count
| ) |  |

Return values

  -1 | Always. The errno is set to ENOTSUP.

See also
  rtems_filesystem_write_t.

## ◆ rtems_filesystem_default_writev()

ssize_t rtems_filesystem_default_writev | ( | rtems_libio_t * | iop,
|  | const struct iovec * | iov,
|  | int | iovcnt,
|  | ssize_t | total
| ) |  |

Calls the write handler for each IO vector entry.

See also
  rtems_filesystem_write_t.