Changeset d0c3b38b in rtems


Ignore:
Timestamp:
May 5, 2009, 12:57:16 PM (10 years ago)
Author:
Thomas Doerfler <Thomas.Doerfler@…>
Branches:
4.10, 4.11, master
Children:
ce7cfe7
Parents:
d8602eb
Message:

Documentation. Changed integer types to match block device types.
Added const qualifier whenever possible. Added
rtems_fsmount_create_mount_point() prototype.

Location:
cpukit
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libblock/include/rtems/ramdisk.h

    rd8602eb rd0c3b38b  
    11/**
    2  * @file rtems/ramdisk.h
    3  * RAM disk block device implementation
     2 * @file
     3 *
     4 * RAM disk block device.
    45 */
    56
     
    2223#endif
    2324
    24 /* RAM disk configuration table entry */
     25/**
     26 * @defgroup rtems_ramdisk RAM Disk Device
     27 *
     28 * @ingroup rtems_blkdev
     29 *
     30 * @{
     31 */
     32
     33/**
     34 * RAM disk configuration table entry.
     35 */
    2536typedef struct rtems_ramdisk_config {
    26     int   block_size; /* RAM disk block size */
    27     int   block_num;  /* Number of blocks on this RAM disk */
    28     void *location;   /* RAM disk permanent location (out of RTEMS controlled
    29                          memory), or NULL if RAM disk memory should be
    30                          allocated dynamically */
     37  /**
     38   * RAM disk block size (must be a power of two).
     39   */
     40  uint32_t block_size;
     41
     42  /**
     43   * Number of blocks on this RAM disk.
     44   */
     45  rtems_blkdev_bnum block_num;
     46
     47  /**
     48   * RAM disk location or @c NULL if RAM disk memory should be allocated
     49   * dynamically.
     50   */
     51  void *location;
    3152} rtems_ramdisk_config;
    3253
    33 /* If application want to use RAM disk, it should specify configuration of
    34  * available RAM disks.
    35  * The following is definitions for RAM disk configuration table
     54/**
     55 * External reference to the RAM disk configuration table describing each RAM
     56 * disk in the system.
     57 *
     58 * The configuration table is provided by the application.
    3659 */
    37 extern rtems_ramdisk_config rtems_ramdisk_configuration[];
     60extern rtems_ramdisk_config rtems_ramdisk_configuration [];
     61
     62/**
     63 * External reference the size of the RAM disk configuration table
     64 * @ref rtems_ramdisk_configuration.
     65 *
     66 * The configuration table size is provided by the application.
     67 */
    3868extern size_t rtems_ramdisk_configuration_size;
    3969
    40 /* ramdisk_initialize --
    41  *     RAM disk driver initialization entry point.
     70/**
     71 * RAM disk driver initialization entry point.
    4272 */
    43 rtems_device_driver
    44 ramdisk_initialize(
    45     rtems_device_major_number major,
    46     rtems_device_minor_number minor,
    47     void *arg);
     73rtems_device_driver ramdisk_initialize(
     74 rtems_device_major_number major,
     75 rtems_device_minor_number minor,
     76 void *arg
     77);
    4878
     79/**
     80 * RAM disk driver table entry.
     81 */
    4982#define RAMDISK_DRIVER_TABLE_ENTRY \
    50     { ramdisk_initialize, RTEMS_GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES }
     83  { \
     84    .initialization_entry = ramdisk_initialize, \
     85    RTEMS_GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES \
     86  }
     87
     88/** @} */
    5189
    5290#ifdef __cplusplus
  • cpukit/libblock/src/ramdisk.c

    rd8602eb rd0c3b38b  
    1 /* ramdisk.c -- RAM disk block device implementation
    2  *
     1/**
     2 * @file
     3 *
     4 * RAM disk block device.
     5 */
     6
     7/*
    38 * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
    49 * Author: Victor V. Vengerov <vvv@oktet.ru>
     
    1924#include <inttypes.h>
    2025
    21 #include "rtems/blkdev.h"
    22 #include "rtems/diskdevs.h"
    23 #include "rtems/ramdisk.h"
     26#include <rtems/blkdev.h>
     27#include <rtems/diskdevs.h>
     28#include <rtems/ramdisk.h>
    2429
    2530/**
     
    3136#endif
    3237
    33 #define RAMDISK_DEVICE_BASE_NAME "/dev/ramdisk"
     38#define RAMDISK_DEVICE_BASE_NAME "/dev/rd"
    3439
    3540/* Internal RAM disk descriptor */
    3641struct ramdisk {
    37     int           block_size; /* RAM disk block size */
    38     int           block_num;  /* Number of blocks on this RAM disk */
    39     void         *area;       /* RAM disk memory area */
    40     bool          initialized;/* RAM disk is initialized */
    41     bool          malloced;   /* != 0, if memory allocated by malloc for this
    42                                  RAM disk */
    43 #if RTEMS_RAMDISK_TRACE
    44     int           info_level; /* Trace level */
     42  uint32_t block_size; /* RAM disk block size */
     43  rtems_blkdev_bnum block_num; /* Number of blocks on this RAM disk */
     44  void *area; /* RAM disk memory area */
     45  bool initialized; /* RAM disk is initialized */
     46  bool malloced; /* != 0, if memory allocated by malloc for this RAM disk */
     47#if RTEMS_RAMDISK_TRACE
     48  int info_level; /* Trace level */
    4549#endif
    4650};
    4751
    4852static struct ramdisk *ramdisk;
    49 static uint32_t        nramdisks;
     53static uint32_t nramdisks;
    5054
    5155#if RTEMS_RAMDISK_TRACE
     
    243247    {
    244248        dev_t dev = rtems_filesystem_make_dev_t(major, i);
    245         char name[sizeof(RAMDISK_DEVICE_BASE_NAME "0123456789")];
    246         snprintf(name, sizeof(name), RAMDISK_DEVICE_BASE_NAME "%" PRIu32, i);
     249        char name [] = RAMDISK_DEVICE_BASE_NAME "a";
     250        name [sizeof(RAMDISK_DEVICE_BASE_NAME)] += i;
    247251        r->block_size = c->block_size;
    248252        r->block_num = c->block_num;
  • cpukit/libmisc/fsmount/fsmount.c

    rd8602eb rd0c3b38b  
     1/**
     2 * @file
     3 *
     4 * File system mount functions.
     5 */
     6
    17/*===============================================================*\
    28| Project: RTEMS fsmount                                          |
     
    3945| Function:                                                                 |
    4046\*-------------------------------------------------------------------------*/
    41 int rtems_fsmount_create_mountpoint
     47int rtems_fsmount_create_mount_point
    4248(
    4349/*-------------------------------------------------------------------------*\
     
    114120| Input Parameters:                                                         |
    115121\*-------------------------------------------------------------------------*/
    116  const fstab_t *fstab_ptr,
    117  int fstab_count,
    118  int *fail_idx
     122 const rtems_fstab_entry *fstab_ptr,
     123 size_t fstab_count,
     124 size_t *fail_idx
    119125 )
    120126/*-------------------------------------------------------------------------*\
     
    125131  int rc = 0;
    126132  int tmp_rc;
    127   int fstab_idx = 0;
     133  size_t fstab_idx = 0;
    128134  rtems_filesystem_mount_table_entry_t *tmp_mt_entry;
    129135  bool terminate = false;
     
    139145     */
    140146    if (tmp_rc == 0) {
    141       tmp_rc = rtems_fsmount_create_mountpoint(fstab_ptr->mount_point);
     147      tmp_rc = rtems_fsmount_create_mount_point(fstab_ptr->mount_point);
    142148      if (tmp_rc != 0) {
    143149        if (0 != (fstab_ptr->report_reasons & FSMOUNT_MNTPNT_CRTERR)) {
     
    155161     * mount device to given mount point
    156162     */
    157     if (tmp_rc == RTEMS_SUCCESSFUL) {
     163    if (tmp_rc == 0) {
    158164      tmp_rc = mount(&tmp_mt_entry,
    159165                     fstab_ptr->fs_ops,
     
    161167                     fstab_ptr->dev,
    162168                     fstab_ptr->mount_point);
    163       if (tmp_rc != RTEMS_SUCCESSFUL) {
     169      if (tmp_rc != 0) {
    164170        if (0 != (fstab_ptr->report_reasons & FSMOUNT_MNT_FAILED)) {
    165171          fprintf(stdout,"fsmount: mounting of \"%s\" to"
  • cpukit/libmisc/fsmount/fsmount.h

    rd8602eb rd0c3b38b  
     1/**
     2 * @file
     3 *
     4 * File system mount functions.
     5 */
     6
    17/*===============================================================*\
    28| Project: RTEMS fsmount                                          |
     
    3440#endif
    3541
    36 /*
    37  * bits to define, what errors will cause reporting (via printf) and
    38  * abort of mount processing
    39  * Use a combination of these bits
    40  * for the fields "report_reasons" and "abort_reasons"
    41  */
    42 #define FSMOUNT_MNT_OK        0x0001 /* mounted ok                 */
    43 #define FSMOUNT_MNTPNT_CRTERR 0x0002 /* cannot create mount point  */
    44 #define FSMOUNT_MNT_FAILED    0x0004 /* mounting failed            */
    45 
     42/**
     43 * @defgroup rtems_fstab File System Mount Support
     44 *
     45 * @{
     46 */
     47
     48/**
     49 * File system mount report and abort condition flags.
     50 *
     51 * The flags define, which conditions will cause a report during the mount
     52 * process (via printf()) or abort the mount process.
     53 *
     54 * @see rtems_fstab_entry and rtems_fsmount().
     55 */
     56typedef enum {
     57  /**
     58   * No conditions.
     59   */
     60  RTEMS_FSTAB_NONE = 0U,
     61
     62  /**
     63   * Complete mount process was successful.
     64   */
     65  RTEMS_FSTAB_OK = 0x1U,
     66
     67  /**
     68   * Mount point creation failed.
     69   */
     70  RTEMS_FSTAB_ERROR_MOUNT_POINT = 0x2U,
     71
     72  /**
     73   * File system mount failed.
     74   */
     75  RTEMS_FSTAB_ERROR_MOUNT = 0x4U,
     76
     77  /**
     78   * Something failed.
     79   */
     80  RTEMS_FSTAB_ERROR = RTEMS_FSTAB_ERROR_MOUNT_POINT | RTEMS_FSTAB_ERROR_MOUNT,
     81
     82  /**
     83   * Any condition.
     84   */
     85  RTEMS_FSTAB_ANY = RTEMS_FSTAB_OK | RTEMS_FSTAB_ERROR
     86} rtems_fstab_conditions;
     87
     88/**
     89 * File system table entry.
     90 */
    4691typedef struct {
    47   char *dev;
    48   char *mount_point;
    49   rtems_filesystem_operations_table *fs_ops;
     92  /**
     93   * Device file path.
     94   */
     95  const char *dev;
     96
     97  /**
     98   * Mount point path.
     99   */
     100  const char *mount_point;
     101
     102  /**
     103   * File system operations.
     104   */
     105  const rtems_filesystem_operations_table *fs_ops;
     106
     107  /**
     108   * File system mount options.
     109   */
    50110  rtems_filesystem_options_t mount_options;
    51   uint16_t   report_reasons;
    52   uint16_t   abort_reasons;
    53 } fstab_t;
    54 
    55 
    56 /*=========================================================================*\
    57 | Function:                                                                 |
    58 \*-------------------------------------------------------------------------*/
    59 int rtems_fsmount
    60 (
    61 /*-------------------------------------------------------------------------*\
    62 | Purpose:                                                                  |
    63 |  This function will create the mount points listed and mount the file     |
    64 |   systems listed in the calling parameters                                |
    65 +---------------------------------------------------------------------------+
    66 | Input Parameters:                                                         |
    67 \*-------------------------------------------------------------------------*/
    68  const fstab_t *fstab_ptr,              /* Ptr to filesystem mount table   */
    69  int fstab_count,                       /* number of entries in mount table*/
    70  int *fail_idx                          /* return: index of failed entry   */
    71  );
    72 /*-------------------------------------------------------------------------*\
    73 | Return Value:                                                             |
    74 |    0, if success, -1 and errno if failed                                  |
    75 \*=========================================================================*/
     111
     112  /**
     113   * Report @ref rtems_fstab_conditions "condition flags".
     114   */
     115  uint16_t report_reasons;
     116
     117  /**
     118   * Abort @ref rtems_fstab_conditions "condition flags".
     119   */
     120  uint16_t abort_reasons;
     121} rtems_fstab_entry;
     122
     123/**
     124 * Creates the mount point with path @a mount_point.
     125 *
     126 * On success, zero is returned.  On error, -1 is returned, and @c errno is set
     127 * appropriately.
     128 *
     129 * @see rtems_fsmount().
     130 */
     131int rtems_fsmount_create_mount_point( const char *mount_point);
     132
     133/**
     134 * Mounts the file systems listed in the file system mount table @a fstab of
     135 * size @a size.
     136 *
     137 * Each file system will be mounted according to its table entry parameters.
     138 * In case of an abort condition the corresponding table index will be reported
     139 * in @a abort_index.  The pointer @a abort_index may be @c NULL.  The mount
     140 * point paths will be created with rtems_fsmount_create_mount_point() and need
     141 * not exist beforehand.
     142 *
     143 * On success, zero is returned.  On error, -1 is returned, and @c errno is set
     144 * appropriately.
     145 *
     146 * @see rtems_bdpart_register_from_disk().
     147 *
     148 * The following example code tries to mount a FAT file system within a SD
     149 * Card.  Some cards do not have a partition table so at first it tries to find
     150 * a file system inside the hole disk.  If this is successful the mount process
     151 * will be aborted because the @ref RTEMS_FSTAB_OK condition is true.  If this
     152 * did not work it tries to mount the file system inside the first partition.
     153 * If this fails the mount process will not be aborted (this is already the
     154 * last entry), but the last error status will be returned.
     155 *
     156 * @code
     157 * #include <stdio.h>
     158 * #include <string.h>
     159 * #include <errno.h>
     160 *
     161 * #include <rtems.h>
     162 * #include <rtems/bdpart.h>
     163 * #include <rtems/dosfs.h>
     164 * #include <rtems/error.h>
     165 * #include <rtems/fsmount.h>
     166 *
     167 * static const rtems_fstab_entry fstab [] = {
     168 *   {
     169 *     .dev = "/dev/sd-card-a",
     170 *     .mount_point = "/mnt",
     171 *     .fs_ops = &msdos_ops,
     172 *     .mount_options = RTEMS_FILESYSTEM_READ_WRITE,
     173 *     .report_reasons = RTEMS_FSTAB_ANY,
     174 *     .abort_reasons = RTEMS_FSTAB_OK
     175 *   }, {
     176 *     .dev = "/dev/sd-card-a1",
     177 *     .mount_point = "/mnt",
     178 *     .fs_ops = &msdos_ops,
     179 *     .mount_options = RTEMS_FILESYSTEM_READ_WRITE,
     180 *     .report_reasons = RTEMS_FSTAB_ANY,
     181 *     .abort_reasons = RTEMS_FSTAB_NONE
     182 *   }
     183 * };
     184 *
     185 * static void my_mount(void)
     186 * {
     187 *   rtems_status_code sc = RTEMS_SUCCESSFUL;
     188 *   int rv = 0;
     189 *   size_t abort_index = 0;
     190 *
     191 *   sc = rtems_bdpart_register_from_disk("/dev/sd-card-a");
     192 *   if (sc != RTEMS_SUCCESSFUL) {
     193 *     printf("read partition table failed: %s\n", rtems_status_text(sc));
     194 *   }
     195 *
     196 *   rv = rtems_fsmount(fstab, sizeof(fstab) / sizeof(fstab [0]), &abort_index);
     197 *   if (rv != 0) {
     198 *     printf("mount failed: %s\n", strerror(errno));
     199 *   }
     200 *   printf("mount aborted at %zu\n", abort_index);
     201 * }
     202 * @endcode
     203 */
     204int rtems_fsmount( const rtems_fstab_entry *fstab, size_t size, size_t *abort_index);
     205
     206/** @} */
     207
     208typedef rtems_fstab_entry fstab_t;
     209
     210#define FSMOUNT_MNT_OK RTEMS_FSTAB_OK
     211
     212#define FSMOUNT_MNTPNT_CRTERR RTEMS_FSTAB_ERROR_MOUNT_POINT
     213
     214#define FSMOUNT_MNT_FAILED RTEMS_FSTAB_ERROR_MOUNT
    76215
    77216#ifdef __cplusplus
Note: See TracChangeset for help on using the changeset viewer.