Notice: We have migrated to GitLab launching 2024-05-01 see here: https://gitlab.rtems.org/

Changes between Version 1 and Version 2 of TBR/UserManual/RTEMS_File_System


Ignore:
Timestamp:
02/20/10 09:09:49 (14 years ago)
Author:
ChrisJohns
Comment:

Add an overview and using.

Legend:

Unmodified
Added
Removed
Modified
  • TBR/UserManual/RTEMS_File_System

    v1 v2  
    77
    88The RTEMS File System or RFS provides a fully featured file system that is fast and compact. The RFS interfaces to the [wiki:File_Systems#Block_Devices Block Devices API] and therefore supports all the block devices RTEMS has. It also interfaces to the RTEMS libc file system support layer. This means the POSIX interface to files in RTEMS is supported by the RFS file system.
     9= RFS Structure =
     10
     11
     12The RFS file system consists of superblock at the start followed by a series of groups. A group is a group of blocks.
     13
     14<blockquote>
     15{| border="1" cellpadding="5" cellspacing="0"
     16|-
     17! style="background:#efefef;" | Superblock
     18|-
     19! align="center" | Group
     20|-
     21! align="center" | Group
     22|}
     23</blockquote>
     24
     25A group is broken up into the block allocation bitmap the inode allocation bitmap, the inodes, and the data blocks.
     26
     27<blockquote>
     28{| border="1" cellpadding="5" cellspacing="0"
     29|-
     30! align="center' | Block Bitmap
     31|-
     32! align="center" | Inode Bitmap
     33|-
     34! align="center" | Inodes
     35|-
     36! align="center" | Data Blocks
     37|}
     38</blockquote>
     39
     40The block bitmap contains a single bit for every block in a group. The default format is to allocate the size of a group based on the number of bits that fit into a single block. For example a block of 1024 bytes has 8,192 bits therefore a group can have 8192 blocks including the block bitmap block. The inode bitmap has a bit for ever inode in the group. An inode is the information about a node on the disk. A node is the data that links the elements of the disk together to create directories, files, and nodes. The number of inodes in a group is format configuration parameter. The default is use 1% of the disk's blocks for inode data. Again with a 1024 byte block size there are 18 inodes per block and 1448 inodes per group.
     41= Using the RFS =
     42
     43
     44The easiest way to use the RFS and to play with it is to enable the shell in your application. To do this add to the file that handles your {{{condefs.h</code> defines:
     45
     46 #define CONFIGURE_SHELL_COMMANDS_INIT
     47 #define CONFIGURE_SHELL_COMMANDS_ALL
     48 #define CONFIGURE_SHELL_MOUNT_RFS
     49 #define CONFIGURE_SHELL_DEBUGRFS
     50 #include <rtems/shellconfig.h>
     51
     52In the main of your application start the shell then at the prompt list the devices you have. The [http://www.rtems.org/ftp/pub/rtems/people/chrisj/file-system/rfs-20100218.tar.gz RFS test application] running on a MCF5235 lists 3 block type devices:
     53
     54 RTEMS SHELL (Ver.1.0-FRC):/dev/console. Feb 20 2010. 'help' to list commands.
     55 [/] # ls -las dev
     56 total 0
     57 0 crwxr-xr-x  1 root  root  0, 0 Jan  1 00:00 console
     58 0 brwxr-xr-x  1 root  root  3, 0 Jan  1 00:00 fdda
     59 0 brwxr-xr-x  1 root  root  4, 0 Jan  1 00:00 nvda
     60 0 brwxr-xr-x  1 root  root  2, 0 Jan  1 00:00 rda
     61 0 crwxr-xr-x  1 root  root  0, 1 Jan  1 00:00 tty01
     62
     63For this example we will use the flash disk. The flash disk on the MCF5235 lives on the single flash device on the board which is shared with the boot monitor that comes with the board. We assume this is a new board so erase the flash:
     64
     65 [/] # fderase /dev/fdda
     66 erase flash disk: /dev/fdda
     67 flash disk erased successful
     68
     69The {{{fderase</code> command can be found in the RFS test application. Next we format the disk with the RFS format command. This command is:
     70
     71<i><b>mkrfs [-v] [-s blksz] [-b grpblk] [-i grpinode] [-I] [-o %inode] dev</b></i>[[BR]]
     72where:
     73;-v : Verbose.
     74;-s blksize : The file system block size.
     75;-b grpblk : Number of blocks in a group.
     76;-i grpinode : Number of inodes in a group.
     77;-I : Initialise the inodes.
     78;-o %inode : The percentage of blocks allocated to inodes in a group.
     79;dev : The device to format.
     80
     81Next we format the flash disk with the default configuration parameters then mounting it:
     82
     83 [/] # mkrfs /dev/fdda
     84 [/] # mkdir f
     85 [/] # mount -t rfs /dev/fdda /f
     86 mounted /dev/fdda -> /f
     87 [/] # ls f
     88 [/]
     89
     90To see the format of the disk run the {{{debugrfs</code> command with the {{{data</code> sub-command:
     91
     92 [/] # debugrfs /f data
     93 RFS Filesystem Data
     94              flags: 00000000
     95             blocks: 1510
     96         block size: 1024
     97               size: 1546240
     98   media block size: 512
     99         media size: 1546240
     100             inodes: 1458
     101         bad blocks: 0
     102   max. name length: 512
     103             groups: 1
     104       group blocks: 8192
     105       group inodes: 1458
     106   inodes per block: 18
     107   blocks per block: 256
     108      singly blocks: 1280
     109     doublly blocks: 327680
     110  max. held buffers: 5
     111        blocks used: 84 (5.5%)
     112        inodes used: 1 (0.0%)