RTEMS: File System Mount Support

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
Files | Data Structures | Enumerations | Functions
File System Mount Support
IO Library » File System Types and Mount

File System Mount Functions. More...

## Files
file | fsmount.c
| File System Mount Functions.

## Data Structures
struct | rtems_fstab_entry

## Enumerations
enum | rtems_fstab_conditions { RTEMS_FSTAB_NONE = 0U , RTEMS_FSTAB_OK = 0x1U , RTEMS_FSTAB_ERROR_MOUNT_POINT = 0x2U , RTEMS_FSTAB_ERROR_MOUNT = 0x4U , RTEMS_FSTAB_ERROR = RTEMS_FSTAB_ERROR_MOUNT_POINT | RTEMS_FSTAB_ERROR_MOUNT , RTEMS_FSTAB_ANY = RTEMS_FSTAB_OK | RTEMS_FSTAB_ERROR }

## Functions
int | rtems_fsmount (const rtems_fstab_entry *fstab, size_t size, size_t *abort_index)
| Mounts the file systems listed in the file system mount table.

## Detailed Description

File System Mount Functions.

This file contains the fsmount functions. These functions
are used to mount a list of filesystems (and create their mount points before).

## Enumeration Type Documentation

## ◆ rtems_fstab_conditions

enum rtems_fstab_conditions

File system mount report and abort condition flags.

The flags define, which conditions will cause a report during the mount process (via printf()) or abort the mount process.

See also
  rtems_fstab_entry and rtems_fsmount().

Enumerator
RTEMS_FSTAB_NONE | No conditions.
RTEMS_FSTAB_OK | Complete mount process was successful.
RTEMS_FSTAB_ERROR_MOUNT_POINT | Mount point creation failed.
RTEMS_FSTAB_ERROR_MOUNT | File system mount failed.
RTEMS_FSTAB_ERROR | Something failed.
RTEMS_FSTAB_ANY | Any condition.

## Function Documentation

## ◆ rtems_fsmount()

int rtems_fsmount | ( | const rtems_fstab_entry * | fstab,
|  | size_t | size,
|  | size_t * | abort_index
| ) |  |

Mounts the file systems listed in the file system mount table.

Mounts the file systems listed in the file system mount table fstab of size size.

Each file system will be mounted according to its table entry parameters. In case of an abort condition the corresponding table index will be reported in abort_index. The pointer abort_index may be `NULL`. The mount point paths will be created with rtems_mkdir() and need not exist beforehand.

On success, zero is returned. On error, -1 is returned, and `errno` is set appropriately.

See also
  rtems_bdpart_register_from_disk().

The following example code tries to mount a FAT file system within a SD Card. Some cards do not have a partition table so at first it tries to find a file system inside the hole disk. If this is successful the mount process will be aborted because the RTEMS_FSTAB_OK condition is true. If this did not work it tries to mount the file system inside the first partition. If this fails the mount process will not be aborted (this is already the last entry), but the last error status will be returned.

#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <rtems.h>
#include <rtems/bdpart.h>
#include <rtems/error.h>
#include <rtems/fsmount.h>
static const rtems_fstab_entry fstab [] = {
{
.source = "/dev/sd-card-a",
.target = "/mnt",
.type = "dosfs",
.options = RTEMS_FILESYSTEM_READ_WRITE,
.report_reasons = RTEMS_FSTAB_ANY,
.abort_reasons = RTEMS_FSTAB_OK
}, {
.source = "/dev/sd-card-a1",
.target = "/mnt",
.type = "dosfs",
.options = RTEMS_FILESYSTEM_READ_WRITE,
.report_reasons = RTEMS_FSTAB_ANY,
.abort_reasons = RTEMS_FSTAB_NONE
}
};
static void my_mount(void)
{
rtems_status_code sc = RTEMS_SUCCESSFUL;
int rv = 0;
size_t abort_index = 0;
sc = rtems_bdpart_register_from_disk("/dev/sd-card-a");
if (sc != RTEMS_SUCCESSFUL) {
printf("read partition table failed: %s\n", rtems_status_text(sc));
}
rv = rtems_fsmount(fstab, sizeof(fstab) / sizeof(fstab [0]), &abort_index);
if (rv != 0) {
printf("mount failed: %s\n", strerror(errno));
}
printf("mount aborted at %zu\n", abort_index);
}
bdpart.h
Block Device Partition Management.
error.h
RTEMS Error Reporting.
fsmount.h
rtems_status_code
rtems_status_code
Classic API Status.
Definition: status.h:43
rtems_status_text
const char * rtems_status_text(rtems_status_code code)
Returns a text for a status code.
Definition: statustext.c:60
RTEMS_SUCCESSFUL
@ RTEMS_SUCCESSFUL
Definition: status.h:47
rtems_bdpart_register_from_disk
rtems_status_code rtems_bdpart_register_from_disk(const char *disk_name)
Definition: bdpart-register.c:127
rtems_fsmount
int rtems_fsmount(const rtems_fstab_entry *fstab, size_t size, size_t *abort_index)
Mounts the file systems listed in the file system mount table.
Definition: fsmount.c:40
RTEMS_FSTAB_NONE
@ RTEMS_FSTAB_NONE
Definition: fsmount.h:56
RTEMS_FSTAB_OK
@ RTEMS_FSTAB_OK
Definition: fsmount.h:61
RTEMS_FSTAB_ANY
@ RTEMS_FSTAB_ANY
Definition: fsmount.h:81
rtems.h
rtems_fstab_entry
Definition: fsmount.h:87
rtems_fstab_entry::source
const char * source
Definition: fsmount.h:91