RTEMS  5.0.0
Files | Data Structures | Enumerations | Functions
File System Mount Support

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. More...
 

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

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)
{
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);
}