Ramdisks

Mathew Benson mathew.benson at gmail.com
Thu Apr 6 22:50:29 UTC 2017


I basically do that too.  But can you do it again to create another RAM
disk?

On Thu, Apr 6, 2017, 5:46 PM Chris Johns <chrisj at rtems.org> wrote:

> On 07/04/2017 00:08, Mathew Benson wrote:
> > Can I create a ramdisk, append to the rtems_ramdisk_configuration object
> > and register a new set of drivers to mount another ramdisk?  Or are the
> > drivers registered oncecand only once at initialization?  Basically, do
> > I have to predefine all the ramdisks?  I have an application that
> > calculates the number of blocks at initialization and creates them one
> > at a time.  But it appears that only the first call to register the
> > driver actually results in the creation of a new ramdisk device.
> >
>
> I create a RAM disk by calling `ramdisk_register`. For example:
>
> #define RAMDISK_BLOCK_SIZE  512
> #define RAMDISK_BLOCK_COUNT ((32 * (1024 * 1024UL))/RAMDISK_BLOCK_SIZE)
> #define RAMDISK_PATH        "/dev/rda"
>
> void setup_ramdisk (void)
> {
> #if HAS_RAMDISK
>    dev_t             dev = 0;
>    rtems_status_code sc;
>
>    printf("RAM disk: ");
>
>    sc = rtems_disk_io_initialize ();
>    if (sc != RTEMS_SUCCESSFUL)
>    {
>      printf ("error: disk io not initialised: %s\n",
>              rtems_status_text (sc));
>      return;
>    }
>
>    sc = ramdisk_register (RAMDISK_BLOCK_SIZE, RAMDISK_BLOCK_COUNT,
>                           false, RAMDISK_PATH, &dev);
>    if (sc != RTEMS_SUCCESSFUL)
>    {
>      printf ("error: ramdisk driver not initialised: %s\n",
>              rtems_status_text (sc));
>      return;
>    }
>
>    printf ("successful\n");
> #endif
> }
>
> I then RFS format and mount the disk using a `#! joel` script:
>
>   #! joel
>   # Format and mount the RAM disk
>   mkrfs /dev/rda
>   mkdir /ram
>   mount -t rfs /dev/rda /ram
>
> Chris
> _______________________________________________
> users mailing list
> users at rtems.org
> http://lists.rtems.org/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20170406/d89e9a4a/attachment.html>


More information about the users mailing list