VFS HWFS

From RCSWiki

Jump to: navigation, search

Contents

About

  • Author: Bin Huang
  • Last Modified: 01/07/2009
  • Notes1: These tutorials will describe how to utilize HWFS (hardware filesystem) hardware core designed by Ashwin which aims to handle high-speed writing and reading from a small amount of large files under Linux.
  • Notes2: If the reader just get started with filesystem, it is recommend to refer to Ashwin's HWFS design and Linux VFS (virtual filesystem) interface.

Before you get started, here is a check list for necessary components for using HWFS hardware core under Linux .

  • HWFS hardware core
  • HWFS module for VFS layer

Summary

  • An individual filesystem based on HWFS hardware core
  • A Linux 2.6 kernel module
  • At the time of this writing, it supports regular Linux file system calls (mount, read, write, remove, umount)
  • It works in parallel with NFS, Ext2, etc.
  • It is easier to write scripts to perform administrative functions in user space with VFS

Start to use HWFS: mounting

  • Register our standalone HWFS into Linux by inserting kernel module hwfs.ko:
 # insmod hwfs.ko
  • Select the mount point for mount. At the time of this writing, no physical device is associated to hwfs because the virtual disk is simulated in DDR2 memory and hardwired to HWFS hardware core.
 # mount -t hwfs none /mnt/hwfs
  • If the reader goes to the mount point /mnt/hwfs and does ls, a test file called hwfs_test_file will be shown.
 # ls /mnt/hwfs  
   hwfs_test_file

Reading a file

  • A practical way of using filesystem is to retrieve data from a certain file. No matter the reader is doing that in scripts or in standalone C program, this operation mainly relies on the Linux file system call open.
  • Here is an example for standalone C program:
 fd = open("/mnt/hwfs/hwfs_test_file", O_RDONLY)
 read(fd, buf, 512)
  • It also support reading commands like more as following:
 more /mnt/hwfs/hwfs_test_file

Writing a file

  • Very similar to reading, the reader can also use HWFS in scripts or in standalone C program.
  • Here is an example for standalone C program:
 fd = open("/mnt/hwfs/hwfs_test_file", O_WDONLY)
 write(fd, buf, 512)
  • It also support writing commands like echo as following:
 echo /mnt/hwfs/hwfs_test_file

Removing a file

  • In user space, to remove a file is very straightforward by using the command rm.
 rm /mnt/hwfs/hwfs_test_file

References

Personal tools